gruubY 0.2.2 → 0.2.3
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/LICENSE +21 -21
- data/README.md +11 -6
- data/Rakefile +51 -51
- data/example/bot.rb +120 -1
- data/example/generate_user_session.rb +81 -81
- data/example/tdlib.rb +77 -77
- data/example/userbot.rb +133 -133
- data/lib/gruubY/api.rb +540 -363
- data/lib/gruubY/async.rb +13 -13
- data/lib/gruubY/bot.rb +104 -90
- data/lib/gruubY/bound.rb +14 -14
- data/lib/gruubY/client.rb +310 -296
- data/lib/gruubY/context.rb +296 -242
- data/lib/gruubY/dispatcher.rb +60 -60
- data/lib/gruubY/enums.rb +57 -62
- data/lib/gruubY/exception.rb +5 -5
- data/lib/gruubY/file_stream.rb +17 -17
- data/lib/gruubY/filters.rb +292 -292
- data/lib/gruubY/group_manager.rb +213 -213
- data/lib/gruubY/handlers.rb +225 -170
- data/lib/gruubY/keyboard.rb +49 -49
- data/lib/gruubY/media.rb +38 -38
- data/lib/gruubY/middleware.rb +18 -18
- data/lib/gruubY/plugin.rb +26 -26
- data/lib/gruubY/raw.rb +25 -25
- data/lib/gruubY/retry.rb +14 -14
- data/lib/gruubY/server.rb +18 -18
- data/lib/gruubY/session.rb +30 -30
- data/lib/gruubY/tdlib/client.rb +565 -565
- data/lib/gruubY/tdlib/client_manager.rb +37 -37
- data/lib/gruubY/tdlib/decorators.rb +17 -17
- data/lib/gruubY/tdlib/errors.rb +6 -6
- data/lib/gruubY/tdlib/group_manager.rb +58 -58
- data/lib/gruubY/tdlib/native.rb +72 -72
- data/lib/gruubY/tdlib/schema_builder.rb +237 -237
- data/lib/gruubY/tdlib/tdjson.rb +49 -49
- data/lib/gruubY/tdlib/user_session.rb +69 -69
- data/lib/gruubY/types/base_object.rb +72 -72
- data/lib/gruubY/types/bound_entities.rb +289 -245
- data/lib/gruubY/types/chat.rb +93 -93
- data/lib/gruubY/types/chat_info.rb +32 -31
- data/lib/gruubY/types/extra.rb +289 -251
- data/lib/gruubY/types/message.rb +301 -295
- data/lib/gruubY/types/message_entity.rb +14 -14
- data/lib/gruubY/types/registry.rb +86 -67
- data/lib/gruubY/types/user.rb +47 -31
- data/lib/gruubY/webapp.rb +22 -22
- data/lib/gruubY.rb +39 -41
- data/plugins/logger.rb +7 -7
- metadata +3 -9
- data/example/ntgcalls.rb +0 -80
- data/lib/gruubY/ntgcalls/native.rb +0 -100
- data/lib/gruubY/ntgcalls.rb +0 -478
- data/lib/gruubY/raw_types.rb +0 -57
- data/plugins/media_tools.rb +0 -13
data/lib/gruubY/enums.rb
CHANGED
|
@@ -1,62 +1,57 @@
|
|
|
1
|
-
module GrubY
|
|
2
|
-
module Enums
|
|
3
|
-
DEFINITIONS = {
|
|
4
|
-
BlockList: %w[main stories],
|
|
5
|
-
BusinessSchedule: %w[always offline custom],
|
|
6
|
-
ButtonStyle: %w[default primary danger success],
|
|
7
|
-
ChatAction: %w[typing upload_photo record_video upload_video record_voice upload_voice upload_document choose_sticker find_location record_video_note upload_video_note],
|
|
8
|
-
ChatEventAction: %w[create edit delete pin unpin join leave invite restrict promote],
|
|
9
|
-
ChatJoinType: %w[by_link by_request by_invite by_username],
|
|
10
|
-
ChatMemberStatus: %w[creator administrator member restricted left kicked],
|
|
11
|
-
ChatMembersFilter: %w[recent administrators contacts bots banned restricted search],
|
|
12
|
-
ChatType: %w[private bot group supergroup channel direct forum],
|
|
13
|
-
ClientPlatform: %w[ruby linux windows macos android ios web],
|
|
14
|
-
FolderColor: %w[blue cyan green orange pink purple red yellow],
|
|
15
|
-
MessageEntityType: %w[mention hashtag cashtag bot_command url email phone_number bold italic underline strikethrough spoiler code pre text_link text_mention custom_emoji],
|
|
16
|
-
MessageMediaType: %w[text photo video animation audio voice video_note document sticker contact location venue poll dice game story paid_media],
|
|
17
|
-
MessageOriginType: %w[user hidden_user chat channel],
|
|
18
|
-
MessageServiceType: %w[new_chat_members left_chat_member new_chat_title new_chat_photo delete_chat_photo group_chat_created supergroup_chat_created channel_chat_created migrate_to_chat_id migrate_from_chat_id pinned_message game_score video_chat_started video_chat_ended video_chat_members_invited successful_payment],
|
|
19
|
-
MessagesFilter: %w[empty photo video document url gif voice
|
|
20
|
-
NextCodeType: %w[sms call flash_call missed_call fragment app],
|
|
21
|
-
PaidReactionPrivacy: %w[anonymous default sender],
|
|
22
|
-
ParseMode: %w[markdown markdown_v2 html],
|
|
23
|
-
PhoneCallDiscardReason: %w[missed disconnect hangup busy],
|
|
24
|
-
PhoneNumberCodeType: %w[sms call flash_call missed_call fragment app],
|
|
25
|
-
PollType: %w[regular quiz],
|
|
26
|
-
PrivacyKey: %w[last_seen phone_number profile_photo forwards calls p2p_invite link_in_bio birthday gifts voice_messages about],
|
|
27
|
-
ProfileColor: %w[blue cyan green orange pink purple red yellow],
|
|
28
|
-
ProfileTab: %w[profile gifts media links files voice],
|
|
29
|
-
ReplyColor: %w[blue cyan green orange pink purple red yellow],
|
|
30
|
-
SentCodeType: %w[sms call flash_call missed_call fragment app firebase email],
|
|
31
|
-
StoriesPrivacyRules: %w[everyone contacts close_friends selected],
|
|
32
|
-
UserStatus: %w[online offline recently last_week last_month long_time_ago],
|
|
33
|
-
UpgradedGiftOrigin: %w[upgrade gift_code transfer craft purchase],
|
|
34
|
-
GiftAttributeType: %w[model symbol backdrop rarity id original_details],
|
|
35
|
-
MediaAreaType: %w[venue location suggested_reaction link weather],
|
|
36
|
-
PrivacyRuleType: %w[allow_all allow_contacts allow_users allow_chats allow_close_friends allow_premium disallow_all disallow_contacts disallow_users disallow_chats disallow_bots],
|
|
37
|
-
GiftForResaleOrder: %w[newest oldest price_asc price_desc rarity_asc rarity_desc],
|
|
38
|
-
GiftPurchaseOfferState: %w[pending accepted rejected expired canceled],
|
|
39
|
-
GiftType: %w[regular upgraded unique collectible],
|
|
40
|
-
PaymentFormType: %w[invoice stars ton gift_upgrade],
|
|
41
|
-
StickerType: %w[regular mask custom_emoji],
|
|
42
|
-
MaskPointType: %w[forehead eyes mouth chin],
|
|
43
|
-
SuggestedPostRefundReason: %w[not_published rejected timeout canceled],
|
|
44
|
-
SuggestedPostState: %w[pending approved declined paid refunded failed]
|
|
45
|
-
}.freeze
|
|
46
|
-
|
|
47
|
-
DEFINITIONS.each do |enum_name, values|
|
|
48
|
-
enum_module = Module.new
|
|
49
|
-
values.each do |value|
|
|
50
|
-
const_name = value.upcase.gsub(/[^A-Z0-9]+/, "_")
|
|
51
|
-
enum_module.const_set(const_name, value)
|
|
52
|
-
end
|
|
53
|
-
const_set(enum_name, enum_module)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
UPDATE_GROUP_CALL_PARTICIPANTS = "updateGroupCallParticipants"
|
|
59
|
-
UPDATE_GROUP_CALL_SIGNALING_DATA = "updateGroupCallSignalingData"
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
1
|
+
module GrubY
|
|
2
|
+
module Enums
|
|
3
|
+
DEFINITIONS = {
|
|
4
|
+
BlockList: %w[main stories],
|
|
5
|
+
BusinessSchedule: %w[always offline custom],
|
|
6
|
+
ButtonStyle: %w[default primary danger success],
|
|
7
|
+
ChatAction: %w[typing upload_photo record_video upload_video record_voice upload_voice upload_document choose_sticker find_location record_video_note upload_video_note],
|
|
8
|
+
ChatEventAction: %w[create edit delete pin unpin join leave invite restrict promote],
|
|
9
|
+
ChatJoinType: %w[by_link by_request by_invite by_username],
|
|
10
|
+
ChatMemberStatus: %w[creator administrator member restricted left kicked],
|
|
11
|
+
ChatMembersFilter: %w[recent administrators contacts bots banned restricted search],
|
|
12
|
+
ChatType: %w[private bot group supergroup channel direct forum],
|
|
13
|
+
ClientPlatform: %w[ruby linux windows macos android ios web],
|
|
14
|
+
FolderColor: %w[blue cyan green orange pink purple red yellow],
|
|
15
|
+
MessageEntityType: %w[mention hashtag cashtag bot_command url email phone_number bold italic underline strikethrough spoiler code pre text_link text_mention custom_emoji bank_card_number ton_address],
|
|
16
|
+
MessageMediaType: %w[text photo video animation audio voice video_note document sticker contact location venue poll dice game story paid_media],
|
|
17
|
+
MessageOriginType: %w[user hidden_user chat channel],
|
|
18
|
+
MessageServiceType: %w[new_chat_members left_chat_member new_chat_title new_chat_photo delete_chat_photo group_chat_created supergroup_chat_created channel_chat_created migrate_to_chat_id migrate_from_chat_id pinned_message game_score video_chat_started video_chat_ended video_chat_members_invited successful_payment],
|
|
19
|
+
MessagesFilter: %w[empty photo video document url gif voice chat_photo phone_call round_video video_note voice_note photo_video mention unread mention_me pinned],
|
|
20
|
+
NextCodeType: %w[sms call flash_call missed_call fragment app],
|
|
21
|
+
PaidReactionPrivacy: %w[anonymous default sender],
|
|
22
|
+
ParseMode: %w[markdown markdown_v2 html],
|
|
23
|
+
PhoneCallDiscardReason: %w[missed disconnect hangup busy],
|
|
24
|
+
PhoneNumberCodeType: %w[sms call flash_call missed_call fragment app],
|
|
25
|
+
PollType: %w[regular quiz],
|
|
26
|
+
PrivacyKey: %w[last_seen phone_number profile_photo forwards calls p2p_invite link_in_bio birthday gifts voice_messages about],
|
|
27
|
+
ProfileColor: %w[blue cyan green orange pink purple red yellow],
|
|
28
|
+
ProfileTab: %w[profile gifts media links files voice],
|
|
29
|
+
ReplyColor: %w[blue cyan green orange pink purple red yellow],
|
|
30
|
+
SentCodeType: %w[sms call flash_call missed_call fragment app firebase email],
|
|
31
|
+
StoriesPrivacyRules: %w[everyone contacts close_friends selected],
|
|
32
|
+
UserStatus: %w[online offline recently last_week last_month long_time_ago],
|
|
33
|
+
UpgradedGiftOrigin: %w[upgrade gift_code transfer craft purchase],
|
|
34
|
+
GiftAttributeType: %w[model symbol backdrop rarity id original_details],
|
|
35
|
+
MediaAreaType: %w[venue location suggested_reaction link weather],
|
|
36
|
+
PrivacyRuleType: %w[allow_all allow_contacts allow_users allow_chats allow_close_friends allow_premium disallow_all disallow_contacts disallow_users disallow_chats disallow_bots],
|
|
37
|
+
GiftForResaleOrder: %w[newest oldest price_asc price_desc rarity_asc rarity_desc],
|
|
38
|
+
GiftPurchaseOfferState: %w[pending accepted rejected expired canceled],
|
|
39
|
+
GiftType: %w[regular upgraded unique collectible],
|
|
40
|
+
PaymentFormType: %w[invoice stars ton gift_upgrade],
|
|
41
|
+
StickerType: %w[regular mask custom_emoji],
|
|
42
|
+
MaskPointType: %w[forehead eyes mouth chin],
|
|
43
|
+
SuggestedPostRefundReason: %w[not_published rejected timeout canceled],
|
|
44
|
+
SuggestedPostState: %w[pending approved declined paid refunded failed]
|
|
45
|
+
}.freeze
|
|
46
|
+
|
|
47
|
+
DEFINITIONS.each do |enum_name, values|
|
|
48
|
+
enum_module = Module.new
|
|
49
|
+
values.each do |value|
|
|
50
|
+
const_name = value.upcase.gsub(/[^A-Z0-9]+/, "_")
|
|
51
|
+
enum_module.const_set(const_name, value)
|
|
52
|
+
end
|
|
53
|
+
const_set(enum_name, enum_module)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
end
|
data/lib/gruubY/exception.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
module GrubY
|
|
2
|
-
class Error < StandardError; end
|
|
3
|
-
class ConfigurationError < Error; end
|
|
4
|
-
class DependencyError < Error; end
|
|
5
|
-
end
|
|
1
|
+
module GrubY
|
|
2
|
+
class Error < StandardError; end
|
|
3
|
+
class ConfigurationError < Error; end
|
|
4
|
+
class DependencyError < Error; end
|
|
5
|
+
end
|
data/lib/gruubY/file_stream.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
require "net/http"
|
|
2
|
-
|
|
3
|
-
module GrubY
|
|
4
|
-
class FileStream
|
|
5
|
-
def self.download(url, dest)
|
|
6
|
-
uri = URI(url)
|
|
7
|
-
|
|
8
|
-
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
9
|
-
http.request_get(uri) do |res|
|
|
10
|
-
File.open(dest, "wb") do |f|
|
|
11
|
-
res.read_body { |chunk| f.write(chunk) }
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
1
|
+
require "net/http"
|
|
2
|
+
|
|
3
|
+
module GrubY
|
|
4
|
+
class FileStream
|
|
5
|
+
def self.download(url, dest)
|
|
6
|
+
uri = URI(url)
|
|
7
|
+
|
|
8
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
9
|
+
http.request_get(uri) do |res|
|
|
10
|
+
File.open(dest, "wb") do |f|
|
|
11
|
+
res.read_body { |chunk| f.write(chunk) }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|