pyrobale 0.2.8.3__tar.gz → 0.2.9__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyrobale
3
- Version: 0.2.8.3
3
+ Version: 0.2.9
4
4
  Summary: A python wrapper for bale api
5
5
  Project-URL: github, https://github.com/pyrobale/pyrobale
6
6
  Project-URL: website, https://pyrobale.github.io
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyrobale"
3
- version = "0.2.8.3"
3
+ version = "0.2.9"
4
4
  authors = [
5
5
  { name = "Ali Safamanesh", email = "darg.q.a.a@gmail.com" },
6
6
  ]
@@ -20,7 +20,7 @@ import re
20
20
  import sys
21
21
  import requests
22
22
 
23
- __version__ = '0.2.8.3'
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 = User(self, {})
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
- thread = threading.Thread(target=handler, args=args, daemon=True)
2277
- thread.start()
2278
- self._threads.append(thread)
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._message_handler:
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._callback_handler:
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 p-olling for new messages"""
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, timeout=30)
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 = {k: v for k, v in locals().items() if k !=
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}"
File without changes
File without changes
File without changes
File without changes