pyrobale 0.2.8.3__py3-none-any.whl → 0.2.9__py3-none-any.whl
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.
- {pyrobale-0.2.8.3.dist-info → pyrobale-0.2.9.dist-info}/METADATA +1 -1
- pyrobale-0.2.9.dist-info/RECORD +5 -0
- pyrobale.py +15 -14
- pyrobale-0.2.8.3.dist-info/RECORD +0 -5
- {pyrobale-0.2.8.3.dist-info → pyrobale-0.2.9.dist-info}/WHEEL +0 -0
- {pyrobale-0.2.8.3.dist-info → pyrobale-0.2.9.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,5 @@
|
|
1
|
+
pyrobale.py,sha256=kwVWwKhng1c3FspyX-pKHwKilJ-LOGvwHG6Nd8ImA38,89899
|
2
|
+
pyrobale-0.2.9.dist-info/METADATA,sha256=u1jXj8TcVxKbqpJviVRZqK4fGT-2iD_Jgcr2-wJJA94,43668
|
3
|
+
pyrobale-0.2.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
4
|
+
pyrobale-0.2.9.dist-info/licenses/LICENSE,sha256=XQsvifC5HE85232_XgRHpeQ35MfeL2YcpU4yPiAgmW4,35269
|
5
|
+
pyrobale-0.2.9.dist-info/RECORD,,
|
pyrobale.py
CHANGED
@@ -20,7 +20,7 @@ import re
|
|
20
20
|
import sys
|
21
21
|
import requests
|
22
22
|
|
23
|
-
__version__ = '0.2.
|
23
|
+
__version__ = '0.2.9'
|
24
24
|
|
25
25
|
|
26
26
|
class ChatActions:
|
@@ -1667,7 +1667,7 @@ class Client:
|
|
1667
1667
|
self._member_join_handler = None
|
1668
1668
|
self._threads = []
|
1669
1669
|
self._polling = False
|
1670
|
-
self.user =
|
1670
|
+
self.user = None
|
1671
1671
|
|
1672
1672
|
def set_state(self,
|
1673
1673
|
chat_or_user_id: Union[Chat,
|
@@ -2273,9 +2273,10 @@ class Client:
|
|
2273
2273
|
|
2274
2274
|
def _create_thread(self, handler, *args):
|
2275
2275
|
"""Helper method to create and start a thread"""
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2276
|
+
if handler:
|
2277
|
+
thread = threading.Thread(target=handler, args=args, daemon=True)
|
2278
|
+
thread.start()
|
2279
|
+
self._threads.append(thread)
|
2279
2280
|
|
2280
2281
|
def _handle_message(self, message, update):
|
2281
2282
|
"""Handle different types of messages"""
|
@@ -2314,7 +2315,7 @@ class Client:
|
|
2314
2315
|
self._create_thread(handler, *args)
|
2315
2316
|
return
|
2316
2317
|
|
2317
|
-
if self
|
2318
|
+
if hasattr(self, '_message_handler'):
|
2318
2319
|
conds = conditions(
|
2319
2320
|
self,
|
2320
2321
|
message.author,
|
@@ -2333,7 +2334,7 @@ class Client:
|
|
2333
2334
|
# Handle message and edited message
|
2334
2335
|
message_types = {
|
2335
2336
|
'message': (Message, self._handle_message),
|
2336
|
-
'edited_message': (Message, self._message_edit_handler)
|
2337
|
+
'edited_message': (Message, lambda m, u: self._create_thread(self._message_edit_handler, m, u) if hasattr(self, '_message_edit_handler') else None)
|
2337
2338
|
}
|
2338
2339
|
|
2339
2340
|
for update_type, (cls, handler) in message_types.items():
|
@@ -2344,7 +2345,7 @@ class Client:
|
|
2344
2345
|
handler(message, update)
|
2345
2346
|
return
|
2346
2347
|
|
2347
|
-
if 'callback_query' in update and self
|
2348
|
+
if 'callback_query' in update and hasattr(self, '_callback_handler'):
|
2348
2349
|
obj = CallbackQuery(
|
2349
2350
|
self, {
|
2350
2351
|
'ok': True, 'result': update['callback_query']})
|
@@ -2362,13 +2363,14 @@ class Client:
|
|
2362
2363
|
info['last_run'] = current_time
|
2363
2364
|
|
2364
2365
|
def run(self, debug=False):
|
2365
|
-
"""Start
|
2366
|
+
"""Start polling for new messages"""
|
2366
2367
|
try:
|
2367
2368
|
self.user = self.get_me()
|
2368
2369
|
except BaseException:
|
2369
2370
|
raise BaleTokenNotFoundError("token not found")
|
2370
2371
|
|
2371
2372
|
self._polling = True
|
2373
|
+
self._threads = []
|
2372
2374
|
offset = 0
|
2373
2375
|
past_updates = set()
|
2374
2376
|
source_file = inspect.getfile(self.__class__)
|
@@ -2389,7 +2391,7 @@ class Client:
|
|
2389
2391
|
python = sys.executable
|
2390
2392
|
os.execl(python, python, *sys.argv)
|
2391
2393
|
|
2392
|
-
updates = self.get_updates(offset=offset
|
2394
|
+
updates = self.get_updates(offset=offset)
|
2393
2395
|
for update in updates:
|
2394
2396
|
update_id = update['update_id']
|
2395
2397
|
if update_id not in past_updates:
|
@@ -2416,9 +2418,8 @@ class Client:
|
|
2416
2418
|
print(f"Error checking file modification time: {e}")
|
2417
2419
|
return False
|
2418
2420
|
|
2419
|
-
def get_updates(self) -> List[Dict[str, Any]]:
|
2420
|
-
params = {
|
2421
|
-
'self' and v is not None}
|
2421
|
+
def get_updates(self, offset=None) -> List[Dict[str, Any]]:
|
2422
|
+
params = {'offset': offset} if offset is not None else {}
|
2422
2423
|
response = self._make_request('GET', 'getUpdates', params=params)
|
2423
2424
|
return response.get('result', [])
|
2424
2425
|
|
@@ -2432,4 +2433,4 @@ class Client:
|
|
2432
2433
|
self._close_handler()
|
2433
2434
|
|
2434
2435
|
def create_ref_link(self, data: str):
|
2435
|
-
return f"https://ble.ir/{self.get_me().username}?start={data}"
|
2436
|
+
return f"https://ble.ir/{self.get_me().username}?start={data}"
|
@@ -1,5 +0,0 @@
|
|
1
|
-
pyrobale.py,sha256=EaJ172999Zft7HOuMNJPsho6YJFFo242SZuY2B9peX4,89775
|
2
|
-
pyrobale-0.2.8.3.dist-info/METADATA,sha256=wqOaghx0itJIOM79hvRZzGyuAHKqjZpT57dxLJ88t64,43670
|
3
|
-
pyrobale-0.2.8.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
4
|
-
pyrobale-0.2.8.3.dist-info/licenses/LICENSE,sha256=XQsvifC5HE85232_XgRHpeQ35MfeL2YcpU4yPiAgmW4,35269
|
5
|
-
pyrobale-0.2.8.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|