@@ -15,14 +15,119 @@ function callback:new(ctx)
15
15
local obj = {}
16
16
17
17
obj .update_id = ctx .update_id
18
- obj .message = Message (ctx .callback_query .message , { direct = true })
19
18
19
+ local t_message = Message (ctx .callback_query .message , { direct = true })
20
+
21
+ obj .message = t_message .message
20
22
obj .callback_query = ctx .callback_query
21
23
obj .is_callback_query = true
22
24
23
25
return setmetatable (obj , self )
24
26
end
25
27
28
+ -- START DEPRECATED BLOCK
29
+ --
30
+ -- Этот блок, стоило бы не делать, так как -
31
+ -- Но оставим ради поддержки старой версии библиотеки.
32
+ --
33
+ --- Gets the chat from the associated message.
34
+ -- @return (number) The chat.
35
+ function callback :getChat ()
36
+ if self .message and self .message .chat then
37
+ return self .message .chat
38
+ end
39
+ end
40
+
41
+ --- Gets the chat ID from the associated message.
42
+ -- @return (number) The chat ID.
43
+ function callback :getChatId ()
44
+ if self .message and self .message .chat then
45
+ return self .message .chat .id
46
+ end
47
+ end
48
+
49
+ --- Gets the chat type from the associated message.
50
+ -- @return (string) The chat type.
51
+ function callback :getChatType ()
52
+ if self .message and self .message .chat then
53
+ return self .message .chat .type
54
+ end
55
+ end
56
+
57
+ --- Gets the text from the associated message.
58
+ -- @return (string) The message text.
59
+ function callback :getText ()
60
+ if self .message and self .message .text then
61
+ return self .message .text
62
+ end
63
+ end
64
+
65
+ --- Gets the message ID from the associated message.
66
+ -- @return (number) The message ID.
67
+ function callback :getMessageId ()
68
+ if self .message and self .message .message_id then
69
+ return self .message .message_id
70
+ end
71
+ end
72
+
73
+ --- Gets the user data from the associated message.
74
+ -- @return (table) The user data.
75
+ function callback :getUserMessageFrom ()
76
+ if self .message and self .message .from then
77
+ return self .message .from
78
+ end
79
+ end
80
+
81
+ --- Gets the user who replied to the associated message.
82
+ -- @return (table) The user data of the reply.
83
+ function callback :getUserReply ()
84
+ if self .message and self .message .reply_to_message then
85
+ return self .message .reply_to_message .from
86
+ end
87
+ end
88
+
89
+ --- get reply to message
90
+ -- @return (table)
91
+ function callback :getReplyToMessage ()
92
+ if self .message and self .message .reply_to_message then
93
+ return self .message .reply_to_message
94
+ end
95
+ end
96
+
97
+ --- Checks if the user who sent the callback query is the same as the one who replied to the associated message.
98
+ -- @return (boolean) True if it's the same user, false otherwise.
99
+ function callback :isSameUser ()
100
+ if self .callback_query and self .callback_query .from and
101
+ self .message and self .message .reply_to_message
102
+ then
103
+ return self .callback_query .from .id == self .message .reply_to_message .from .id
104
+ end
105
+ end
106
+
107
+ --- Gets the inline keyboard
108
+ -- @return (table) inline keyboard object
109
+ function callback :getInlineKeyboard ()
110
+ if self .message
111
+ and self .message .reply_markup
112
+ and self .message .reply_markup .inline_keyboard
113
+ then
114
+ return self .message .reply_markup .inline_keyboard
115
+ end
116
+ end
117
+
118
+ --- Gets the sender chat
119
+ -- @return (table) Sender chat object
120
+ function callback :getSenderChat ()
121
+ if self .message
122
+ and self .message .reply_to_message
123
+ and self .message .reply_to_message .sender_chat
124
+ then
125
+ return self .message .reply_to_message .sender_chat
126
+ end
127
+ end
128
+ --
129
+ -- END DEPRECATED BLOCK
130
+
26
131
--- Gets the update ID
27
132
-- @return (number) The update ID
28
133
function callback :getUpdateId ()
0 commit comments