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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/README.md +11 -6
  4. data/Rakefile +51 -51
  5. data/example/bot.rb +120 -1
  6. data/example/generate_user_session.rb +81 -81
  7. data/example/tdlib.rb +77 -77
  8. data/example/userbot.rb +133 -133
  9. data/lib/gruubY/api.rb +540 -363
  10. data/lib/gruubY/async.rb +13 -13
  11. data/lib/gruubY/bot.rb +104 -90
  12. data/lib/gruubY/bound.rb +14 -14
  13. data/lib/gruubY/client.rb +310 -296
  14. data/lib/gruubY/context.rb +296 -242
  15. data/lib/gruubY/dispatcher.rb +60 -60
  16. data/lib/gruubY/enums.rb +57 -62
  17. data/lib/gruubY/exception.rb +5 -5
  18. data/lib/gruubY/file_stream.rb +17 -17
  19. data/lib/gruubY/filters.rb +292 -292
  20. data/lib/gruubY/group_manager.rb +213 -213
  21. data/lib/gruubY/handlers.rb +225 -170
  22. data/lib/gruubY/keyboard.rb +49 -49
  23. data/lib/gruubY/media.rb +38 -38
  24. data/lib/gruubY/middleware.rb +18 -18
  25. data/lib/gruubY/plugin.rb +26 -26
  26. data/lib/gruubY/raw.rb +25 -25
  27. data/lib/gruubY/retry.rb +14 -14
  28. data/lib/gruubY/server.rb +18 -18
  29. data/lib/gruubY/session.rb +30 -30
  30. data/lib/gruubY/tdlib/client.rb +565 -565
  31. data/lib/gruubY/tdlib/client_manager.rb +37 -37
  32. data/lib/gruubY/tdlib/decorators.rb +17 -17
  33. data/lib/gruubY/tdlib/errors.rb +6 -6
  34. data/lib/gruubY/tdlib/group_manager.rb +58 -58
  35. data/lib/gruubY/tdlib/native.rb +72 -72
  36. data/lib/gruubY/tdlib/schema_builder.rb +237 -237
  37. data/lib/gruubY/tdlib/tdjson.rb +49 -49
  38. data/lib/gruubY/tdlib/user_session.rb +69 -69
  39. data/lib/gruubY/types/base_object.rb +72 -72
  40. data/lib/gruubY/types/bound_entities.rb +289 -245
  41. data/lib/gruubY/types/chat.rb +93 -93
  42. data/lib/gruubY/types/chat_info.rb +32 -31
  43. data/lib/gruubY/types/extra.rb +289 -251
  44. data/lib/gruubY/types/message.rb +301 -295
  45. data/lib/gruubY/types/message_entity.rb +14 -14
  46. data/lib/gruubY/types/registry.rb +86 -67
  47. data/lib/gruubY/types/user.rb +47 -31
  48. data/lib/gruubY/webapp.rb +22 -22
  49. data/lib/gruubY.rb +39 -41
  50. data/plugins/logger.rb +7 -7
  51. metadata +3 -9
  52. data/example/ntgcalls.rb +0 -80
  53. data/lib/gruubY/ntgcalls/native.rb +0 -100
  54. data/lib/gruubY/ntgcalls.rb +0 -478
  55. data/lib/gruubY/raw_types.rb +0 -57
  56. data/plugins/media_tools.rb +0 -13
@@ -1,93 +1,93 @@
1
- require_relative "base_object"
2
-
3
- module GrubY
4
- class Chat < BaseObject
5
- fields :id, :type, :title, :username, :first_name, :last_name,
6
- :is_forum, :is_direct_messages
7
-
8
- def archive
9
- call_raw_api("archiveChats", { chat_ids: [id] })
10
- end
11
-
12
- def unarchive
13
- call_raw_api("unarchiveChats", { chat_ids: [id] })
14
- end
15
-
16
- def set_title(title)
17
- call_api("setChatTitle", { chat_id: id, title: title.to_s })
18
- end
19
-
20
- def set_description(description)
21
- call_api("setChatDescription", { chat_id: id, description: description.to_s })
22
- end
23
-
24
- def set_photo(photo, **opts)
25
- call_api("setChatPhoto", { chat_id: id, photo: photo }.merge(opts))
26
- end
27
-
28
- def set_ttl(message_auto_delete_time)
29
- call_api("setChatMessageAutoDeleteTime", { chat_id: id, message_auto_delete_time: message_auto_delete_time.to_i })
30
- end
31
-
32
- def ban_member(user_id, **opts)
33
- call_api("banChatMember", { chat_id: id, user_id: user_id }.merge(opts))
34
- end
35
-
36
- def unban_member(user_id, **opts)
37
- call_api("unbanChatMember", { chat_id: id, user_id: user_id }.merge(opts))
38
- end
39
-
40
- def restrict_member(user_id, permissions:, **opts)
41
- call_api("restrictChatMember", { chat_id: id, user_id: user_id, permissions: permissions }.merge(opts))
42
- end
43
-
44
- def promote_member(user_id, **opts)
45
- call_api("promoteChatMember", { chat_id: id, user_id: user_id }.merge(opts))
46
- end
47
-
48
- def join
49
- call_api("joinChat", { chat_id: id })
50
- end
51
-
52
- def leave
53
- call_api("leaveChat", { chat_id: id })
54
- end
55
-
56
- def export_invite_link
57
- call_api("exportChatInviteLink", { chat_id: id })
58
- end
59
-
60
- def get_member(user_id)
61
- call_api("getChatMember", { chat_id: id, user_id: user_id })
62
- end
63
-
64
- def get_members(**opts)
65
- call_raw_api("getChatAdministrators", { chat_id: id }.merge(opts))
66
- end
67
-
68
- def add_members(user_ids)
69
- ids = Array(user_ids)
70
- call_api("addChatMembers", { chat_id: id, user_ids: ids })
71
- end
72
-
73
- def mark_unread
74
- call_raw_api("markChatUnread", { chat_id: id, is_marked_as_unread: true })
75
- end
76
-
77
- def set_protected_content(enabled: true)
78
- call_raw_api("setChatProtectedContent", { chat_id: id, has_protected_content: enabled })
79
- end
80
-
81
- def unpin_all_messages
82
- call_api("unpinAllChatMessages", { chat_id: id })
83
- end
84
-
85
- def mute
86
- call_raw_api("setChatNotificationSettings", { chat_id: id, mute_for: 2_147_483_647 })
87
- end
88
-
89
- def unmute
90
- call_raw_api("setChatNotificationSettings", { chat_id: id, mute_for: 0 })
91
- end
92
- end
93
- end
1
+ require_relative "base_object"
2
+
3
+ module GrubY
4
+ class Chat < BaseObject
5
+ fields :id, :type, :title, :username, :first_name, :last_name,
6
+ :is_forum, :is_direct_messages
7
+
8
+ def archive
9
+ call_raw_api("archiveChats", { chat_ids: [id] })
10
+ end
11
+
12
+ def unarchive
13
+ call_raw_api("unarchiveChats", { chat_ids: [id] })
14
+ end
15
+
16
+ def set_title(title)
17
+ call_api("setChatTitle", { chat_id: id, title: title.to_s })
18
+ end
19
+
20
+ def set_description(description)
21
+ call_api("setChatDescription", { chat_id: id, description: description.to_s })
22
+ end
23
+
24
+ def set_photo(photo, **opts)
25
+ call_api("setChatPhoto", { chat_id: id, photo: photo }.merge(opts))
26
+ end
27
+
28
+ def set_ttl(message_auto_delete_time)
29
+ call_api("setChatMessageAutoDeleteTime", { chat_id: id, message_auto_delete_time: message_auto_delete_time.to_i })
30
+ end
31
+
32
+ def ban_member(user_id, **opts)
33
+ call_api("banChatMember", { chat_id: id, user_id: user_id }.merge(opts))
34
+ end
35
+
36
+ def unban_member(user_id, **opts)
37
+ call_api("unbanChatMember", { chat_id: id, user_id: user_id }.merge(opts))
38
+ end
39
+
40
+ def restrict_member(user_id, permissions:, **opts)
41
+ call_api("restrictChatMember", { chat_id: id, user_id: user_id, permissions: permissions }.merge(opts))
42
+ end
43
+
44
+ def promote_member(user_id, **opts)
45
+ call_api("promoteChatMember", { chat_id: id, user_id: user_id }.merge(opts))
46
+ end
47
+
48
+ def join
49
+ call_api("joinChat", { chat_id: id })
50
+ end
51
+
52
+ def leave
53
+ call_api("leaveChat", { chat_id: id })
54
+ end
55
+
56
+ def export_invite_link
57
+ call_api("exportChatInviteLink", { chat_id: id })
58
+ end
59
+
60
+ def get_member(user_id)
61
+ call_api("getChatMember", { chat_id: id, user_id: user_id })
62
+ end
63
+
64
+ def get_members(**opts)
65
+ call_raw_api("getChatAdministrators", { chat_id: id }.merge(opts))
66
+ end
67
+
68
+ def add_members(user_ids)
69
+ ids = Array(user_ids)
70
+ call_api("addChatMembers", { chat_id: id, user_ids: ids })
71
+ end
72
+
73
+ def mark_unread
74
+ call_raw_api("markChatUnread", { chat_id: id, is_marked_as_unread: true })
75
+ end
76
+
77
+ def set_protected_content(enabled: true)
78
+ call_raw_api("setChatProtectedContent", { chat_id: id, has_protected_content: enabled })
79
+ end
80
+
81
+ def unpin_all_messages
82
+ call_api("unpinAllChatMessages", { chat_id: id })
83
+ end
84
+
85
+ def mute
86
+ call_raw_api("setChatNotificationSettings", { chat_id: id, mute_for: 2_147_483_647 })
87
+ end
88
+
89
+ def unmute
90
+ call_raw_api("setChatNotificationSettings", { chat_id: id, mute_for: 0 })
91
+ end
92
+ end
93
+ end
@@ -1,31 +1,32 @@
1
- require_relative "base_object"
2
- require_relative "chat"
3
-
4
- module GrubY
5
- class ChatFullInfo < BaseObject
6
- fields :id, :type, :title, :username, :first_name, :last_name, :is_forum,
7
- :is_direct_messages, :accent_color_id, :max_reaction_count, :photo,
8
- :active_usernames, :birthdate, :business_intro, :business_location,
9
- :business_opening_hours, :personal_chat, :parent_chat,
10
- :available_reactions, :background_custom_emoji_id,
11
- :profile_accent_color_id, :profile_background_custom_emoji_id,
12
- :emoji_status_custom_emoji_id, :emoji_status_expiration_date, :bio,
13
- :has_private_forwards, :has_restricted_voice_and_video_messages,
14
- :join_to_send_messages, :join_by_request, :description, :invite_link,
15
- :pinned_message, :permissions, :accepted_gift_types,
16
- :can_send_paid_media, :slow_mode_delay, :unrestrict_boost_count,
17
- :message_auto_delete_time, :has_aggressive_anti_spam_enabled,
18
- :has_hidden_members, :has_protected_content, :has_visible_history,
19
- :sticker_set_name, :can_set_sticker_set,
20
- :custom_emoji_sticker_set_name, :linked_chat_id, :location, :rating,
21
- :first_profile_audio, :unique_gift_colors, :paid_message_star_count
22
-
23
- def initialize(data)
24
- super(data)
25
- @personal_chat = Chat.new(@personal_chat) if @personal_chat.is_a?(Hash)
26
- @parent_chat = Chat.new(@parent_chat) if @parent_chat.is_a?(Hash)
27
- end
28
- end
29
-
30
- ChatInfo = ChatFullInfo
31
- end
1
+ require_relative "base_object"
2
+ require_relative "chat"
3
+
4
+ module GrubY
5
+ class ChatFullInfo < BaseObject
6
+ fields :id, :type, :title, :username, :first_name, :last_name, :is_forum,
7
+ :is_direct_messages, :accent_color_id, :max_reaction_count, :photo,
8
+ :active_usernames, :birthdate, :business_intro, :business_location,
9
+ :business_opening_hours, :personal_chat, :parent_chat,
10
+ :available_reactions, :background_custom_emoji_id,
11
+ :profile_accent_color_id, :profile_background_custom_emoji_id,
12
+ :emoji_status_custom_emoji_id, :emoji_status_expiration_date, :bio,
13
+ :has_private_forwards, :has_restricted_voice_and_video_messages,
14
+ :join_to_send_messages, :join_by_request, :description, :invite_link,
15
+ :pinned_message, :permissions, :accepted_gift_types,
16
+ :can_send_paid_media, :slow_mode_delay, :unrestrict_boost_count,
17
+ :message_auto_delete_time, :has_aggressive_anti_spam_enabled,
18
+ :has_hidden_members, :has_protected_content, :has_visible_history,
19
+ :sticker_set_name, :can_set_sticker_set,
20
+ :custom_emoji_sticker_set_name, :linked_chat_id, :location, :rating,
21
+ :first_profile_audio, :unique_gift_colors, :paid_message_star_count,
22
+ :community, :ton_wallet_card, :share_theme
23
+
24
+ def initialize(data)
25
+ super(data)
26
+ @personal_chat = Chat.new(@personal_chat) if @personal_chat.is_a?(Hash)
27
+ @parent_chat = Chat.new(@parent_chat) if @parent_chat.is_a?(Hash)
28
+ end
29
+ end
30
+
31
+ ChatInfo = ChatFullInfo
32
+ end