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
|
@@ -1,67 +1,86 @@
|
|
|
1
|
-
require_relative "base_object"
|
|
2
|
-
|
|
3
|
-
module GrubY
|
|
4
|
-
module TypeRegistry
|
|
5
|
-
TYPE_NAMES = %w[
|
|
6
|
-
AcceptedGiftTypes Birthday BusinessConnection BusinessIntro BusinessRecipients BusinessWeeklyOpen BusinessWorkingHours
|
|
7
|
-
Username VerificationStatus ChatPhoto ChatMember ChatPermissions ChatAdministratorRights ChatInviteLink ChatAdminWithInviteLinks
|
|
8
|
-
ChatEvent ChatEventFilter ChatMemberUpdated ChatJoiner Dialog Restriction EmojiStatus FailedToAddMember Folder GroupCallMember
|
|
9
|
-
ChatColor FoundContacts PrivacyRule StoriesStealthMode UserRating BotVerification BusinessBotRights ChatSettings
|
|
10
|
-
GlobalPrivacySettings HistoryCleared BusinessMessage MessageOriginChannel MessageOriginChat MessageOriginHiddenUser
|
|
11
|
-
MessageOriginImport MessageOriginUser MessageOrigin Photo PollOptionAdded PollOptionDeleted Thumbnail StrippedThumbnail
|
|
12
|
-
AvailableEffect ExternalReplyInfo FactCheck FormattedText ForumTopic ForumTopicClosed ForumTopicCreated ForumTopicEdited
|
|
13
|
-
ForumTopicReopened GeneralForumTopicHidden GeneralForumTopicUnhidden Contact CraftGiftResult CraftGiftResultSuccess
|
|
14
|
-
CraftGiftResultFail Location ManagedBotCreated MaskPosition MediaArea Venue Sticker Game WebPage ProximityAlertTriggered
|
|
15
|
-
PollOption Dice Reaction RestrictionReason Gift VideoChatScheduled VideoChatStarted VideoChatEnded VideoChatMembersInvited
|
|
16
|
-
PhoneCallStarted PhoneCallEnded WebAppData MessageReactions ChatReactions MyBoost BoostsStatus Giveaway InputChecklistTask
|
|
17
|
-
GiveawayCreated GiveawayPrizeStars GiveawayCompleted GiveawayWinners Invoice LinkPreviewOptions GiftCollection PremiumGiftCode
|
|
18
|
-
GiftPurchaseLimit GiftResaleParameters GiftResalePrice GiftResalePriceStar GiftResalePriceTon GiftUpgradePreview
|
|
19
|
-
GiftUpgradePrice GiftUpgradeVariants CheckedGiftCode ChecklistTask ChecklistTasksAdded ChecklistTasksDone Checklist
|
|
20
|
-
RefundedPayment ReplyParameters SuccessfulPayment SuggestedPostParameters SuggestedPostInfo SuggestedPostPaid
|
|
21
|
-
SuggestedPostPrice SuggestedPostPriceStar SuggestedPostPriceTon SuggestedPostApprovalFailed SuggestedPostApproved
|
|
22
|
-
SuggestedPostDeclined SuggestedPostRefunded TextQuote PaidMediaInfo PaidMediaPreview PaidMessagesRefunded PaidReactor
|
|
23
|
-
PaidMessagesPriceChanged DirectMessagePriceChanged DirectMessagesTopic PaymentForm PaymentOption SavedCredentials PaymentResult
|
|
24
|
-
ChatBoost ChatOwnerChanged ChatOwnerLeft ChatHasProtectedContentToggled ChatHasProtectedContentDisableRequested
|
|
25
|
-
ContactRegistered ScreenshotTaken StarAmount WriteAccessAllowed GiftAttribute StoryView GiftedPremium ChatBackground ChatTheme
|
|
26
|
-
GiftedStars GiftedTon UpgradedGiftValueInfo UpgradedGiftAttributeId UpgradedGiftPurchaseOffer UpgradedGiftPurchaseOfferRejected
|
|
27
|
-
UpgradedGiftAttributeIdModel UpgradedGiftAttributeIdSymbol UpgradedGiftAttributeIdBackdrop UpgradedGiftAttributeRarity
|
|
28
|
-
UpgradedGiftAttributeRarityPerMille UpgradedGiftAttributeRarityUncommon UpgradedGiftAttributeRarityRare
|
|
29
|
-
UpgradedGiftAttributeRarityEpic UpgradedGiftAttributeRarityLegendary UpgradedGiftOriginalDetails InputChatPhoto
|
|
30
|
-
InputChatPhotoPrevious InputChatPhotoStatic InputChatPhotoAnimation AuctionBid AuctionRound AuctionState AuctionStateActive
|
|
31
|
-
AuctionStateFinished GiftAuctionState GiftAuction ReplyKeyboardMarkup KeyboardButton ReplyKeyboardRemove
|
|
32
|
-
InlineKeyboardMarkup InlineKeyboardButton LoginUrl ForceReply GameHighScore CallbackGame WebAppInfo MenuButton
|
|
33
|
-
MenuButtonCommands MenuButtonWebApp MenuButtonDefault SentWebAppMessage KeyboardButtonRequestChat
|
|
34
|
-
KeyboardButtonRequestManagedBot KeyboardButtonRequestUsers KeyboardButtonPollType ManagedBotUpdated OrderInfo
|
|
35
|
-
MessageReactionUpdated MessageReactionCountUpdated ChatBoostUpdated ShippingOption PurchasedPaidMedia ChatShared UsersShared
|
|
36
|
-
BotCommand BotCommandScope BotCommandScopeDefault BotCommandScopeAllPrivateChats BotCommandScopeAllGroupChats
|
|
37
|
-
BotCommandScopeAllChatAdministrators BotCommandScopeChat BotCommandScopeChatAdministrators BotCommandScopeChatMember
|
|
38
|
-
InlineQueryResult InlineQueryResultCachedAudio InlineQueryResultCachedDocument InlineQueryResultCachedAnimation
|
|
39
|
-
InlineQueryResultCachedPhoto InlineQueryResultCachedSticker InlineQueryResultCachedVideo InlineQueryResultCachedVoice
|
|
40
|
-
InlineQueryResultArticle InlineQueryResultAudio InlineQueryResultContact InlineQueryResultDocument InlineQueryResultAnimation
|
|
41
|
-
InlineQueryResultLocation InlineQueryResultPhoto InlineQueryResultVenue InlineQueryResultVideo InlineQueryResultVoice
|
|
42
|
-
ChosenInlineResult ActiveSessions FirebaseAuthenticationSettings FirebaseAuthenticationSettingsAndroid
|
|
43
|
-
FirebaseAuthenticationSettingsIos PhoneNumberAuthenticationSettings SentCode TermsOfService InputChecklist
|
|
44
|
-
InputContactMessageContent InputCredentials InputCredentialsApplePay InputCredentialsGooglePay InputCredentialsNew
|
|
45
|
-
InputCredentialsSaved InputInvoice InputInvoiceMessage InputInvoiceMessageContent InputInvoiceName
|
|
46
|
-
InputLocationMessageContent InputMedia InputMediaAnimation InputMediaAudio InputMediaDocument InputMediaPhoto
|
|
47
|
-
InputMediaVideo InputMessageContent InputPhoneContact InputPollOption InputPrivacyRule InputPrivacyRuleAllowAll
|
|
48
|
-
InputPrivacyRuleAllowBots InputPrivacyRuleAllowChats InputPrivacyRuleAllowCloseFriends InputPrivacyRuleAllowContacts
|
|
49
|
-
InputPrivacyRuleAllowPremium InputPrivacyRuleAllowUsers InputPrivacyRuleDisallowAll InputPrivacyRuleDisallowBots
|
|
50
|
-
InputPrivacyRuleDisallowChats InputPrivacyRuleDisallowContacts InputPrivacyRuleDisallowUsers InputTextMessageContent
|
|
51
|
-
InputVenueMessageContent
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
1
|
+
require_relative "base_object"
|
|
2
|
+
|
|
3
|
+
module GrubY
|
|
4
|
+
module TypeRegistry
|
|
5
|
+
TYPE_NAMES = %w[
|
|
6
|
+
Update AcceptedGiftTypes Birthday BusinessConnection BusinessIntro BusinessRecipients BusinessWeeklyOpen BusinessWorkingHours
|
|
7
|
+
Username VerificationStatus ChatPhoto ChatMember ChatPermissions ChatAdministratorRights ChatInviteLink ChatAdminWithInviteLinks
|
|
8
|
+
ChatEvent ChatEventFilter ChatMemberUpdated ChatJoiner Dialog Restriction EmojiStatus FailedToAddMember Folder GroupCallMember
|
|
9
|
+
ChatColor FoundContacts PrivacyRule StoriesStealthMode UserRating BotVerification BusinessBotRights ChatSettings
|
|
10
|
+
GlobalPrivacySettings HistoryCleared BusinessMessage MessageOriginChannel MessageOriginChat MessageOriginHiddenUser
|
|
11
|
+
MessageOriginImport MessageOriginUser MessageOrigin Photo PollOptionAdded PollOptionDeleted Thumbnail StrippedThumbnail
|
|
12
|
+
AvailableEffect ExternalReplyInfo FactCheck FormattedText ForumTopic ForumTopicClosed ForumTopicCreated ForumTopicEdited
|
|
13
|
+
ForumTopicReopened GeneralForumTopicHidden GeneralForumTopicUnhidden Contact CraftGiftResult CraftGiftResultSuccess
|
|
14
|
+
CraftGiftResultFail Location ManagedBotCreated MaskPosition MediaArea Venue Sticker Game WebPage ProximityAlertTriggered
|
|
15
|
+
PollOption Dice Reaction RestrictionReason Gift VideoChatScheduled VideoChatStarted VideoChatEnded VideoChatMembersInvited
|
|
16
|
+
PhoneCallStarted PhoneCallEnded WebAppData MessageReactions ChatReactions MyBoost BoostsStatus Giveaway InputChecklistTask
|
|
17
|
+
GiveawayCreated GiveawayPrizeStars GiveawayCompleted GiveawayWinners Invoice LinkPreviewOptions GiftCollection PremiumGiftCode
|
|
18
|
+
GiftPurchaseLimit GiftResaleParameters GiftResalePrice GiftResalePriceStar GiftResalePriceTon GiftUpgradePreview
|
|
19
|
+
GiftUpgradePrice GiftUpgradeVariants CheckedGiftCode ChecklistTask ChecklistTasksAdded ChecklistTasksDone Checklist
|
|
20
|
+
RefundedPayment ReplyParameters SuccessfulPayment SuggestedPostParameters SuggestedPostInfo SuggestedPostPaid
|
|
21
|
+
SuggestedPostPrice SuggestedPostPriceStar SuggestedPostPriceTon SuggestedPostApprovalFailed SuggestedPostApproved
|
|
22
|
+
SuggestedPostDeclined SuggestedPostRefunded TextQuote PaidMediaInfo PaidMediaPreview PaidMessagesRefunded PaidReactor
|
|
23
|
+
PaidMessagesPriceChanged DirectMessagePriceChanged DirectMessagesTopic PaymentForm PaymentOption SavedCredentials PaymentResult
|
|
24
|
+
ChatBoost ChatOwnerChanged ChatOwnerLeft ChatHasProtectedContentToggled ChatHasProtectedContentDisableRequested
|
|
25
|
+
ContactRegistered ScreenshotTaken StarAmount WriteAccessAllowed GiftAttribute StoryView GiftedPremium ChatBackground ChatTheme
|
|
26
|
+
GiftedStars GiftedTon UpgradedGiftValueInfo UpgradedGiftAttributeId UpgradedGiftPurchaseOffer UpgradedGiftPurchaseOfferRejected
|
|
27
|
+
UpgradedGiftAttributeIdModel UpgradedGiftAttributeIdSymbol UpgradedGiftAttributeIdBackdrop UpgradedGiftAttributeRarity
|
|
28
|
+
UpgradedGiftAttributeRarityPerMille UpgradedGiftAttributeRarityUncommon UpgradedGiftAttributeRarityRare
|
|
29
|
+
UpgradedGiftAttributeRarityEpic UpgradedGiftAttributeRarityLegendary UpgradedGiftOriginalDetails InputChatPhoto
|
|
30
|
+
InputChatPhotoPrevious InputChatPhotoStatic InputChatPhotoAnimation AuctionBid AuctionRound AuctionState AuctionStateActive
|
|
31
|
+
AuctionStateFinished GiftAuctionState GiftAuction ReplyKeyboardMarkup KeyboardButton ReplyKeyboardRemove
|
|
32
|
+
InlineKeyboardMarkup InlineKeyboardButton LoginUrl ForceReply GameHighScore CallbackGame WebAppInfo MenuButton
|
|
33
|
+
MenuButtonCommands MenuButtonWebApp MenuButtonDefault SentWebAppMessage KeyboardButtonRequestChat
|
|
34
|
+
KeyboardButtonRequestManagedBot KeyboardButtonRequestUsers KeyboardButtonPollType ManagedBotUpdated OrderInfo
|
|
35
|
+
MessageReactionUpdated MessageReactionCountUpdated ChatBoostUpdated ShippingOption PurchasedPaidMedia ChatShared UsersShared
|
|
36
|
+
BotCommand BotCommandScope BotCommandScopeDefault BotCommandScopeAllPrivateChats BotCommandScopeAllGroupChats
|
|
37
|
+
BotCommandScopeAllChatAdministrators BotCommandScopeChat BotCommandScopeChatAdministrators BotCommandScopeChatMember
|
|
38
|
+
InlineQueryResult InlineQueryResultCachedAudio InlineQueryResultCachedDocument InlineQueryResultCachedAnimation
|
|
39
|
+
InlineQueryResultCachedPhoto InlineQueryResultCachedSticker InlineQueryResultCachedVideo InlineQueryResultCachedVoice
|
|
40
|
+
InlineQueryResultArticle InlineQueryResultAudio InlineQueryResultContact InlineQueryResultDocument InlineQueryResultAnimation
|
|
41
|
+
InlineQueryResultLocation InlineQueryResultPhoto InlineQueryResultVenue InlineQueryResultVideo InlineQueryResultVoice
|
|
42
|
+
ChosenInlineResult ActiveSessions FirebaseAuthenticationSettings FirebaseAuthenticationSettingsAndroid
|
|
43
|
+
FirebaseAuthenticationSettingsIos PhoneNumberAuthenticationSettings SentCode TermsOfService InputChecklist
|
|
44
|
+
InputContactMessageContent InputCredentials InputCredentialsApplePay InputCredentialsGooglePay InputCredentialsNew
|
|
45
|
+
InputCredentialsSaved InputInvoice InputInvoiceMessage InputInvoiceMessageContent InputInvoiceName
|
|
46
|
+
InputLocationMessageContent InputMedia InputMediaAnimation InputMediaAudio InputMediaDocument InputMediaPhoto
|
|
47
|
+
InputMediaVideo InputMessageContent InputPhoneContact InputPollOption InputPrivacyRule InputPrivacyRuleAllowAll
|
|
48
|
+
InputPrivacyRuleAllowBots InputPrivacyRuleAllowChats InputPrivacyRuleAllowCloseFriends InputPrivacyRuleAllowContacts
|
|
49
|
+
InputPrivacyRuleAllowPremium InputPrivacyRuleAllowUsers InputPrivacyRuleDisallowAll InputPrivacyRuleDisallowBots
|
|
50
|
+
InputPrivacyRuleDisallowChats InputPrivacyRuleDisallowContacts InputPrivacyRuleDisallowUsers InputTextMessageContent
|
|
51
|
+
InputVenueMessageContent
|
|
52
|
+
BotFullInfo Sticker StickerSet MaskPosition InputSticker
|
|
53
|
+
ChatBoostRemoved PollAnswer Update WebhookInfo BotSubscriptionUpdated MessageGenerationStopped
|
|
54
|
+
Widget SharedWidget WidgetQuery SharedWidgetQuery
|
|
55
|
+
WidgetQueryType WidgetQueryTypeData WidgetQueryTypeSignData WidgetQueryTypeSentTransaction WidgetQueryWallet
|
|
56
|
+
EphemeralMessageParameters CommunityChatAdded CommunityChatJoined CommunityChatRemoved Community
|
|
57
|
+
ChatShareTheme ChatShareThemeEmoji ChatShareThemeUniqueGift
|
|
58
|
+
ChatShareThemeBackdrop ChatShareThemeBackdrops
|
|
59
|
+
RichText RichTextTonAddress TonAddress BankCardNumber PaidMessagesWaived TonWalletCard TonWalletCardSticker
|
|
60
|
+
TonNft TonNftAttribute TonWalletTransfer AreaPosition EmojiType EmojiTypeEmoji EmojiTypeCustomEmoji
|
|
61
|
+
RichMessage RichMessageButton RichTextButton RichBlockButtons RichBlockExpandableBlockQuotation
|
|
62
|
+
RichBlockDocument RichBlockTable InputRichMessageMedia InputMediaVoiceNote
|
|
63
|
+
InputRichMessageContent InputWidgetMessageContent InputSharedWidgetMessageContent
|
|
64
|
+
InputRichBlockListItem InputRichBlockParagraph InputRichBlockSectionHeading InputRichBlockPreformatted
|
|
65
|
+
InputRichBlockFooter InputRichBlockDivider InputRichBlockMathematicalExpression InputRichBlockAnchor
|
|
66
|
+
InputRichBlockList InputRichBlockBlockQuotation InputRichBlockPullQuotation InputRichBlockCollage
|
|
67
|
+
InputRichBlockSlideshow InputRichBlockTable InputRichBlockDetails InputRichBlockMap
|
|
68
|
+
InputRichBlockAnimation InputRichBlockAudio InputRichBlockPhoto InputRichBlockVideo
|
|
69
|
+
InputRichBlockVoiceNote InputRichBlockThinking
|
|
70
|
+
InputRichBlockButtons InputRichBlockExpandableBlockQuotation InputRichBlockDocument
|
|
71
|
+
].freeze
|
|
72
|
+
|
|
73
|
+
module_function
|
|
74
|
+
|
|
75
|
+
def install!
|
|
76
|
+
TYPE_NAMES.each do |type_name|
|
|
77
|
+
next if GrubY.const_defined?(type_name)
|
|
78
|
+
|
|
79
|
+
klass = Class.new(GrubY::BaseObject)
|
|
80
|
+
GrubY.const_set(type_name, klass)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
GrubY::TypeRegistry.install!
|
data/lib/gruubY/types/user.rb
CHANGED
|
@@ -1,31 +1,47 @@
|
|
|
1
|
-
require_relative "base_object"
|
|
2
|
-
|
|
3
|
-
module GrubY
|
|
4
|
-
class User < BaseObject
|
|
5
|
-
fields :id, :is_bot, :first_name, :last_name, :username, :language_code,
|
|
6
|
-
:is_premium, :added_to_attachment_menu, :can_join_groups,
|
|
7
|
-
:can_read_all_group_messages, :supports_inline_queries,
|
|
8
|
-
:
|
|
9
|
-
:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def
|
|
16
|
-
call_raw_api("
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def
|
|
20
|
-
call_raw_api("
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def
|
|
24
|
-
call_raw_api("
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def
|
|
28
|
-
call_raw_api("
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
require_relative "base_object"
|
|
2
|
+
|
|
3
|
+
module GrubY
|
|
4
|
+
class User < BaseObject
|
|
5
|
+
fields :id, :is_bot, :first_name, :last_name, :username, :language_code,
|
|
6
|
+
:is_premium, :added_to_attachment_menu, :can_join_groups,
|
|
7
|
+
:can_read_all_group_messages, :supports_inline_queries,
|
|
8
|
+
:supports_guest_queries, :supports_join_request_queries,
|
|
9
|
+
:inline_feedback_share_denominator,
|
|
10
|
+
:can_connect_to_business, :has_main_web_app, :has_topics_enabled,
|
|
11
|
+
:allows_users_to_create_topics, :can_manage_bots, :can_communicate_with_bots,
|
|
12
|
+
:active_usernames, :inline_query_placeholder,
|
|
13
|
+
:needs_inline_query_location, :has_topic_sidebar
|
|
14
|
+
|
|
15
|
+
def archive
|
|
16
|
+
call_raw_api("archiveChats", { chat_ids: [id] })
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def unarchive
|
|
20
|
+
call_raw_api("unarchiveChats", { chat_ids: [id] })
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def block
|
|
24
|
+
call_raw_api("blockUser", { user_id: id })
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def unblock
|
|
28
|
+
call_raw_api("unblockUser", { user_id: id })
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def get_common_chats(offset_chat_id: 0, limit: 100)
|
|
32
|
+
call_raw_api("getCommonChats", { user_id: id, offset_chat_id: offset_chat_id, limit: limit })
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class BotFullInfo < User
|
|
37
|
+
fields :id, :is_bot, :first_name, :last_name, :username, :language_code,
|
|
38
|
+
:is_premium, :added_to_attachment_menu, :can_join_groups,
|
|
39
|
+
:can_read_all_group_messages, :supports_inline_queries,
|
|
40
|
+
:supports_guest_queries, :supports_join_request_queries,
|
|
41
|
+
:inline_feedback_share_denominator,
|
|
42
|
+
:can_connect_to_business, :has_main_web_app, :has_topics_enabled,
|
|
43
|
+
:allows_users_to_create_topics, :can_manage_bots, :can_communicate_with_bots,
|
|
44
|
+
:active_usernames, :inline_query_placeholder,
|
|
45
|
+
:needs_inline_query_location, :has_topic_sidebar
|
|
46
|
+
end
|
|
47
|
+
end
|
data/lib/gruubY/webapp.rb
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
module GrubY
|
|
2
|
-
module WebApp
|
|
3
|
-
module_function
|
|
4
|
-
|
|
5
|
-
def info(url:)
|
|
6
|
-
{
|
|
7
|
-
web_app: {
|
|
8
|
-
url: url.to_s
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def inline_button(text:, url:)
|
|
14
|
-
{
|
|
15
|
-
text: text.to_s,
|
|
16
|
-
web_app: {
|
|
17
|
-
url: url.to_s
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
1
|
+
module GrubY
|
|
2
|
+
module WebApp
|
|
3
|
+
module_function
|
|
4
|
+
|
|
5
|
+
def info(url:)
|
|
6
|
+
{
|
|
7
|
+
web_app: {
|
|
8
|
+
url: url.to_s
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def inline_button(text:, url:)
|
|
14
|
+
{
|
|
15
|
+
text: text.to_s,
|
|
16
|
+
web_app: {
|
|
17
|
+
url: url.to_s
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/gruubY.rb
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
require_relative "gruubY/async"
|
|
2
|
-
require_relative "gruubY/api"
|
|
3
|
-
require_relative "gruubY/bot"
|
|
4
|
-
require_relative "gruubY/bound"
|
|
5
|
-
require_relative "gruubY/context"
|
|
6
|
-
require_relative "gruubY/client"
|
|
7
|
-
require_relative "gruubY/dispatcher"
|
|
8
|
-
require_relative "gruubY/enums"
|
|
9
|
-
require_relative "gruubY/file_stream"
|
|
10
|
-
require_relative "gruubY/filters"
|
|
11
|
-
require_relative "gruubY/handlers"
|
|
12
|
-
require_relative "gruubY/group_manager"
|
|
13
|
-
require_relative "gruubY/keyboard"
|
|
14
|
-
require_relative "gruubY/media"
|
|
15
|
-
require_relative "gruubY/middleware"
|
|
16
|
-
require_relative "gruubY/
|
|
17
|
-
require_relative "gruubY/
|
|
18
|
-
require_relative "gruubY/
|
|
19
|
-
require_relative "gruubY/
|
|
20
|
-
require_relative "gruubY/
|
|
21
|
-
require_relative "gruubY/
|
|
22
|
-
require_relative "gruubY/
|
|
23
|
-
require_relative "gruubY/
|
|
24
|
-
require_relative "gruubY/types/
|
|
25
|
-
require_relative "gruubY/types/
|
|
26
|
-
require_relative "gruubY/types/
|
|
27
|
-
require_relative "gruubY/types/
|
|
28
|
-
require_relative "gruubY/types/
|
|
29
|
-
require_relative "gruubY/types/
|
|
30
|
-
require_relative "gruubY/types/
|
|
31
|
-
require_relative "gruubY/
|
|
32
|
-
require_relative "gruubY/
|
|
33
|
-
require_relative "gruubY/tdlib/
|
|
34
|
-
require_relative "gruubY/tdlib/
|
|
35
|
-
require_relative "gruubY/tdlib/
|
|
36
|
-
require_relative "gruubY/tdlib/
|
|
37
|
-
require_relative "gruubY/tdlib/
|
|
38
|
-
require_relative "gruubY/tdlib/
|
|
39
|
-
require_relative "gruubY/tdlib/
|
|
40
|
-
require_relative "gruubY/tdlib/group_manager"
|
|
41
|
-
require_relative "gruubY/tdlib/user_session"
|
|
1
|
+
require_relative "gruubY/async"
|
|
2
|
+
require_relative "gruubY/api"
|
|
3
|
+
require_relative "gruubY/bot"
|
|
4
|
+
require_relative "gruubY/bound"
|
|
5
|
+
require_relative "gruubY/context"
|
|
6
|
+
require_relative "gruubY/client"
|
|
7
|
+
require_relative "gruubY/dispatcher"
|
|
8
|
+
require_relative "gruubY/enums"
|
|
9
|
+
require_relative "gruubY/file_stream"
|
|
10
|
+
require_relative "gruubY/filters"
|
|
11
|
+
require_relative "gruubY/handlers"
|
|
12
|
+
require_relative "gruubY/group_manager"
|
|
13
|
+
require_relative "gruubY/keyboard"
|
|
14
|
+
require_relative "gruubY/media"
|
|
15
|
+
require_relative "gruubY/middleware"
|
|
16
|
+
require_relative "gruubY/plugin"
|
|
17
|
+
require_relative "gruubY/raw"
|
|
18
|
+
require_relative "gruubY/retry"
|
|
19
|
+
require_relative "gruubY/server"
|
|
20
|
+
require_relative "gruubY/session"
|
|
21
|
+
require_relative "gruubY/webapp"
|
|
22
|
+
require_relative "gruubY/types/base_object"
|
|
23
|
+
require_relative "gruubY/types/user"
|
|
24
|
+
require_relative "gruubY/types/chat"
|
|
25
|
+
require_relative "gruubY/types/bound_entities"
|
|
26
|
+
require_relative "gruubY/types/chat_info"
|
|
27
|
+
require_relative "gruubY/types/message_entity"
|
|
28
|
+
require_relative "gruubY/types/extra"
|
|
29
|
+
require_relative "gruubY/types/message"
|
|
30
|
+
require_relative "gruubY/types/registry"
|
|
31
|
+
require_relative "gruubY/tdlib/native"
|
|
32
|
+
require_relative "gruubY/tdlib/errors"
|
|
33
|
+
require_relative "gruubY/tdlib/decorators"
|
|
34
|
+
require_relative "gruubY/tdlib/tdjson"
|
|
35
|
+
require_relative "gruubY/tdlib/schema_builder"
|
|
36
|
+
require_relative "gruubY/tdlib/client_manager"
|
|
37
|
+
require_relative "gruubY/tdlib/client"
|
|
38
|
+
require_relative "gruubY/tdlib/group_manager"
|
|
39
|
+
require_relative "gruubY/tdlib/user_session"
|
data/plugins/logger.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
def self.register(bot)
|
|
2
|
-
bot.use do |ctx, nxt|
|
|
3
|
-
username = ctx.user&.username || ctx.user&.first_name || "unknown"
|
|
4
|
-
puts "[LOG] #{username}: #{ctx.update}"
|
|
5
|
-
nxt.call
|
|
6
|
-
end
|
|
7
|
-
end
|
|
1
|
+
def self.register(bot)
|
|
2
|
+
bot.use do |ctx, nxt|
|
|
3
|
+
username = ctx.user&.username || ctx.user&.first_name || "unknown"
|
|
4
|
+
puts "[LOG] #{username}: #{ctx.update}"
|
|
5
|
+
nxt.call
|
|
6
|
+
end
|
|
7
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gruubY
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sreyanshu
|
|
@@ -23,8 +23,7 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
|
-
description: Telegram
|
|
27
|
-
bindings.
|
|
26
|
+
description: Telegram Bot API and TDLib toolkit for Ruby.
|
|
28
27
|
executables: []
|
|
29
28
|
extensions: []
|
|
30
29
|
extra_rdoc_files: []
|
|
@@ -35,7 +34,6 @@ files:
|
|
|
35
34
|
- config/config.rb
|
|
36
35
|
- example/bot.rb
|
|
37
36
|
- example/generate_user_session.rb
|
|
38
|
-
- example/ntgcalls.rb
|
|
39
37
|
- example/tdlib.rb
|
|
40
38
|
- example/userbot.rb
|
|
41
39
|
- lib/gruubY.rb
|
|
@@ -55,11 +53,8 @@ files:
|
|
|
55
53
|
- lib/gruubY/keyboard.rb
|
|
56
54
|
- lib/gruubY/media.rb
|
|
57
55
|
- lib/gruubY/middleware.rb
|
|
58
|
-
- lib/gruubY/ntgcalls.rb
|
|
59
|
-
- lib/gruubY/ntgcalls/native.rb
|
|
60
56
|
- lib/gruubY/plugin.rb
|
|
61
57
|
- lib/gruubY/raw.rb
|
|
62
|
-
- lib/gruubY/raw_types.rb
|
|
63
58
|
- lib/gruubY/retry.rb
|
|
64
59
|
- lib/gruubY/server.rb
|
|
65
60
|
- lib/gruubY/session.rb
|
|
@@ -83,7 +78,6 @@ files:
|
|
|
83
78
|
- lib/gruubY/types/user.rb
|
|
84
79
|
- lib/gruubY/webapp.rb
|
|
85
80
|
- plugins/logger.rb
|
|
86
|
-
- plugins/media_tools.rb
|
|
87
81
|
homepage: https://github.com/iSreyanshu/gruubY
|
|
88
82
|
licenses:
|
|
89
83
|
- MIT
|
|
@@ -104,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
104
98
|
- !ruby/object:Gem::Version
|
|
105
99
|
version: '0'
|
|
106
100
|
requirements: []
|
|
107
|
-
rubygems_version:
|
|
101
|
+
rubygems_version: 3.6.9
|
|
108
102
|
specification_version: 4
|
|
109
103
|
summary: A Ruby wrapper for Telegram BotAPI and TDLib
|
|
110
104
|
test_files: []
|
data/example/ntgcalls.rb
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
require_relative "../lib/gruubY"
|
|
2
|
-
require "json"
|
|
3
|
-
|
|
4
|
-
# Usage:
|
|
5
|
-
# TD_USER_SESSION='<base64>' \
|
|
6
|
-
# VC_CHAT='@YourGroupOrChannel' \
|
|
7
|
-
# VC_AUDIO=./song.mp3 \
|
|
8
|
-
# ruby example/ntgcalls.rb
|
|
9
|
-
#
|
|
10
|
-
# Optional:
|
|
11
|
-
# TDJSON_PATH=/path/to/libtdjson.so
|
|
12
|
-
# NTGCALLS_PATH=/path/to/libntgcalls.so
|
|
13
|
-
# VC_INVITE_HASH=xxxx
|
|
14
|
-
|
|
15
|
-
td_user_session = ENV["TD_USER_SESSION"].to_s
|
|
16
|
-
chat = ENV["VC_CHAT"].to_s
|
|
17
|
-
audio = ENV["VC_AUDIO"].to_s
|
|
18
|
-
|
|
19
|
-
abort("Missing TD_USER_SESSION") if td_user_session.empty?
|
|
20
|
-
abort("Missing VC_CHAT (chat ID or @username)") if chat.empty?
|
|
21
|
-
abort("Missing VC_AUDIO") if audio.empty?
|
|
22
|
-
|
|
23
|
-
bot = GrubY::NTgCalls::MusicBot.new(
|
|
24
|
-
td_user_session: td_user_session,
|
|
25
|
-
tdjson_path: ENV["TDJSON_PATH"],
|
|
26
|
-
ntgcalls_path: ENV["NTGCALLS_PATH"],
|
|
27
|
-
phone_number: ENV["TD_PHONE"]
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
begin
|
|
31
|
-
bot.start
|
|
32
|
-
result = bot.join_and_play(
|
|
33
|
-
chat: chat,
|
|
34
|
-
audio: audio,
|
|
35
|
-
invite_hash: ENV.fetch("VC_INVITE_HASH", "")
|
|
36
|
-
)
|
|
37
|
-
puts "[NTgCalls] Joined chat #{result[:chat_id]} and started playback"
|
|
38
|
-
puts "[NTgCalls] offer payload size=#{result[:offer].to_s.bytesize}"
|
|
39
|
-
|
|
40
|
-
puts "Commands: pause, resume, mute, unmute, time, cpu, stop, showraw, quit"
|
|
41
|
-
loop do
|
|
42
|
-
print "> "
|
|
43
|
-
cmd = STDIN.gets.to_s.strip.downcase
|
|
44
|
-
|
|
45
|
-
case cmd
|
|
46
|
-
when "pause"
|
|
47
|
-
bot.pause
|
|
48
|
-
puts "paused"
|
|
49
|
-
when "resume"
|
|
50
|
-
bot.resume
|
|
51
|
-
puts "resumed"
|
|
52
|
-
when "mute"
|
|
53
|
-
bot.mute
|
|
54
|
-
puts "muted"
|
|
55
|
-
when "unmute"
|
|
56
|
-
bot.unmute
|
|
57
|
-
puts "unmuted"
|
|
58
|
-
when "time"
|
|
59
|
-
puts bot.time
|
|
60
|
-
when "cpu"
|
|
61
|
-
puts bot.cpu_usage
|
|
62
|
-
when "stop"
|
|
63
|
-
bot.stop_call
|
|
64
|
-
puts "stopped"
|
|
65
|
-
when "showraw"
|
|
66
|
-
igc = bot.input_group_call(chat: chat)
|
|
67
|
-
puts "InputGroupCall: #{igc.to_json}"
|
|
68
|
-
puts "InputPeerSelf: #{bot.input_peer_self.to_json}"
|
|
69
|
-
puts "DataJSON: #{bot.data_json(result[:offer]).to_json}"
|
|
70
|
-
puts "JoinGroupCall: #{GrubY::RawTypes.join_group_call(call: igc, params: bot.data_json(result[:offer])).to_json}"
|
|
71
|
-
puts "LeaveGroupCall: #{GrubY::RawTypes.leave_group_call(call: igc, source: 0).to_json}"
|
|
72
|
-
when "quit", "exit"
|
|
73
|
-
break
|
|
74
|
-
else
|
|
75
|
-
puts "Unknown command!"
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
ensure
|
|
79
|
-
bot.stop
|
|
80
|
-
end
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
require "ffi"
|
|
2
|
-
|
|
3
|
-
module GrubY
|
|
4
|
-
module NTgCalls
|
|
5
|
-
module Native
|
|
6
|
-
extend FFI::Library
|
|
7
|
-
|
|
8
|
-
class LibraryNotFoundError < StandardError; end
|
|
9
|
-
|
|
10
|
-
callback :ntg_async_callback, [:pointer], :void
|
|
11
|
-
|
|
12
|
-
class NtgAsyncStruct < FFI::Struct
|
|
13
|
-
layout :userData, :pointer,
|
|
14
|
-
:errorCode, :pointer,
|
|
15
|
-
:errorMessage, :pointer,
|
|
16
|
-
:promise, :ntg_async_callback
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
class NtgAudioDescriptionStruct < FFI::Struct
|
|
20
|
-
layout :mediaSource, :int,
|
|
21
|
-
:input, :string,
|
|
22
|
-
:sampleRate, :uint32,
|
|
23
|
-
:channelCount, :uint8,
|
|
24
|
-
:keepOpen, :bool
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
class NtgMediaDescriptionStruct < FFI::Struct
|
|
28
|
-
layout :microphone, :pointer,
|
|
29
|
-
:speaker, :pointer,
|
|
30
|
-
:camera, :pointer,
|
|
31
|
-
:screen, :pointer
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
class << self
|
|
35
|
-
def load!(path = nil)
|
|
36
|
-
return if @loaded
|
|
37
|
-
|
|
38
|
-
ffi_lib(resolve_library_path(path))
|
|
39
|
-
attach_function :ntg_init, [], :uintptr_t
|
|
40
|
-
attach_function :ntg_destroy, [:uintptr_t], :int
|
|
41
|
-
attach_function :ntg_get_version, [:pointer], :int
|
|
42
|
-
attach_function :ntg_create, [:uintptr_t, :int64, :pointer, NtgAsyncStruct.by_value], :int
|
|
43
|
-
attach_function :ntg_connect, [:uintptr_t, :int64, :string, :bool, NtgAsyncStruct.by_value], :int
|
|
44
|
-
attach_function :ntg_set_stream_sources, [:uintptr_t, :int64, :int, NtgMediaDescriptionStruct.by_value, NtgAsyncStruct.by_value], :int
|
|
45
|
-
attach_function :ntg_pause, [:uintptr_t, :int64, NtgAsyncStruct.by_value], :int
|
|
46
|
-
attach_function :ntg_resume, [:uintptr_t, :int64, NtgAsyncStruct.by_value], :int
|
|
47
|
-
attach_function :ntg_mute, [:uintptr_t, :int64, NtgAsyncStruct.by_value], :int
|
|
48
|
-
attach_function :ntg_unmute, [:uintptr_t, :int64, NtgAsyncStruct.by_value], :int
|
|
49
|
-
attach_function :ntg_stop, [:uintptr_t, :int64, NtgAsyncStruct.by_value], :int
|
|
50
|
-
attach_function :ntg_time, [:uintptr_t, :int64, :int, :pointer, NtgAsyncStruct.by_value], :int
|
|
51
|
-
attach_function :ntg_cpu_usage, [:uintptr_t, :pointer, NtgAsyncStruct.by_value], :int
|
|
52
|
-
@loaded = true
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
private
|
|
56
|
-
|
|
57
|
-
def resolve_library_path(custom_path)
|
|
58
|
-
return custom_path if custom_path && File.exist?(custom_path)
|
|
59
|
-
|
|
60
|
-
env_path = ENV["NTGCALLS_PATH"]
|
|
61
|
-
return env_path if env_path && File.exist?(env_path)
|
|
62
|
-
|
|
63
|
-
found = default_candidates.find { |path| File.exist?(path) }
|
|
64
|
-
return found if found
|
|
65
|
-
|
|
66
|
-
raise LibraryNotFoundError,
|
|
67
|
-
"NTgCalls shared library not found. Set NTGCALLS_PATH or pass lib_path."
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def default_candidates
|
|
71
|
-
if Gem.win_platform?
|
|
72
|
-
[
|
|
73
|
-
"ntgcalls.dll",
|
|
74
|
-
"vendor/ntgcalls/windows/ntgcalls.dll",
|
|
75
|
-
"vendor/ntgcalls/ntgcalls.dll",
|
|
76
|
-
"C:/ntgcalls/bin/ntgcalls.dll"
|
|
77
|
-
]
|
|
78
|
-
elsif RUBY_PLATFORM.include?("darwin")
|
|
79
|
-
[
|
|
80
|
-
"libntgcalls.dylib",
|
|
81
|
-
"vendor/ntgcalls/macos/libntgcalls.dylib",
|
|
82
|
-
"vendor/ntgcalls/darwin/libntgcalls.dylib",
|
|
83
|
-
"vendor/ntgcalls/libntgcalls.dylib",
|
|
84
|
-
"/usr/local/lib/libntgcalls.dylib",
|
|
85
|
-
"/opt/homebrew/lib/libntgcalls.dylib"
|
|
86
|
-
]
|
|
87
|
-
else
|
|
88
|
-
[
|
|
89
|
-
"libntgcalls.so",
|
|
90
|
-
"vendor/ntgcalls/linux/libntgcalls.so",
|
|
91
|
-
"vendor/ntgcalls/libntgcalls.so",
|
|
92
|
-
"/usr/lib/libntgcalls.so",
|
|
93
|
-
"/usr/local/lib/libntgcalls.so"
|
|
94
|
-
]
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|