Rubka 1.5.0__tar.gz → 1.7.2__tar.gz
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.
- {rubka-1.5.0 → rubka-1.7.2}/PKG-INFO +1 -1
- {rubka-1.5.0 → rubka-1.7.2}/Rubka.egg-info/PKG-INFO +1 -1
- {rubka-1.5.0 → rubka-1.7.2}/rubka/api.py +20 -14
- rubka-1.7.2/rubka/context.py +294 -0
- {rubka-1.5.0 → rubka-1.7.2}/setup.py +1 -1
- rubka-1.5.0/rubka/context.py +0 -99
- {rubka-1.5.0 → rubka-1.7.2}/README.md +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/Rubka.egg-info/SOURCES.txt +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/Rubka.egg-info/dependency_links.txt +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/Rubka.egg-info/requires.txt +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/Rubka.egg-info/top_level.txt +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/rubka/__init__.py +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/rubka/config.py +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/rubka/decorators.py +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/rubka/exceptions.py +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/rubka/jobs.py +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/rubka/keyboards.py +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/rubka/keypad.py +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/rubka/logger.py +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/rubka/utils.py +0 -0
- {rubka-1.5.0 → rubka-1.7.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Rubka
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.2
|
|
4
4
|
Summary: A Python library for interacting with Rubika Bot API.
|
|
5
5
|
Home-page: https://github.com/Mahdy-Ahmadi/Rubka
|
|
6
6
|
Download-URL: https://github.com/Mahdy-Ahmadi/Rubka/archive/refs/tags/v0.1.0.tar.gz
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: Rubka
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.2
|
|
4
4
|
Summary: A Python library for interacting with Rubika Bot API.
|
|
5
5
|
Home-page: https://github.com/Mahdy-Ahmadi/Rubka
|
|
6
6
|
Download-URL: https://github.com/Mahdy-Ahmadi/Rubka/archive/refs/tags/v0.1.0.tar.gz
|
|
@@ -3,7 +3,7 @@ from typing import List, Optional, Dict, Any, Literal
|
|
|
3
3
|
from .exceptions import APIRequestError
|
|
4
4
|
from .logger import logger
|
|
5
5
|
from typing import Callable
|
|
6
|
-
from .context import
|
|
6
|
+
from .context import Message
|
|
7
7
|
API_URL = "https://botapi.rubika.ir/v3"
|
|
8
8
|
|
|
9
9
|
class Robot:
|
|
@@ -24,18 +24,24 @@ class Robot:
|
|
|
24
24
|
try:
|
|
25
25
|
response = self.session.post(url, json=data, timeout=10)
|
|
26
26
|
response.raise_for_status()
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
try:
|
|
28
|
+
json_resp = response.json()
|
|
29
|
+
except ValueError:
|
|
30
|
+
logger.error(f"Invalid JSON response from {method}: {response.text}")
|
|
31
|
+
raise APIRequestError(f"Invalid JSON response: {response.text}")
|
|
32
|
+
if method != "getUpdates":logger.debug(f"API Response from {method}: {json_resp}")
|
|
33
|
+
|
|
29
34
|
return json_resp
|
|
30
35
|
except requests.RequestException as e:
|
|
31
36
|
logger.error(f"API request failed: {e}")
|
|
32
37
|
raise APIRequestError(f"API request failed: {e}") from e
|
|
33
38
|
|
|
39
|
+
|
|
34
40
|
def get_me(self) -> Dict[str, Any]:
|
|
35
41
|
"""Get info about the bot itself."""
|
|
36
42
|
return self._post("getMe", {})
|
|
37
|
-
def on_message(self, filters: Optional[Callable[[
|
|
38
|
-
def decorator(func: Callable[[Any,
|
|
43
|
+
def on_message(self, filters: Optional[Callable[[Message], bool]] = None, commands: Optional[List[str]] = None):
|
|
44
|
+
def decorator(func: Callable[[Any, Message], None]):
|
|
39
45
|
self._message_handler = {
|
|
40
46
|
"func": func,
|
|
41
47
|
"filters": filters,
|
|
@@ -47,18 +53,16 @@ class Robot:
|
|
|
47
53
|
|
|
48
54
|
|
|
49
55
|
def _process_update(self, update: Dict[str, Any]):
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
chat_id = update_data.get('chat_id')
|
|
56
|
+
if update.get('type') == 'NewMessage':
|
|
57
|
+
msg = update.get('new_message', {})
|
|
58
|
+
chat_id = update.get('chat_id')
|
|
54
59
|
message_id = msg.get('message_id')
|
|
55
60
|
sender_id = msg.get('sender_id')
|
|
56
61
|
text = msg.get('text')
|
|
57
62
|
|
|
58
63
|
if self._message_handler:
|
|
59
64
|
handler = self._message_handler
|
|
60
|
-
context =
|
|
61
|
-
|
|
65
|
+
context = Message(bot=self, chat_id=chat_id, message_id=message_id, sender_id=sender_id, text=text, raw_data=msg)
|
|
62
66
|
|
|
63
67
|
if handler["commands"]:
|
|
64
68
|
if not context.text or not context.text.startswith("/"):
|
|
@@ -78,19 +82,21 @@ class Robot:
|
|
|
78
82
|
|
|
79
83
|
|
|
80
84
|
|
|
85
|
+
|
|
81
86
|
def run(self):
|
|
82
87
|
print("Bot started running...")
|
|
83
88
|
while True:
|
|
84
89
|
try:
|
|
85
90
|
updates = self.get_updates(offset_id=self._offset_id, limit=10)
|
|
86
91
|
if updates and updates.get('data'):
|
|
87
|
-
for update in updates['data']:
|
|
92
|
+
for update in updates['data'].get('updates', []):
|
|
88
93
|
self._process_update(update)
|
|
89
|
-
self._offset_id =
|
|
94
|
+
self._offset_id = updates['data'].get('next_offset_id', self._offset_id)
|
|
90
95
|
except Exception as e:
|
|
91
96
|
print(f"Error in run loop: {e}")
|
|
92
|
-
logger.error(f"API request failed: {e}")
|
|
97
|
+
#logger.error(f"API request failed: {e}")
|
|
93
98
|
raise APIRequestError(f"API request failed: {e}") from e
|
|
99
|
+
|
|
94
100
|
def send_message(
|
|
95
101
|
self,
|
|
96
102
|
chat_id: str,
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
from typing import Any, Dict, List,Optional
|
|
2
|
+
|
|
3
|
+
class File:
|
|
4
|
+
def __init__(self, data: dict):
|
|
5
|
+
self.file_id: str = data.get("file_id")
|
|
6
|
+
self.file_name: str = data.get("file_name")
|
|
7
|
+
self.size: str = data.get("size")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Sticker:
|
|
11
|
+
def __init__(self, data: dict):
|
|
12
|
+
self.sticker_id: str = data.get("sticker_id")
|
|
13
|
+
self.emoji_character: str = data.get("emoji_character")
|
|
14
|
+
self.file = File(data.get("file", {}))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# =========================
|
|
18
|
+
# Poll
|
|
19
|
+
# =========================
|
|
20
|
+
class PollStatus:
|
|
21
|
+
def __init__(self, data: dict):
|
|
22
|
+
self.state: str = data.get("state")
|
|
23
|
+
self.selection_index: int = data.get("selection_index")
|
|
24
|
+
self.percent_vote_options: List[int] = data.get("percent_vote_options", [])
|
|
25
|
+
self.total_vote: int = data.get("total_vote")
|
|
26
|
+
self.show_total_votes: bool = data.get("show_total_votes")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Poll:
|
|
30
|
+
def __init__(self, data: dict):
|
|
31
|
+
self.question: str = data.get("question")
|
|
32
|
+
self.options: List[str] = data.get("options", [])
|
|
33
|
+
self.poll_status = PollStatus(data.get("poll_status", {}))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# =========================
|
|
37
|
+
# Location & Contact & ForwardedFrom
|
|
38
|
+
# =========================
|
|
39
|
+
class Location:
|
|
40
|
+
def __init__(self, data: dict):
|
|
41
|
+
self.latitude: str = data.get("latitude")
|
|
42
|
+
self.longitude: str = data.get("longitude")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class LiveLocation:
|
|
46
|
+
def __init__(self, data: dict):
|
|
47
|
+
self.start_time: str = data.get("start_time")
|
|
48
|
+
self.live_period: int = data.get("live_period")
|
|
49
|
+
self.current_location = Location(data.get("current_location", {}))
|
|
50
|
+
self.user_id: str = data.get("user_id")
|
|
51
|
+
self.status: str = data.get("status")
|
|
52
|
+
self.last_update_time: str = data.get("last_update_time")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class ContactMessage:
|
|
56
|
+
def __init__(self, data: dict):
|
|
57
|
+
self.phone_number: str = data.get("phone_number")
|
|
58
|
+
self.first_name: str = data.get("first_name")
|
|
59
|
+
self.last_name: str = data.get("last_name")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class ForwardedFrom:
|
|
63
|
+
def __init__(self, data: dict):
|
|
64
|
+
self.type_from: str = data.get("type_from")
|
|
65
|
+
self.message_id: str = data.get("message_id")
|
|
66
|
+
self.from_chat_id: str = data.get("from_chat_id")
|
|
67
|
+
self.from_sender_id: str = data.get("from_sender_id")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# =========================
|
|
71
|
+
# AuxData
|
|
72
|
+
# =========================
|
|
73
|
+
class AuxData:
|
|
74
|
+
def __init__(self, data: dict):
|
|
75
|
+
self.start_id: str = data.get("start_id")
|
|
76
|
+
self.button_id: str = data.get("button_id")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# =========================
|
|
80
|
+
# Button Models
|
|
81
|
+
# =========================
|
|
82
|
+
class ButtonTextbox:
|
|
83
|
+
def __init__(self, data: dict):
|
|
84
|
+
self.type_line: str = data.get("type_line")
|
|
85
|
+
self.type_keypad: str = data.get("type_keypad")
|
|
86
|
+
self.place_holder: Optional[str] = data.get("place_holder")
|
|
87
|
+
self.title: Optional[str] = data.get("title")
|
|
88
|
+
self.default_value: Optional[str] = data.get("default_value")
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class ButtonNumberPicker:
|
|
92
|
+
def __init__(self, data: dict):
|
|
93
|
+
self.min_value: str = data.get("min_value")
|
|
94
|
+
self.max_value: str = data.get("max_value")
|
|
95
|
+
self.default_value: Optional[str] = data.get("default_value")
|
|
96
|
+
self.title: str = data.get("title")
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class ButtonStringPicker:
|
|
100
|
+
def __init__(self, data: dict):
|
|
101
|
+
self.items: List[str] = data.get("items", [])
|
|
102
|
+
self.default_value: Optional[str] = data.get("default_value")
|
|
103
|
+
self.title: Optional[str] = data.get("title")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class ButtonCalendar:
|
|
107
|
+
def __init__(self, data: dict):
|
|
108
|
+
self.default_value: Optional[str] = data.get("default_value")
|
|
109
|
+
self.type: str = data.get("type")
|
|
110
|
+
self.min_year: str = data.get("min_year")
|
|
111
|
+
self.max_year: str = data.get("max_year")
|
|
112
|
+
self.title: str = data.get("title")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class ButtonLocation:
|
|
116
|
+
def __init__(self, data: dict):
|
|
117
|
+
self.default_pointer_location = Location(data.get("default_pointer_location", {}))
|
|
118
|
+
self.default_map_location = Location(data.get("default_map_location", {}))
|
|
119
|
+
self.type: str = data.get("type")
|
|
120
|
+
self.title: Optional[str] = data.get("title")
|
|
121
|
+
self.location_image_url: str = data.get("location_image_url")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class ButtonSelectionItem:
|
|
125
|
+
def __init__(self, data: dict):
|
|
126
|
+
self.text: str = data.get("text")
|
|
127
|
+
self.image_url: str = data.get("image_url")
|
|
128
|
+
self.type: str = data.get("type")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class ButtonSelection:
|
|
132
|
+
def __init__(self, data: dict):
|
|
133
|
+
self.selection_id: str = data.get("selection_id")
|
|
134
|
+
self.search_type: str = data.get("search_type")
|
|
135
|
+
self.get_type: str = data.get("get_type")
|
|
136
|
+
self.items: List[ButtonSelectionItem] = [ButtonSelectionItem(i) for i in data.get("items", [])]
|
|
137
|
+
self.is_multi_selection: bool = data.get("is_multi_selection")
|
|
138
|
+
self.columns_count: str = data.get("columns_count")
|
|
139
|
+
self.title: str = data.get("title")
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class Button:
|
|
143
|
+
def __init__(self, data: dict):
|
|
144
|
+
self.id: str = data.get("id")
|
|
145
|
+
self.type: str = data.get("type")
|
|
146
|
+
self.button_text: str = data.get("button_text")
|
|
147
|
+
self.button_selection = ButtonSelection(data.get("button_selection", {})) if "button_selection" in data else None
|
|
148
|
+
self.button_calendar = ButtonCalendar(data.get("button_calendar", {})) if "button_calendar" in data else None
|
|
149
|
+
self.button_number_picker = ButtonNumberPicker(data.get("button_number_picker", {})) if "button_number_picker" in data else None
|
|
150
|
+
self.button_string_picker = ButtonStringPicker(data.get("button_string_picker", {})) if "button_string_picker" in data else None
|
|
151
|
+
self.button_location = ButtonLocation(data.get("button_location", {})) if "button_location" in data else None
|
|
152
|
+
self.button_textbox = ButtonTextbox(data.get("button_textbox", {})) if "button_textbox" in data else None
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class KeypadRow:
|
|
156
|
+
def __init__(self, data: dict):
|
|
157
|
+
self.buttons: List[Button] = [Button(btn) for btn in data.get("buttons", [])]
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class Keypad:
|
|
161
|
+
def __init__(self, data: dict):
|
|
162
|
+
self.rows: List[KeypadRow] = [KeypadRow(r) for r in data.get("rows", [])]
|
|
163
|
+
self.resize_keyboard: bool = data.get("resize_keyboard", False)
|
|
164
|
+
self.on_time_keyboard: bool = data.get("on_time_keyboard", False)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class Chat:
|
|
168
|
+
def __init__(self, data: dict):
|
|
169
|
+
self.chat_id: str = data.get("chat_id")
|
|
170
|
+
self.chat_type: str = data.get("chat_type")
|
|
171
|
+
self.user_id: str = data.get("user_id")
|
|
172
|
+
self.first_name: str = data.get("first_name")
|
|
173
|
+
self.last_name: str = data.get("last_name")
|
|
174
|
+
self.title: str = data.get("title")
|
|
175
|
+
self.username: str = data.get("username")
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class Bot:
|
|
179
|
+
def __init__(self, data: dict):
|
|
180
|
+
self.bot_id: str = data.get("bot_id")
|
|
181
|
+
self.bot_title: str = data.get("bot_title")
|
|
182
|
+
self.avatar = File(data.get("avatar", {}))
|
|
183
|
+
self.description: str = data.get("description")
|
|
184
|
+
self.username: str = data.get("username")
|
|
185
|
+
self.start_message: str = data.get("start_message")
|
|
186
|
+
self.share_url: str = data.get("share_url")
|
|
187
|
+
class Message:
|
|
188
|
+
def __init__(self, bot, chat_id, message_id, sender_id, text, raw_data=None):
|
|
189
|
+
self.bot = bot
|
|
190
|
+
self.chat_id = chat_id
|
|
191
|
+
self.message_id = message_id
|
|
192
|
+
self.sender_id = sender_id
|
|
193
|
+
self.text = text
|
|
194
|
+
self.args = []
|
|
195
|
+
self.raw_data = raw_data or {}
|
|
196
|
+
|
|
197
|
+
self.reply_to_message_id: Optional[str] = self.raw_data.get("reply_to_message_id")
|
|
198
|
+
self.forwarded_from = ForwardedFrom(self.raw_data["forwarded_from"]) if "forwarded_from" in self.raw_data else None
|
|
199
|
+
self.file = File(self.raw_data["file"]) if "file" in self.raw_data else None
|
|
200
|
+
self.sticker = Sticker(self.raw_data["sticker"]) if "sticker" in self.raw_data else None
|
|
201
|
+
self.contact_message = ContactMessage(self.raw_data["contact_message"]) if "contact_message" in self.raw_data else None
|
|
202
|
+
self.poll = Poll(self.raw_data["poll"]) if "poll" in self.raw_data else None
|
|
203
|
+
self.location = Location(self.raw_data["location"]) if "location" in self.raw_data else None
|
|
204
|
+
self.live_location = LiveLocation(self.raw_data["live_location"]) if "live_location" in self.raw_data else None
|
|
205
|
+
self.aux_data = AuxData(self.raw_data["aux_data"]) if "aux_data" in self.raw_data else None
|
|
206
|
+
|
|
207
|
+
@property
|
|
208
|
+
def session(self):
|
|
209
|
+
if self.chat_id not in self.bot.sessions:
|
|
210
|
+
self.bot.sessions[self.chat_id] = {}
|
|
211
|
+
return self.bot.sessions[self.chat_id]
|
|
212
|
+
def reply(self, text: str, **kwargs):
|
|
213
|
+
return self.bot.send_message(
|
|
214
|
+
self.chat_id,
|
|
215
|
+
text,
|
|
216
|
+
reply_to_message_id=self.message_id,
|
|
217
|
+
**kwargs
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
def reply_poll(self, question: str, options: List[str], **kwargs) -> Dict[str, Any]:
|
|
221
|
+
return self.bot._post("sendPoll", {
|
|
222
|
+
"chat_id": self.chat_id,
|
|
223
|
+
"question": question,
|
|
224
|
+
"options": options,
|
|
225
|
+
"reply_to_message_id": self.message_id,
|
|
226
|
+
**kwargs
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
def reply_location(self, latitude: str, longitude: str, **kwargs) -> Dict[str, Any]:
|
|
230
|
+
return self.bot.send_location(
|
|
231
|
+
chat_id=self.chat_id,
|
|
232
|
+
latitude=latitude,
|
|
233
|
+
longitude=longitude,
|
|
234
|
+
reply_to_message_id=self.message_id,
|
|
235
|
+
**kwargs
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
def reply_contact(self, first_name: str, last_name: str, phone_number: str, **kwargs) -> Dict[str, Any]:
|
|
239
|
+
return self.bot.send_contact(
|
|
240
|
+
chat_id=self.chat_id,
|
|
241
|
+
first_name=first_name,
|
|
242
|
+
last_name=last_name,
|
|
243
|
+
phone_number=phone_number,
|
|
244
|
+
reply_to_message_id=self.message_id,
|
|
245
|
+
**kwargs
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
def reply_keypad(self, text: str, keypad: Dict[str, Any], **kwargs) -> Dict[str, Any]:
|
|
249
|
+
return self.bot.send_message(
|
|
250
|
+
chat_id=self.chat_id,
|
|
251
|
+
text=text,
|
|
252
|
+
chat_keypad_type="New",
|
|
253
|
+
chat_keypad=keypad,
|
|
254
|
+
reply_to_message_id=self.message_id,
|
|
255
|
+
**kwargs
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
def reply_inline(self, text: str, inline_keypad: Dict[str, Any], **kwargs) -> Dict[str, Any]:
|
|
259
|
+
return self.bot.send_message(
|
|
260
|
+
chat_id=self.chat_id,
|
|
261
|
+
text=text,
|
|
262
|
+
inline_keypad=inline_keypad,
|
|
263
|
+
reply_to_message_id=self.message_id,
|
|
264
|
+
**kwargs
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
def reply_sticker(self, sticker_id: str, **kwargs) -> Dict[str, Any]:
|
|
268
|
+
return self.bot._post("sendSticker", {
|
|
269
|
+
"chat_id": self.chat_id,
|
|
270
|
+
"sticker_id": sticker_id,
|
|
271
|
+
"reply_to_message_id": self.message_id,
|
|
272
|
+
**kwargs
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
def reply_file(self, file_id: str, **kwargs) -> Dict[str, Any]:
|
|
276
|
+
return self.bot._post("sendFile", {
|
|
277
|
+
"chat_id": self.chat_id,
|
|
278
|
+
"file_id": file_id,
|
|
279
|
+
"reply_to_message_id": self.message_id,
|
|
280
|
+
**kwargs
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
def edit(self, new_text: str) -> Dict[str, Any]:
|
|
284
|
+
return self.bot.edit_message_text(
|
|
285
|
+
chat_id=self.chat_id,
|
|
286
|
+
message_id=self.message_id,
|
|
287
|
+
text=new_text
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
def delete(self) -> Dict[str, Any]:
|
|
291
|
+
return self.bot.delete_message(
|
|
292
|
+
chat_id=self.chat_id,
|
|
293
|
+
message_id=self.message_id
|
|
294
|
+
)
|
rubka-1.5.0/rubka/context.py
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, List
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Message:
|
|
5
|
-
def __init__(self, bot, chat_id, message_id, sender_id, text):
|
|
6
|
-
self.bot = bot
|
|
7
|
-
self.chat_id = chat_id
|
|
8
|
-
self.message_id = message_id
|
|
9
|
-
self.sender_id = sender_id
|
|
10
|
-
self.text = text
|
|
11
|
-
self.args = []
|
|
12
|
-
@property
|
|
13
|
-
def session(self):
|
|
14
|
-
if self.chat_id not in self.bot.sessions:
|
|
15
|
-
self.bot.sessions[self.chat_id] = {}
|
|
16
|
-
return self.bot.sessions[self.chat_id]
|
|
17
|
-
def reply(self, text: str, **kwargs):
|
|
18
|
-
return self.bot.send_message(
|
|
19
|
-
self.chat_id,
|
|
20
|
-
text,
|
|
21
|
-
reply_to_message_id=self.message_id,
|
|
22
|
-
**kwargs
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
def reply_poll(self, question: str, options: List[str], **kwargs) -> Dict[str, Any]:
|
|
26
|
-
return self.bot._post("sendPoll", {
|
|
27
|
-
"chat_id": self.chat_id,
|
|
28
|
-
"question": question,
|
|
29
|
-
"options": options,
|
|
30
|
-
"reply_to_message_id": self.message_id,
|
|
31
|
-
**kwargs
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
def reply_location(self, latitude: str, longitude: str, **kwargs) -> Dict[str, Any]:
|
|
35
|
-
return self.bot.send_location(
|
|
36
|
-
chat_id=self.chat_id,
|
|
37
|
-
latitude=latitude,
|
|
38
|
-
longitude=longitude,
|
|
39
|
-
reply_to_message_id=self.message_id,
|
|
40
|
-
**kwargs
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
def reply_contact(self, first_name: str, last_name: str, phone_number: str, **kwargs) -> Dict[str, Any]:
|
|
44
|
-
return self.bot.send_contact(
|
|
45
|
-
chat_id=self.chat_id,
|
|
46
|
-
first_name=first_name,
|
|
47
|
-
last_name=last_name,
|
|
48
|
-
phone_number=phone_number,
|
|
49
|
-
reply_to_message_id=self.message_id,
|
|
50
|
-
**kwargs
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
def reply_keypad(self, text: str, keypad: Dict[str, Any], **kwargs) -> Dict[str, Any]:
|
|
54
|
-
return self.bot.send_message(
|
|
55
|
-
chat_id=self.chat_id,
|
|
56
|
-
text=text,
|
|
57
|
-
chat_keypad_type="New",
|
|
58
|
-
chat_keypad=keypad,
|
|
59
|
-
reply_to_message_id=self.message_id,
|
|
60
|
-
**kwargs
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
def reply_inline(self, text: str, inline_keypad: Dict[str, Any], **kwargs) -> Dict[str, Any]:
|
|
64
|
-
return self.bot.send_message(
|
|
65
|
-
chat_id=self.chat_id,
|
|
66
|
-
text=text,
|
|
67
|
-
inline_keypad=inline_keypad,
|
|
68
|
-
reply_to_message_id=self.message_id,
|
|
69
|
-
**kwargs
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
def reply_sticker(self, sticker_id: str, **kwargs) -> Dict[str, Any]:
|
|
73
|
-
return self.bot._post("sendSticker", {
|
|
74
|
-
"chat_id": self.chat_id,
|
|
75
|
-
"sticker_id": sticker_id,
|
|
76
|
-
"reply_to_message_id": self.message_id,
|
|
77
|
-
**kwargs
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
def reply_file(self, file_id: str, **kwargs) -> Dict[str, Any]:
|
|
81
|
-
return self.bot._post("sendFile", {
|
|
82
|
-
"chat_id": self.chat_id,
|
|
83
|
-
"file_id": file_id,
|
|
84
|
-
"reply_to_message_id": self.message_id,
|
|
85
|
-
**kwargs
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
def edit(self, new_text: str) -> Dict[str, Any]:
|
|
89
|
-
return self.bot.edit_message_text(
|
|
90
|
-
chat_id=self.chat_id,
|
|
91
|
-
message_id=self.message_id,
|
|
92
|
-
text=new_text
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
def delete(self) -> Dict[str, Any]:
|
|
96
|
-
return self.bot.delete_message(
|
|
97
|
-
chat_id=self.chat_id,
|
|
98
|
-
message_id=self.message_id
|
|
99
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|