telepost 0.8.0 → 0.8.1
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 +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +4 -0
- data/Rakefile +1 -1
- data/lib/telepost.rb +6 -19
- data/telepost.gemspec +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72e3854ed2c2ef04727919095d396357f7cd91641387825a039d28cafdf819cf
|
|
4
|
+
data.tar.gz: 4ef6fe085695c41b615dbc31ce0c885c966ecd357e361625e91d74aad61a07a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29ef8828ecfb355777daffb9a8a69fffd59b3393357bd60bc9b5012a9be6062c67ffd0660cd6d4bbd5c9a5effec7ef4a4c1bafbed5be7801b4494b935c1a3db2
|
|
7
|
+
data.tar.gz: 9e5aab74dccdca37292a2eb5959c2b24396cddfdd6189de47445ad0e48194efee77dbc3a7728303a70d1860f8f80984a9809794cdfecdf0440b5fb929d6effae
|
data/Gemfile
CHANGED
|
@@ -10,6 +10,7 @@ gem 'minitest', '~>6.0', require: false
|
|
|
10
10
|
gem 'minitest-reporters', '~>1.7', require: false
|
|
11
11
|
gem 'rake', '~>13.2', require: false
|
|
12
12
|
gem 'rubocop', '~>1.71', require: false
|
|
13
|
+
gem 'rubocop-elegant', '>=0.0.20', require: false
|
|
13
14
|
gem 'rubocop-minitest', '~>0.38', require: false
|
|
14
15
|
gem 'rubocop-performance', '~>1.25', require: false
|
|
15
16
|
gem 'rubocop-rake', '~>0.7', require: false
|
data/Gemfile.lock
CHANGED
|
@@ -97,6 +97,9 @@ GEM
|
|
|
97
97
|
rubocop-ast (1.49.1)
|
|
98
98
|
parser (>= 3.3.7.2)
|
|
99
99
|
prism (~> 1.7)
|
|
100
|
+
rubocop-elegant (0.0.20)
|
|
101
|
+
lint_roller (~> 1.1)
|
|
102
|
+
rubocop (~> 1.75)
|
|
100
103
|
rubocop-minitest (0.39.1)
|
|
101
104
|
lint_roller (~> 1.1)
|
|
102
105
|
rubocop (>= 1.75.0, < 2.0)
|
|
@@ -146,6 +149,7 @@ DEPENDENCIES
|
|
|
146
149
|
minitest-reporters (~> 1.7)
|
|
147
150
|
rake (~> 13.2)
|
|
148
151
|
rubocop (~> 1.71)
|
|
152
|
+
rubocop-elegant (>= 0.0.20)
|
|
149
153
|
rubocop-minitest (~> 0.38)
|
|
150
154
|
rubocop-performance (~> 1.25)
|
|
151
155
|
rubocop-rake (~> 0.7)
|
data/Rakefile
CHANGED
data/lib/telepost.rb
CHANGED
|
@@ -31,9 +31,7 @@ class Telepost
|
|
|
31
31
|
@sent = []
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def run
|
|
35
|
-
# Nothing to do here
|
|
36
|
-
end
|
|
34
|
+
def run; end
|
|
37
35
|
|
|
38
36
|
def spam(*lines)
|
|
39
37
|
post(0, lines)
|
|
@@ -55,9 +53,6 @@ class Telepost
|
|
|
55
53
|
# @note Raised when message posting fails
|
|
56
54
|
class CantPost < StandardError; end
|
|
57
55
|
|
|
58
|
-
# To make it possible to get the client.
|
|
59
|
-
#
|
|
60
|
-
# @return [Telegram::Bot::Client] The Telegram bot client
|
|
61
56
|
attr_reader :client
|
|
62
57
|
|
|
63
58
|
# Makes a new object. To obtain a token you should talk
|
|
@@ -78,8 +73,10 @@ class Telepost
|
|
|
78
73
|
# @return [void]
|
|
79
74
|
# @raise [RuntimeError] If no block is given
|
|
80
75
|
def run
|
|
81
|
-
raise 'Block must be given' unless block_given?
|
|
76
|
+
raise(RuntimeError, 'Block must be given') unless block_given?
|
|
82
77
|
@bot.listen do |message|
|
|
78
|
+
next unless message.respond_to?(:chat)
|
|
79
|
+
next if message.chat.nil?
|
|
83
80
|
yield(message.chat.id, message.respond_to?(:text) ? message.text : '')
|
|
84
81
|
end
|
|
85
82
|
rescue Net::OpenTimeout
|
|
@@ -108,12 +105,7 @@ class Telepost
|
|
|
108
105
|
# @param lines [Array<String>] Message lines to send
|
|
109
106
|
# @return [Telegram::Bot::Types::Message] The sent message object
|
|
110
107
|
def post(chat, *lines, parse_mode: 'Markdown')
|
|
111
|
-
@bot.api.send_message(
|
|
112
|
-
chat_id: chat,
|
|
113
|
-
parse_mode:,
|
|
114
|
-
disable_web_page_preview: true,
|
|
115
|
-
text: lines.join(' ')
|
|
116
|
-
)
|
|
108
|
+
@bot.api.send_message(chat_id: chat, parse_mode:, disable_web_page_preview: true, text: lines.join(' '))
|
|
117
109
|
end
|
|
118
110
|
|
|
119
111
|
# Attach a file (as a Telegram document) to the chat. The file
|
|
@@ -132,11 +124,6 @@ class Telepost
|
|
|
132
124
|
else
|
|
133
125
|
file
|
|
134
126
|
end
|
|
135
|
-
@bot.api.send_document(
|
|
136
|
-
chat_id: chat,
|
|
137
|
-
document:,
|
|
138
|
-
caption:,
|
|
139
|
-
parse_mode:
|
|
140
|
-
)
|
|
127
|
+
@bot.api.send_document(chat_id: chat, document:, caption:, parse_mode:)
|
|
141
128
|
end
|
|
142
129
|
end
|
data/telepost.gemspec
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
require 'English'
|
|
7
7
|
|
|
8
8
|
Gem::Specification.new do |s|
|
|
9
|
-
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?
|
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
|
|
10
10
|
s.required_ruby_version = '>=3.2'
|
|
11
11
|
s.name = 'telepost'
|
|
12
|
-
s.version = '0.8.
|
|
12
|
+
s.version = '0.8.1'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
s.summary = 'Simple Telegram posting Ruby gem'
|
|
15
15
|
s.description = 'Simple Telegram posting Ruby gem'
|
|
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
|
|
|
19
19
|
s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
|
|
20
20
|
s.rdoc_options = ['--charset=UTF-8']
|
|
21
21
|
s.extra_rdoc_files = ['README.md']
|
|
22
|
-
s.add_dependency
|
|
22
|
+
s.add_dependency('telegram-bot-ruby', '~> 1.0')
|
|
23
23
|
s.metadata['rubygems_mfa_required'] = 'true'
|
|
24
24
|
end
|