reddit-to-telegram 0.10.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fa8c86edbe2717330cedef9d55d49a2d1eb88030cc57a80c73d0658009c371a
4
- data.tar.gz: f1484d64987d38e487ca35419330cb1aba1eb849c86aa80f7cc1b5718abb2cb4
3
+ metadata.gz: f3c90c3500377ec39f458058ec1c31dacf5c40f5432b1a6ea49634b7e27e614b
4
+ data.tar.gz: e1f448fd52360e605ea72d5d713b042db4cb1d18289cdbf214aee1b715b2b538
5
5
  SHA512:
6
- metadata.gz: ffbca702ce0c85ad6cf26a5874d593a6d7b4b5d60b03219ea4543509ea2d04e07564174d14576e49c8d78b34395070283b15a6b2de67c1e158df45ea826ed5ab
7
- data.tar.gz: 58147fcf09d213770b73bf21cdaf50bfb4fae9ebe3a62288c9a784a2ba996b971bbe77811363e4edb2deb0b59a0ba4140f801dd584241f2021d1e8ff4da95ab2
6
+ metadata.gz: 3fff45f081de429c62223f8ec2fe711c8c4ee756776e4153feeaf5c01f2753518de7520e44c3bdebe52e01e4914e0d77380afd21d931f01184520abe4c8990ae
7
+ data.tar.gz: cda7f819e6166c55bc57bfc04515aea3d62333ad9b38cab852188637c1d09ddddc303cd0a0350f25bc263238f0c261a886780f893b9afb49336da87964f4a4eb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reddit-to-telegram (0.10.1)
4
+ reddit-to-telegram (0.11.0)
5
5
  aws-sdk-dynamodb (~> 1.106)
6
6
  httparty
7
7
 
data/README.md CHANGED
@@ -39,8 +39,8 @@ aws.access_key_id | RTT_AWS_ACCESS_KEY_ID | Your AWS access key
39
39
  aws.region | RTT_AWS_REGION | AWS region your DynamoDB is hosted on |
40
40
  aws.secret_access_key | RTT_AWS_SECRET_ACCESS_KEY | Your AWS access key ID. Needed for AWS DynamoDB storage. |
41
41
  google.api_key | RTT_GOOGLE_API_KEY | Your Google API key to translate posts via Google Translate |
42
- reddit.client_id | RTT_REDDIT_CLIENT_ID | Reddit app credentials to access API. Reddit allows more authenticated requests |
43
- reddit.client_secret | RTT_REDDIT_CLIENT_SECRET | Reddit app credentials to access API. Reddit allows more authenticated requests |
42
+ reddit.client_id * | RTT_REDDIT_CLIENT_ID | Reddit app credentials to access API. Reddit allows more authenticated requests |
43
+ reddit.client_secret * | RTT_REDDIT_CLIENT_SECRET | Reddit app credentials to access API. Reddit allows more authenticated requests |
44
44
  store.max_stored_posts | RTT_MAX_STORED_POSTS | Number of posts to store in the database to avoid duplicates, default is 25 |
45
45
  store.tmp_dir | RTT_TEMP_DIR | Directory to write temp files to without trailing `/` |
46
46
  store.type | RTT_STORE_TYPE | Choose between `aws_dynamo_db`, `memory` or `temp_file`. Default is `aws_dynamo_db`, so if you're not specifying your AWS credentials, you have to choose another store type |
@@ -18,7 +18,7 @@ module RedditToTelegram
18
18
 
19
19
  class << self
20
20
  def hot(subreddit, retries_left = 5)
21
- headers = BASE_HEADERS.merge("Authorization" => "Bearer #{Store::Reddit.token}")
21
+ headers = BASE_HEADERS.merge("Authorization" => "Bearer #{Auth.token}")
22
22
  res = HTTParty.get(
23
23
  "#{BASE_URI}/#{subreddit}/hot.json",
24
24
  query: QUERY_FOR_SUBREDDIT,
@@ -29,7 +29,7 @@ module RedditToTelegram
29
29
  end
30
30
 
31
31
  def post(link, retries_left = 5)
32
- headers = BASE_HEADERS.merge("Authorization" => "Bearer #{Store::Reddit.token}")
32
+ headers = BASE_HEADERS.merge("Authorization" => "Bearer #{Auth.token}")
33
33
  link = link.gsub("www", "oauth") if link.match(/www.reddit.com/)
34
34
  link += ".json" unless link.match(/.json/)
35
35
 
@@ -49,8 +49,6 @@ module RedditToTelegram
49
49
  func_args = Array(func.values.first)
50
50
 
51
51
  case res.code
52
- when 401
53
- handle_401(func_name, func_args)
54
52
  when 429
55
53
  handle_429(func_name, func_args)
56
54
  when 200
@@ -60,19 +58,6 @@ module RedditToTelegram
60
58
  end
61
59
  end
62
60
 
63
- def handle_401(func_name, func_args)
64
- retries_left = func_args.last
65
- func_args[func_args.length - 1] = retries_left - 1
66
-
67
- Store::Reddit.token = Auth.token
68
-
69
- if retries_left > 0
70
- send(func_name, *func_args)
71
- else
72
- Errors.new(FailedToFetchFromReddit, "Failed to authenticate")
73
- end
74
- end
75
-
76
61
  def handle_429(func_name, func_args)
77
62
  retries_left = func_args.last
78
63
 
@@ -19,8 +19,6 @@ module RedditToTelegram
19
19
 
20
20
  private
21
21
 
22
- attr_reader :reddit_token
23
-
24
22
  def setup
25
23
  check_credentials
26
24
  prepare_db
@@ -87,7 +85,6 @@ module RedditToTelegram
87
85
  end
88
86
 
89
87
  def assign_default_values
90
- @reddit_token = ""
91
88
  @posts = {}
92
89
  end
93
90
 
@@ -6,8 +6,6 @@ module RedditToTelegram
6
6
  class << self
7
7
  private
8
8
 
9
- attr_accessor :reddit_token
10
-
11
9
  @posts = {}
12
10
 
13
11
  def setup; end
@@ -8,7 +8,7 @@ module RedditToTelegram
8
8
  class << self
9
9
  private
10
10
 
11
- attr_reader :reddit_token, :posts
11
+ attr_reader :posts
12
12
 
13
13
  @reddit_token = nil
14
14
  @posts = {}
@@ -52,7 +52,6 @@ module RedditToTelegram
52
52
 
53
53
  file = File.read(temp_file_path)
54
54
  data = JSON.parse(file)
55
- @reddit_token = data["reddit_token"]
56
55
  @posts = {}
57
56
  data.each do |key, value|
58
57
  @posts[key.split("_").last.to_sym] = value.transform_keys(&:to_sym) if key.match?(/posts_.+/)
@@ -60,7 +59,6 @@ module RedditToTelegram
60
59
  end
61
60
 
62
61
  def write_file
63
- data = { reddit_token: @reddit_token }
64
62
  @posts.each do |telegram_chat_id, values|
65
63
  data["posts_#{telegram_chat_id}"] = values
66
64
  end
@@ -68,7 +66,6 @@ module RedditToTelegram
68
66
  end
69
67
 
70
68
  def assign_default_values
71
- @reddit_token = nil
72
69
  @posts = {}
73
70
  end
74
71
 
@@ -22,27 +22,11 @@ module RedditToTelegram
22
22
  Configuration.store.max_stored_posts - 1
23
23
  end
24
24
 
25
- def reddit
26
- Reddit
27
- end
28
-
29
25
  def posts
30
26
  Posts
31
27
  end
32
28
  end
33
29
 
34
- class Reddit
35
- class << self
36
- def token
37
- Store.active.send(:reddit_token)
38
- end
39
-
40
- def token=(val)
41
- Store.active.send(:reddit_token=, val)
42
- end
43
- end
44
- end
45
-
46
30
  class Posts
47
31
  class << self
48
32
  def add(telegram_chat_id, subreddit, id)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RedditToTelegram
4
- VERSION = "0.10.1"
4
+ VERSION = "0.11.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddit-to-telegram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Tityuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-01 00:00:00.000000000 Z
11
+ date: 2025-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb