telegem 3.2.0 → 3.2.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/Readme.md +1 -1
- data/lib/core/bot.rb +2 -0
- data/lib/core/context.rb +76 -0
- data/lib/core/rate_limit.rb +3 -2
- data/lib/markup/keyboard.rb +7 -10
- data/lib/telegem.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d61b868c4601e8372d69f3a30af35e5efb2cfe7024c518c2c239804dd2914e7a
|
|
4
|
+
data.tar.gz: 38069437b5d718560e1480cc3846160bbdcd33a1b03380aadf6785692ebdecf3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '095647f0f51efff1afafc5233341506b76780288aafba0dd87aae6a9ffe42f5115aaf0aaf2a0f5db4034d2a053a7ff0d75d966b1fea34aa7e20e082e06b7bf1d'
|
|
7
|
+
data.tar.gz: fbe3e2f72ac63184f8378ca98108b9a16f87cfcf91219260de04a65bf1945dbdcec4c0d5b49bd82295714e478ad2798a7ffec38e86f411f4a13b6b5524a40dbc
|
data/Readme.md
CHANGED
data/lib/core/bot.rb
CHANGED
data/lib/core/context.rb
CHANGED
|
@@ -42,6 +42,82 @@ module Telegem
|
|
|
42
42
|
inline_query&.query
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def message_id
|
|
46
|
+
message&.message_id
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def message_date
|
|
50
|
+
message&.date
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def edit_date
|
|
54
|
+
message&.edit_date
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def command_name
|
|
58
|
+
message&.command_name
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def has_media?
|
|
62
|
+
message&.has_media? || false
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def media_type
|
|
66
|
+
message&.media_type
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def entities
|
|
70
|
+
message&.entities || []
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def caption_entities
|
|
74
|
+
message&caption_entities || []
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def caption
|
|
78
|
+
message&.caption
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def reply?
|
|
82
|
+
message&.reply?
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def replied_message
|
|
86
|
+
message&.reply_to_message
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def replied_text
|
|
90
|
+
replied_message&.text
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def replied_from
|
|
94
|
+
replied_message&.from
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def replied_chat
|
|
98
|
+
replied_message&.chat
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def update_type
|
|
102
|
+
@update.type
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def is_edited?
|
|
106
|
+
!!@update.edited_message
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def channel_post?
|
|
110
|
+
update_type == :channel_post
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def callback_query?
|
|
114
|
+
update_type == :callback_query
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def inline_query?
|
|
118
|
+
update_type == :inline_query
|
|
119
|
+
end
|
|
120
|
+
|
|
45
121
|
def reply(text, **options)
|
|
46
122
|
return nil unless chat
|
|
47
123
|
|
data/lib/core/rate_limit.rb
CHANGED
|
@@ -88,7 +88,8 @@ module Telegem
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
def cleanup_counter(type, key, now)
|
|
91
|
-
|
|
91
|
+
expires = @counters[type].get_ttl(key) || now
|
|
92
|
+
@counters[type].delete(key) if now > expires
|
|
92
93
|
end
|
|
93
94
|
|
|
94
95
|
def rate_limit_response(ctx)
|
|
@@ -96,5 +97,5 @@ module Telegem
|
|
|
96
97
|
ctx.reply("⏳ Please wait a moment before sending another request.") rescue nil
|
|
97
98
|
nil
|
|
98
99
|
end
|
|
99
|
-
end
|
|
100
|
+
end
|
|
100
101
|
end
|
data/lib/markup/keyboard.rb
CHANGED
|
@@ -152,16 +152,13 @@ module Telegem
|
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
def to_h
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
inline_keyboard: clean_rows
|
|
163
|
-
}
|
|
164
|
-
end
|
|
155
|
+
clean_rows = @buttons.compact.map do |row|
|
|
156
|
+
row = Array(row).compact.select { |btn| is_a?(Hash) }
|
|
157
|
+
row.empty? ? nil : row
|
|
158
|
+
end.compact
|
|
159
|
+
{ inline_keyboard: clean_rows}
|
|
160
|
+
end
|
|
161
|
+
|
|
165
162
|
def to_json(*args)
|
|
166
163
|
to_h.to_json(*args)
|
|
167
164
|
end
|
data/lib/telegem.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'logger'
|
|
|
3
3
|
require 'json'
|
|
4
4
|
|
|
5
5
|
module Telegem
|
|
6
|
-
VERSION = "3.2.
|
|
6
|
+
VERSION = "3.2.1".freeze
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
# Load core components
|
|
@@ -82,4 +82,4 @@ if ENV['TELEGEM_GLOBAL'] == 'true'
|
|
|
82
82
|
def Telegem(token, **options)
|
|
83
83
|
::Telegem.new(token, **options)
|
|
84
84
|
end
|
|
85
|
-
end
|
|
85
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: telegem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.2.
|
|
4
|
+
version: 3.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- sick_phantom
|
|
@@ -159,7 +159,7 @@ metadata:
|
|
|
159
159
|
bug_tracker_uri: https://gitlab.com/ruby-telegem/telegem/-/issues
|
|
160
160
|
documentation_uri: https://gitlab.com/ruby-telegem/telegem/-/tree/main/docs-src?ref_type=heads
|
|
161
161
|
rubygems_mfa_required: 'false'
|
|
162
|
-
post_install_message: "Thanks for installing Telegem 3.2.
|
|
162
|
+
post_install_message: "Thanks for installing Telegem 3.2.1!\n\n\U0001F4DA Documentation:
|
|
163
163
|
https://gitlab.com/ruby-telegem/telegem\n\n\U0001F510 For SSL Webhooks:\nRun: telegem-ssl
|
|
164
164
|
your-domain.com\nThis sets up Let's Encrypt certificates automatically.\n\n\U0001F916
|
|
165
165
|
Happy bot building!\n"
|