telepost 0.9.0 → 0.10.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: 847510fbfea002fc65ee0a20dbc39dd2c5ede53aab590c5a8aa2ed66f2bdc50e
4
- data.tar.gz: '086d01f73bff093ef51dbbcb67757d48d21a37211131ca6522e5b2f25901345b'
3
+ metadata.gz: bb2f082807cb2bf827333ccbaf2dbe286b46edd1ddd8518df9628c7507822dc3
4
+ data.tar.gz: bcd93a98a219b978a7673c49746b54dd8240bbbfa51c2a1749fd17d129a96455
5
5
  SHA512:
6
- metadata.gz: 77b5815fcaa702a9a0c422b7633e4992cb7824d79e0c0eb0a77ce03bd4e58464463eab5a3a154e47c4aad0704601d9fc7fa43c1c3fb2656401e88d1d4bd4df04
7
- data.tar.gz: 4e9334873a9a5e0e9e7c92828b657fbc00b9f822e6c471f6c57bc7b582e3a54b6c6dde6a3c332de43614cffe7c31485678f8206f8fff7ee185ba9c6dc1f65142
6
+ metadata.gz: 6a96040340518bec226b2ff447ac0d784e23785050de3c518c84369f64e265eba8225459d04405de64e2b877529d594f04597f8617689af6331f6d76f56c1d14
7
+ data.tar.gz: a1278e354d65fe8fbc9ae8adcea25ae851e6f10223ccfd735de47b8d39331982191b01b6abf76e79d593f235423d52f591715c3d28b828b78e46f243b3d53de0
data/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GEM
13
13
  ast (2.4.3)
14
14
  bigdecimal (4.1.2)
15
15
  builder (3.3.0)
16
- concurrent-ruby (1.3.6)
16
+ concurrent-ruby (1.3.7)
17
17
  crack (1.0.1)
18
18
  bigdecimal
19
19
  rexml
@@ -41,18 +41,18 @@ GEM
41
41
  dry-inflector (~> 1.0)
42
42
  dry-logic (~> 1.4)
43
43
  zeitwerk (~> 2.6)
44
- faraday (2.14.2)
44
+ faraday (2.14.3)
45
45
  faraday-net_http (>= 2.0, < 3.5)
46
46
  json
47
47
  logger
48
48
  faraday-multipart (1.2.0)
49
49
  multipart-post (~> 2.0)
50
- faraday-net_http (3.4.3)
50
+ faraday-net_http (3.4.4)
51
51
  net-http (~> 0.5)
52
52
  hashdiff (1.2.1)
53
53
  ice_nine (0.11.2)
54
- json (2.19.5)
55
- language_server-protocol (3.17.0.5)
54
+ json (2.21.2)
55
+ language_server-protocol (3.17.0.6)
56
56
  lint_roller (1.1.0)
57
57
  logger (1.7.0)
58
58
  minitest (6.0.6)
@@ -67,7 +67,7 @@ GEM
67
67
  net-http (0.9.1)
68
68
  uri (>= 0.11.1)
69
69
  parallel (2.1.0)
70
- parser (3.3.11.1)
70
+ parser (3.3.12.0)
71
71
  ast (~> 2.4.1)
72
72
  racc
73
73
  prism (1.9.0)
@@ -77,8 +77,8 @@ GEM
77
77
  rake (13.4.2)
78
78
  regexp_parser (2.12.0)
79
79
  rexml (3.4.4)
80
- rubocop (1.86.2)
81
- json (~> 2.3)
80
+ rubocop (1.90.0)
81
+ json (>= 2.3)
82
82
  language_server-protocol (~> 3.17.0.2)
83
83
  lint_roller (~> 1.1.0)
84
84
  parallel (>= 1.10)
@@ -88,19 +88,19 @@ GEM
88
88
  rubocop-ast (>= 1.49.0, < 2.0)
89
89
  ruby-progressbar (~> 1.7)
90
90
  unicode-display_width (>= 2.4.0, < 4.0)
91
- rubocop-ast (1.49.1)
91
+ rubocop-ast (1.50.0)
92
92
  parser (>= 3.3.7.2)
93
93
  prism (~> 1.7)
94
94
  rubocop-elegant (0.5.1)
95
95
  lint_roller (~> 1.1)
96
96
  rubocop (~> 1.75)
97
- rubocop-minitest (0.39.1)
97
+ rubocop-minitest (0.40.0)
98
98
  lint_roller (~> 1.1)
99
99
  rubocop (>= 1.75.0, < 2.0)
100
100
  rubocop-ast (>= 1.38.0, < 2.0)
101
- rubocop-performance (1.26.1)
101
+ rubocop-performance (1.27.0)
102
102
  lint_roller (~> 1.1)
103
- rubocop (>= 1.75.0, < 2.0)
103
+ rubocop (>= 1.89.0, < 2.0)
104
104
  rubocop-ast (>= 1.47.1, < 2.0)
105
105
  rubocop-rake (0.7.1)
106
106
  lint_roller (~> 1.1)
@@ -124,11 +124,11 @@ GEM
124
124
  unicode-emoji (~> 4.1)
125
125
  unicode-emoji (4.2.0)
126
126
  uri (1.1.1)
127
- webmock (3.26.2)
127
+ webmock (3.26.3)
128
128
  addressable (>= 2.8.0)
129
129
  crack (>= 0.3.2)
130
130
  hashdiff (>= 0.4.0, < 2.0.0)
131
- yard (0.9.44)
131
+ yard (0.9.45)
132
132
  zeitwerk (2.8.2)
133
133
 
134
134
  PLATFORMS
data/README.md CHANGED
@@ -46,13 +46,15 @@ tp = Telepost.new('..token..', chats: [12345])
46
46
  tp.spam('How are you?')
47
47
  ```
48
48
 
49
- You can also attach a file (sent as a Telegram document). The
50
- `file` argument accepts a path or an already-open `IO`/`File`,
51
- and `caption:` is optional:
49
+ You can also attach a file. The `file` argument accepts a path or
50
+ an already-open `IO`/`File`, and `caption:` is optional. A file with
51
+ an image extension goes out as a photo, which Telegram shows inline,
52
+ while everything else goes out as a document:
52
53
 
53
54
  ```ruby
54
55
  tp = Telepost.new('..token..')
55
56
  tp.attach(12345, '/tmp/dump.sql', caption: 'Today is dump')
57
+ tp.attach(12345, '/tmp/chart.png', caption: 'Today is chart')
56
58
  ```
57
59
 
58
60
  You can also pass an array of files, to post them all as a single
data/lib/telepost.rb CHANGED
@@ -121,9 +121,11 @@ class Telepost
121
121
  @bot.api.send_message(chat_id: chat, parse_mode:, disable_web_page_preview: true, text: lines.join(' '))
122
122
  end
123
123
 
124
- # Attach a file (as a Telegram document) to the chat. The file
125
- # argument can either be a path (String) or an open IO/File. The
126
- # filename shown in Telegram comes from the basename of the path.
124
+ # Attach a file to the chat. The file argument can either be a
125
+ # path (String) or an open IO/File. The filename shown in Telegram
126
+ # comes from the basename of the path. A file with an image
127
+ # extension goes out as a photo via +sendPhoto+, so Telegram shows
128
+ # it inline, and everything else as a document via +sendDocument+.
127
129
  #
128
130
  # When +file+ is an +Array+, all of its items are posted as a single
129
131
  # grouped message (a Telegram "album") via +sendMediaGroup+. Items
@@ -139,7 +141,11 @@ class Telepost
139
141
  def attach(chat, file, caption: nil, parse_mode: 'Markdown')
140
142
  return album(chat, file, caption:, parse_mode:) if file.is_a?(Array)
141
143
  io = upload(file)
142
- @bot.api.send_document(chat_id: chat, document: io, caption:, parse_mode:)
144
+ if photo?(file)
145
+ @bot.api.send_photo(chat_id: chat, photo: io, caption:, parse_mode:)
146
+ else
147
+ @bot.api.send_document(chat_id: chat, document: io, caption:, parse_mode:)
148
+ end
143
149
  ensure
144
150
  io.close if file.is_a?(String) && io.respond_to?(:close)
145
151
  end
data/telepost.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
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.9.0'
12
+ s.version = '0.10.0'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Simple Telegram posting Ruby gem'
15
15
  s.description = 'Simple Telegram posting Ruby gem'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telepost
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko