telepost 0.4.0 → 0.5.1

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: '0831c6d5e4388551579018345287cc6bc869610795abb994815ca530601c1eb3'
4
- data.tar.gz: a90e179dc5b4241bb4ff3279542e8c3fc63dfc9bfbaa0313e3314ea392faf110
3
+ metadata.gz: b1bfc2471b076fe6343687400f3c9d199f4ba2c01fce7751e5b13d1db31ed29c
4
+ data.tar.gz: 94a7397bcf43afa770452170c918d672f0fbe47a59bff68d7842e9f3c94a9e45
5
5
  SHA512:
6
- metadata.gz: 3736347a28810f3433c4319b16c46dc1d550e4ee85e9885a7540cd9c7b98fa1a9fca5da1b3ab4cdcc4631d121d591cc233f0f19d3cc68c08c8ab073eee24e4c5
7
- data.tar.gz: 4fcc75ad584f8161de7bcf59dd18cee662f49840e3e2ebbdd9a80483225d7661ce02bc1db0cf3e874369c475a5ae6cc99b99ebe4a442bbe3390d477e64865285
6
+ metadata.gz: 51fae734e3ab3403eaaa3b8d21ed201a3cbee2a10c9802905061fc2551c83063109ca76134a8fc0cd7ad921ce1d6ddd4d40c9774af7d783e7589a552b3bd37a6
7
+ data.tar.gz: ec5bb310af82d8ea9aaf82f5465fa7ce5fa7b7ba8559a4404f8dbaa5246e673b1d4300acf8f3d75e5a5aec257669f1ff7646cb314e9686542e3e55694496c2ec
@@ -28,7 +28,7 @@ name: actionlint
28
28
  - master
29
29
  jobs:
30
30
  actionlint:
31
- runs-on: ubuntu-22.04
31
+ runs-on: ubuntu-24.04
32
32
  steps:
33
33
  - uses: actions/checkout@v4
34
34
  - name: Download actionlint
@@ -25,7 +25,7 @@ on:
25
25
  - master
26
26
  jobs:
27
27
  codecov:
28
- runs-on: ubuntu-22.04
28
+ runs-on: ubuntu-24.04
29
29
  steps:
30
30
  - uses: actions/checkout@v4
31
31
  - uses: ruby/setup-ruby@v1
@@ -24,7 +24,7 @@ name: copyrights
24
24
  pull_request:
25
25
  jobs:
26
26
  copyrights:
27
- runs-on: ubuntu-22.04
27
+ runs-on: ubuntu-24.04
28
28
  steps:
29
29
  - uses: actions/checkout@v4
30
- - uses: yegor256/copyrights-action@0.0.4
30
+ - uses: yegor256/copyrights-action@0.0.5
@@ -32,7 +32,7 @@ concurrency:
32
32
  cancel-in-progress: true
33
33
  jobs:
34
34
  markdown-lint:
35
- runs-on: ubuntu-22.04
35
+ runs-on: ubuntu-24.04
36
36
  steps:
37
37
  - uses: actions/checkout@v4
38
38
  - uses: articulate/actions-markdownlint@v1
@@ -28,7 +28,7 @@ on:
28
28
  - master
29
29
  jobs:
30
30
  pdd:
31
- runs-on: ubuntu-22.04
31
+ runs-on: ubuntu-24.04
32
32
  steps:
33
33
  - uses: actions/checkout@v4
34
34
  - uses: volodya-lombrozo/pdd-action@master
@@ -31,7 +31,7 @@ jobs:
31
31
  name: test
32
32
  strategy:
33
33
  matrix:
34
- os: [ubuntu-20.04, macos-12, windows-2022]
34
+ os: [ubuntu-24.04, macos-12, windows-2022]
35
35
  ruby: [3.2, 3.3]
36
36
  runs-on: ${{ matrix.os }}
37
37
  steps:
@@ -24,7 +24,7 @@ on:
24
24
  pull_request:
25
25
  jobs:
26
26
  xcop:
27
- runs-on: ubuntu-22.04
27
+ runs-on: ubuntu-24.04
28
28
  steps:
29
29
  - uses: actions/checkout@v4
30
30
  - uses: g4s8/xcop-action@master
data/.rultor.yml CHANGED
@@ -21,7 +21,7 @@
21
21
  # SOFTWARE.
22
22
  ---
23
23
  docker:
24
- image: yegor256/rultor-image:1.23.1
24
+ image: yegor256/rultor-ruby
25
25
  assets:
26
26
  rubygems.yml: yegor256/home#assets/rubygems.yml
27
27
  install: |-
data/Gemfile CHANGED
@@ -23,9 +23,9 @@
23
23
  source 'https://rubygems.org'
24
24
  gemspec
25
25
 
26
- gem 'minitest', '5.24.1', require: false
26
+ gem 'minitest', '5.25.1', require: false
27
27
  gem 'rake', '13.2.1', require: false
28
- gem 'rubocop', '1.65.0', require: false
29
- gem 'rubocop-rspec', '3.0.2', require: false
28
+ gem 'rubocop', '1.66.1', require: false
29
+ gem 'rubocop-rspec', '3.0.5', require: false
30
30
  gem 'simplecov', '0.22.0', require: false
31
- gem 'yard', '0.9.36', require: false
31
+ gem 'yard', '0.9.37', require: false
data/Gemfile.lock CHANGED
@@ -2,109 +2,102 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  telepost (0.0.0)
5
- telebot (= 0.1.2)
5
+ telegram-bot-ruby (~> 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  ast (2.4.2)
11
- axiom-types (0.1.1)
12
- descendants_tracker (~> 0.0.4)
13
- ice_nine (~> 0.11.0)
14
- thread_safe (~> 0.3, >= 0.3.1)
15
- coercible (1.0.0)
16
- descendants_tracker (~> 0.0.1)
17
- descendants_tracker (0.0.4)
18
- thread_safe (~> 0.3, >= 0.3.1)
19
- docile (1.4.0)
20
- faraday (1.10.3)
21
- faraday-em_http (~> 1.0)
22
- faraday-em_synchrony (~> 1.0)
23
- faraday-excon (~> 1.1)
24
- faraday-httpclient (~> 1.0)
25
- faraday-multipart (~> 1.0)
26
- faraday-net_http (~> 1.0)
27
- faraday-net_http_persistent (~> 1.0)
28
- faraday-patron (~> 1.0)
29
- faraday-rack (~> 1.0)
30
- faraday-retry (~> 1.0)
31
- ruby2_keywords (>= 0.0.4)
32
- faraday-em_http (1.0.0)
33
- faraday-em_synchrony (1.0.0)
34
- faraday-excon (1.1.0)
35
- faraday-httpclient (1.0.1)
11
+ bigdecimal (3.1.8)
12
+ concurrent-ruby (1.3.4)
13
+ docile (1.4.1)
14
+ dry-core (1.0.1)
15
+ concurrent-ruby (~> 1.0)
16
+ zeitwerk (~> 2.6)
17
+ dry-inflector (1.1.0)
18
+ dry-logic (1.5.0)
19
+ concurrent-ruby (~> 1.0)
20
+ dry-core (~> 1.0, < 2)
21
+ zeitwerk (~> 2.6)
22
+ dry-struct (1.6.0)
23
+ dry-core (~> 1.0, < 2)
24
+ dry-types (>= 1.7, < 2)
25
+ ice_nine (~> 0.11)
26
+ zeitwerk (~> 2.6)
27
+ dry-types (1.7.2)
28
+ bigdecimal (~> 3.0)
29
+ concurrent-ruby (~> 1.0)
30
+ dry-core (~> 1.0)
31
+ dry-inflector (~> 1.0)
32
+ dry-logic (~> 1.4)
33
+ zeitwerk (~> 2.6)
34
+ faraday (2.12.0)
35
+ faraday-net_http (>= 2.0, < 3.4)
36
+ json
37
+ logger
36
38
  faraday-multipart (1.0.4)
37
39
  multipart-post (~> 2)
38
- faraday-net_http (1.0.1)
39
- faraday-net_http_persistent (1.2.0)
40
- faraday-patron (1.0.0)
41
- faraday-rack (1.0.0)
42
- faraday-retry (1.0.3)
43
- faraday_middleware (1.2.0)
44
- faraday (~> 1.0)
40
+ faraday-net_http (3.3.0)
41
+ net-http
45
42
  ice_nine (0.11.2)
46
43
  json (2.7.2)
47
44
  language_server-protocol (3.17.0.3)
48
- minitest (5.24.1)
45
+ logger (1.6.1)
46
+ minitest (5.25.1)
49
47
  multipart-post (2.4.1)
50
- parallel (1.25.1)
51
- parser (3.3.4.0)
48
+ net-http (0.4.1)
49
+ uri
50
+ parallel (1.26.3)
51
+ parser (3.3.5.0)
52
52
  ast (~> 2.4.1)
53
53
  racc
54
- racc (1.8.0)
54
+ racc (1.8.1)
55
55
  rainbow (3.1.1)
56
56
  rake (13.2.1)
57
57
  regexp_parser (2.9.2)
58
- rexml (3.3.1)
59
- strscan
60
- rubocop (1.65.0)
58
+ rubocop (1.66.1)
61
59
  json (~> 2.3)
62
60
  language_server-protocol (>= 3.17.0)
63
61
  parallel (~> 1.10)
64
62
  parser (>= 3.3.0.2)
65
63
  rainbow (>= 2.2.2, < 4.0)
66
64
  regexp_parser (>= 2.4, < 3.0)
67
- rexml (>= 3.2.5, < 4.0)
68
- rubocop-ast (>= 1.31.1, < 2.0)
65
+ rubocop-ast (>= 1.32.2, < 2.0)
69
66
  ruby-progressbar (~> 1.7)
70
67
  unicode-display_width (>= 2.4.0, < 3.0)
71
- rubocop-ast (1.31.3)
68
+ rubocop-ast (1.32.3)
72
69
  parser (>= 3.3.1.0)
73
- rubocop-rspec (3.0.2)
70
+ rubocop-rspec (3.0.5)
74
71
  rubocop (~> 1.61)
75
72
  ruby-progressbar (1.13.0)
76
- ruby2_keywords (0.0.5)
77
73
  simplecov (0.22.0)
78
74
  docile (~> 1.1)
79
75
  simplecov-html (~> 0.11)
80
76
  simplecov_json_formatter (~> 0.1)
81
- simplecov-html (0.12.3)
77
+ simplecov-html (0.13.1)
82
78
  simplecov_json_formatter (0.1.4)
83
- strscan (3.1.0)
84
- telebot (0.1.2)
85
- faraday
86
- faraday_middleware
87
- virtus
88
- thread_safe (0.3.6)
89
- unicode-display_width (2.5.0)
90
- virtus (2.0.0)
91
- axiom-types (~> 0.1)
92
- coercible (~> 1.0)
93
- descendants_tracker (~> 0.0, >= 0.0.3)
94
- yard (0.9.36)
79
+ telegram-bot-ruby (1.0.0)
80
+ dry-struct (~> 1.6)
81
+ faraday (~> 2.0)
82
+ faraday-multipart (~> 1.0)
83
+ zeitwerk (~> 2.6)
84
+ unicode-display_width (2.6.0)
85
+ uri (0.13.1)
86
+ yard (0.9.37)
87
+ zeitwerk (2.6.18)
95
88
 
96
89
  PLATFORMS
97
90
  arm64-darwin-22
98
91
  ruby
99
92
 
100
93
  DEPENDENCIES
101
- minitest (= 5.24.1)
94
+ minitest (= 5.25.1)
102
95
  rake (= 13.2.1)
103
- rubocop (= 1.65.0)
104
- rubocop-rspec (= 3.0.2)
96
+ rubocop (= 1.66.1)
97
+ rubocop-rspec (= 3.0.5)
105
98
  simplecov (= 0.22.0)
106
99
  telepost!
107
- yard (= 0.9.36)
100
+ yard (= 0.9.37)
108
101
 
109
102
  BUNDLED WITH
110
- 2.5.6
103
+ 2.5.18
data/lib/telepost.rb CHANGED
@@ -22,7 +22,7 @@
22
22
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
23
  # SOFTWARE.
24
24
 
25
- require 'telebot'
25
+ require 'telegram/bot'
26
26
 
27
27
  # Telepost is a simple gateway to Telegram, which can post messages and
28
28
  # respond to primitive requests:
@@ -71,25 +71,16 @@ class Telepost
71
71
  # to the @BotFather in Telegram.
72
72
  def initialize(token, chats: [])
73
73
  @token = token
74
- @client = Telebot::Client.new(token)
75
74
  @chats = chats
75
+ @bot = Telegram::Bot::Client.new(@token)
76
76
  end
77
77
 
78
78
  # You can run a chat bot to listen to the messages coming to it, in
79
79
  # a separate thread.
80
80
  def run
81
- Telebot::Bot.new(@token).run do |chat, message|
82
- if block_given?
83
- yield(chat, message)
84
- elsif !chat.nil?
85
- id = message.chat.id
86
- if id.positive?
87
- post(
88
- message.chat.id,
89
- "This is your chat ID: `#{message.chat.id}`."
90
- )
91
- end
92
- end
81
+ raise 'Block must be given' unless block_given?
82
+ @bot.listen do |message|
83
+ yield(message.chat.id, message.text)
93
84
  end
94
85
  rescue Net::OpenTimeout
95
86
  retry
@@ -110,14 +101,11 @@ class Telepost
110
101
  # be the admin there). The lines provided will be
111
102
  # concatenated with a space between them.
112
103
  def post(chat, *lines)
113
- msg = lines.join(' ')
114
- @client.send_message(
104
+ @bot.api.send_message(
115
105
  chat_id: chat,
116
106
  parse_mode: 'Markdown',
117
107
  disable_web_page_preview: true,
118
- text: msg
108
+ text: lines.join(' ')
119
109
  )
120
- rescue Telebot::Error => e
121
- raise CantPost, "#{e.message}, can't post this message: \"#{msg}\""
122
110
  end
123
111
  end
data/telepost.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
29
29
  s.required_ruby_version = '>=3.2'
30
30
  s.name = 'telepost'
31
- s.version = '0.4.0'
31
+ s.version = '0.5.1'
32
32
  s.license = 'MIT'
33
33
  s.summary = 'Simple Telegram posting Ruby gem'
34
34
  s.description = 'Simple Telegram posting Ruby gem'
@@ -38,6 +38,6 @@ Gem::Specification.new do |s|
38
38
  s.files = `git ls-files`.split($RS)
39
39
  s.rdoc_options = ['--charset=UTF-8']
40
40
  s.extra_rdoc_files = ['README.md']
41
- s.add_dependency 'telebot', '0.1.2'
41
+ s.add_dependency 'telegram-bot-ruby', '~> 1.0'
42
42
  s.metadata['rubygems_mfa_required'] = 'true'
43
43
  end
@@ -23,6 +23,7 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  require 'minitest/autorun'
26
+ require 'yaml'
26
27
  require_relative '../lib/telepost'
27
28
 
28
29
  # Telepost test.
@@ -38,11 +39,13 @@ class TelepostTest < Minitest::Test
38
39
  end
39
40
 
40
41
  def test_real_posting
41
- skip
42
+ cfg = '/code/home/assets/zerocracy/baza.yml'
43
+ skip unless File.exist?(cfg)
44
+ yaml = YAML.safe_load_file(cfg)
42
45
  tp = Telepost.new(
43
- '1088589765:...',
44
- chats: [-1_001_438_256_738] # codexia channel
46
+ yaml['tg']['token'],
47
+ chats: [yaml['tg']['admin_chat'].to_i]
45
48
  )
46
- tp.spam('This is just a test message')
49
+ tp.spam('This is just a test message from telepost test')
47
50
  end
48
51
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telepost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-11 00:00:00.000000000 Z
11
+ date: 2024-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: telebot
14
+ name: telegram-bot-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.2
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.2
26
+ version: '1.0'
27
27
  description: Simple Telegram posting Ruby gem
28
28
  email: yegor256@gmail.com
29
29
  executables: []
@@ -58,7 +58,7 @@ licenses:
58
58
  - MIT
59
59
  metadata:
60
60
  rubygems_mfa_required: 'true'
61
- post_install_message:
61
+ post_install_message:
62
62
  rdoc_options:
63
63
  - "--charset=UTF-8"
64
64
  require_paths:
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubygems_version: 3.4.10
78
- signing_key:
78
+ signing_key:
79
79
  specification_version: 4
80
80
  summary: Simple Telegram posting Ruby gem
81
81
  test_files: []