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 +4 -4
- data/.github/workflows/actionlint.yml +1 -1
- data/.github/workflows/codecov.yml +1 -1
- data/.github/workflows/copyrights.yml +2 -2
- data/.github/workflows/markdown-lint.yml +1 -1
- data/.github/workflows/pdd.yml +1 -1
- data/.github/workflows/rake.yml +1 -1
- data/.github/workflows/xcop.yml +1 -1
- data/.rultor.yml +1 -1
- data/Gemfile +4 -4
- data/Gemfile.lock +56 -63
- data/lib/telepost.rb +7 -19
- data/telepost.gemspec +2 -2
- data/test/test_telepost.rb +7 -4
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1bfc2471b076fe6343687400f3c9d199f4ba2c01fce7751e5b13d1db31ed29c
|
4
|
+
data.tar.gz: 94a7397bcf43afa770452170c918d672f0fbe47a59bff68d7842e9f3c94a9e45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51fae734e3ab3403eaaa3b8d21ed201a3cbee2a10c9802905061fc2551c83063109ca76134a8fc0cd7ad921ce1d6ddd4d40c9774af7d783e7589a552b3bd37a6
|
7
|
+
data.tar.gz: ec5bb310af82d8ea9aaf82f5465fa7ce5fa7b7ba8559a4404f8dbaa5246e673b1d4300acf8f3d75e5a5aec257669f1ff7646cb314e9686542e3e55694496c2ec
|
data/.github/workflows/pdd.yml
CHANGED
data/.github/workflows/rake.yml
CHANGED
data/.github/workflows/xcop.yml
CHANGED
data/.rultor.yml
CHANGED
data/Gemfile
CHANGED
@@ -23,9 +23,9 @@
|
|
23
23
|
source 'https://rubygems.org'
|
24
24
|
gemspec
|
25
25
|
|
26
|
-
gem 'minitest', '5.
|
26
|
+
gem 'minitest', '5.25.1', require: false
|
27
27
|
gem 'rake', '13.2.1', require: false
|
28
|
-
gem 'rubocop', '1.
|
29
|
-
gem 'rubocop-rspec', '3.0.
|
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.
|
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
|
-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
faraday
|
35
|
-
|
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 (
|
39
|
-
|
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
|
-
|
45
|
+
logger (1.6.1)
|
46
|
+
minitest (5.25.1)
|
49
47
|
multipart-post (2.4.1)
|
50
|
-
|
51
|
-
|
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.
|
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
|
-
|
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
|
-
|
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.
|
68
|
+
rubocop-ast (1.32.3)
|
72
69
|
parser (>= 3.3.1.0)
|
73
|
-
rubocop-rspec (3.0.
|
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.
|
77
|
+
simplecov-html (0.13.1)
|
82
78
|
simplecov_json_formatter (0.1.4)
|
83
|
-
|
84
|
-
|
85
|
-
faraday
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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.
|
94
|
+
minitest (= 5.25.1)
|
102
95
|
rake (= 13.2.1)
|
103
|
-
rubocop (= 1.
|
104
|
-
rubocop-rspec (= 3.0.
|
96
|
+
rubocop (= 1.66.1)
|
97
|
+
rubocop-rspec (= 3.0.5)
|
105
98
|
simplecov (= 0.22.0)
|
106
99
|
telepost!
|
107
|
-
yard (= 0.9.
|
100
|
+
yard (= 0.9.37)
|
108
101
|
|
109
102
|
BUNDLED WITH
|
110
|
-
2.5.
|
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 '
|
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
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
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:
|
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.
|
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 '
|
41
|
+
s.add_dependency 'telegram-bot-ruby', '~> 1.0'
|
42
42
|
s.metadata['rubygems_mfa_required'] = 'true'
|
43
43
|
end
|
data/test/test_telepost.rb
CHANGED
@@ -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
|
-
|
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
|
-
'
|
44
|
-
chats: [
|
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
|
+
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-
|
11
|
+
date: 2024-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
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:
|
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:
|
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: []
|