i_delete_my_tweets 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca760bf67d5926944ba6dad201cf0ce4c53ec5b1fbd37c169e21dd79ff30a75d
4
- data.tar.gz: fae34815f3666a5d90bc9f3d63a7a7b63ae2f4325a0d5ddf699c3bc49a60092f
3
+ metadata.gz: e03c2ee22696ed493efe66668726bf473b813ec6043f30ce8e5ac26e095040c8
4
+ data.tar.gz: c659a42b19e9265a52d78bb21e5484658eea8de3335cfe453a2c27de584e2295
5
5
  SHA512:
6
- metadata.gz: 06a03f903c7d12ac099b59c0621a3109f66944819b4b5c84313d6b39e4a24253bb005c42f68802268240196a52af69084c57759f2f2c97bab62ca441585b3dc2
7
- data.tar.gz: b59dc5a37339c5cb4ea3aeae09390b845791e920cc39678608182d51384139a153cb06460a82dbc69d589fa6ba2a1b757fc824b20f99dae1f02625746c726a23
6
+ metadata.gz: b29e101e19c38ee684690bd3046ebb2415864d10b5a92857aebfead4698a3dd91c6032e2d9fd30ae48a7f357e4aa406145cec8466281e932020165c9b712513f
7
+ data.tar.gz: d72ee4efb6b18138ff23c5d213aecdc16ddeacb06b923a1c8116a6fc27353d8b51cb0e7006cf906a14c724bcf952677b180cd9d491efdc2bc874638ca9ed509a
data/.env.sample CHANGED
@@ -6,4 +6,5 @@ OLDER_THAN="2022-04-28 21:20:47 -0300"
6
6
  PATH_TO_CSV='./tweets.csv'
7
7
  FAVE_THRESHOLD=3
8
8
  RT_THRESHOLD=5
9
+ WITH_WORDS=#FML,#TBT,musk,trump
9
10
  SCREEN_NAME=jack
data/.env.test CHANGED
@@ -6,4 +6,5 @@ OLDER_THAN="2022-04-28 21:20:47 -0300"
6
6
  PATH_TO_CSV='./tweets.csv'
7
7
  FAVE_THRESHOLD=3
8
8
  RT_THRESHOLD=5
9
+ WITH_WORDS=#FML,#TBT,musk,trump
9
10
  SCREEN_NAME=jack
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # I Delete My Tweets
2
2
 
3
- [![Coverage Status](https://coveralls.io/repos/github/spiceee/i_delete_my_tweets/badge.svg?branch=chore/add-github-action)](https://coveralls.io/github/spiceee/i_delete_my_tweets?branch=chore/add-github-action)
3
+ [![Coverage Status](https://coveralls.io/repos/github/spiceee/i_delete_my_tweets/badge.svg?branch=master)](https://coveralls.io/github/spiceee/i_delete_my_tweets?branch=master)
4
4
 
5
5
  <img width="800" alt="Screen Shot 2022-05-11 at 19 04 53" src="https://user-images.githubusercontent.com/12278/167955371-a24ec8e6-bd9a-4014-bc25-9fb9e3cb21ce.png">
6
6
 
@@ -31,17 +31,18 @@ These are the keys/values that make the script work. They are read from and writ
31
31
  a `.i_delete_my_tweets` env file in your user directory (~/). You can fill
32
32
  the values yourself or work with the <config store> commands (see Usage) to do that interactively.
33
33
 
34
- | KEY | VALUE | DESCRIPTION |
35
- | ------------------- | --------------------------- | ---------------------------------------- |
36
- | CONSUMER_KEY | String | Your Twitter App key |
37
- | CONSUMER_SECRET | String | Your Twitter App secret |
38
- | ACCESS_TOKEN | String | Account access token |
39
- | ACCESS_TOKEN_SECRET | String | Access token secret |
40
- | OLDER_THAN | "2022-04-28 21:20:47 -0300" | A timestamp |
41
- | PATH_TO_CSV | './tweets.csv' | A path to a CSV file |
42
- | FAVE_THRESHOLD | 3 | Minimum number of faves to skip deletion |
43
- | RT_THRESHOLD | 5 | Minimum number of RTs to skip deletion |
44
- | SCREEN_NAME | jack | The account screen_name |
34
+ | KEY | VALUE | DESCRIPTION |
35
+ | ------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
36
+ | CONSUMER_KEY | String | Your Twitter App key |
37
+ | CONSUMER_SECRET | String | Your Twitter App secret |
38
+ | ACCESS_TOKEN | String | Account access token |
39
+ | ACCESS_TOKEN_SECRET | String | Access token secret |
40
+ | OLDER_THAN | "2022-04-28 21:20:47 -0300" | A timestamp (code to avoid system parser problems) |
41
+ | PATH_TO_CSV | './tweets.csv' | A path to a CSV file |
42
+ | FAVE_THRESHOLD | 3 | Minimum number of faves to skip deletion |
43
+ | RT_THRESHOLD | 5 | Minimum number of RTs to skip deletion |
44
+ | WITH_WORDS | #FML, trump, musk | A comma-separated list of words and hashtags that, if found on a tweet, would delete it immediately.<br>If this list is _not_ empty, IDMT will use the words only and bypass any FAVE or RT threshold criteria.<br>OLDER_THAN is always taken into account, though. |
45
+ | SCREEN_NAME | jack | The account screen_name |
45
46
 
46
47
  Since you have to call commands with `--dry-run=false` for them to really take action, just play around with the skip rules before using `--dry-run=false` and see what works for you.
47
48
 
@@ -91,6 +92,7 @@ $ i_delete_my_tweets config store RT_THRESHOLD 2
91
92
  $ i_delete_my_tweets config store FAVE_THRESHOLD 2
92
93
  $ i_delete_my_tweets config store OLDER_THAN 2021-11-02
93
94
  $ i_delete_my_tweets config store SCREEN_NAME mytwitterhandle
95
+ $ i_delete_my_tweets config store WITH_WORDS "#fml, #drunktweets, rogan"
94
96
  ```
95
97
 
96
98
  IDMT can generate an `ACCESS_TOKEN` and `ACCESS_TOKEN_SECRET` for you using a PIN provided
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.add_dependency 'activesupport', '~> 6.1.5.1'
7
7
  spec.add_dependency 'csv', '~> 3.0.9'
8
8
  spec.add_dependency 'dotenv', '~> 2.7.6'
9
- spec.add_dependency 'oauth', '>= 0.5.5'
9
+ spec.add_dependency 'oauth', '~> 0.5.5'
10
10
  spec.add_dependency 'progress', '~> 3.6.0'
11
11
  spec.add_dependency 'terminal-table', '~> 3.0.2'
12
12
  spec.add_dependency 'thor', '~> 1.2.1'
@@ -117,12 +117,21 @@ module IDeleteMyTweets
117
117
  tweet.retweet_count < config.rt_threshold.to_i
118
118
  end
119
119
 
120
+ def includes_words?(tweet)
121
+ tweet.text.match(config.compiled_words_regex)
122
+ end
123
+
120
124
  def can_be_destroyed?(tweet)
121
125
  return false unless satisfies_older_than? tweet
122
- return false unless bellow_fave_threshold? tweet
123
- return false unless bellow_rt_threshold? tweet
124
126
 
125
- true
127
+ if config.with_words.empty?
128
+ return false unless bellow_fave_threshold? tweet
129
+ return false unless bellow_rt_threshold? tweet
130
+
131
+ true
132
+ else
133
+ includes_words?(tweet)
134
+ end
126
135
  end
127
136
 
128
137
  def collect_with_max_id(collection = [], max_id = nil, &block)
@@ -10,10 +10,12 @@ module IDeleteMyTweets
10
10
  "PATH_TO_CSV",
11
11
  "FAVE_THRESHOLD",
12
12
  "RT_THRESHOLD",
13
+ "WITH_WORDS",
13
14
  "SCREEN_NAME"
14
15
  ].freeze
15
16
  PATH_TO_ENV = "~/.i_delete_my_tweets".freeze
16
17
  OBFUSCATE_WORDS = %w(secret token key).freeze
18
+ OPTIONALS = %w(with_words).freeze
17
19
 
18
20
  class Config
19
21
  attr_accessor :consumer_key,
@@ -24,6 +26,7 @@ module IDeleteMyTweets
24
26
  :path_to_csv,
25
27
  :fave_threshold,
26
28
  :rt_threshold,
29
+ :with_words,
27
30
  :screen_name
28
31
 
29
32
  def initialize(opts = {})
@@ -35,6 +38,7 @@ module IDeleteMyTweets
35
38
  @path_to_csv = opts[:path_to_csv] || ENV.fetch("PATH_TO_CSV", "./")
36
39
  @fave_threshold = opts[:fave_threshold] || ENV.fetch("FAVE_THRESHOLD", 0)
37
40
  @rt_threshold = opts[:rt_threshold] || ENV.fetch("RT_THRESHOLD", 0)
41
+ @with_words = opts[:with_words] || ENV.fetch("WITH_WORDS", "")
38
42
  @screen_name = opts[:screen_name] || ENV.fetch("SCREEN_NAME", "")
39
43
  end
40
44
 
@@ -62,7 +66,17 @@ module IDeleteMyTweets
62
66
  end
63
67
 
64
68
  def empty_values
65
- zipped.map { |tuples| tuples.second.to_s.empty? ? tuples.first : nil }.compact
69
+ zipped.reject { |tuples| OPTIONALS.member?(tuples.first.downcase) }
70
+ .map { |tuples| tuples.second.to_s.empty? ? tuples.first : nil }
71
+ .compact
72
+ end
73
+
74
+ def compiled_words_regex
75
+ @compiled_words_regex ||= Regexp.union(
76
+ with_words.split(",")
77
+ .map(&:squish)
78
+ .map { |word| /(?<=\s|^)#{Regexp.quote(word)}\b/i }
79
+ )
66
80
  end
67
81
 
68
82
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i_delete_my_tweets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'Fabio"
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-06-08 00:00:00.000000000 Z
13
+ date: 2022-06-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -58,14 +58,14 @@ dependencies:
58
58
  name: oauth
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
63
  version: 0.5.5
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ">="
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: 0.5.5
71
71
  - !ruby/object:Gem::Dependency