d4rktg 0.4.2__py3-none-any.whl → 0.4.4__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.
d4rk/Utils/_round.py CHANGED
@@ -1,23 +1,34 @@
1
1
  from itertools import cycle
2
2
  from functools import wraps
3
+ from pyrogram import Message
3
4
 
4
- bot_cycle = None
5
5
  last_selected = None
6
-
7
- def set_bot_cycle(bot_ids):
8
- global bot_cycle
9
- bot_cycle = cycle(bot_ids)
6
+ bot_order = []
10
7
 
11
8
  def round_robin():
12
9
  def decorator(func):
13
10
  @wraps(func)
14
- async def wrapper(client, message, *args, **kwargs):
15
- global last_selected, bot_cycle
16
- if bot_cycle is None:return
17
- if last_selected is None:last_selected = next(bot_cycle)
11
+ async def wrapper(client, message: Message, *args, **kwargs):
12
+ global last_selected, bot_order
13
+
14
+ # Private chats: all bots respond
15
+ if message.chat.type.name.lower() == "private":
16
+ return await func(client, message, *args, **kwargs)
17
+
18
+ # If this chat is new, start order dynamically
19
+ chat_id = message.chat.id
20
+ if chat_id not in bot_order:
21
+ bot_order.append(client.me.id)
22
+ last_selected = client.me.id
23
+
24
+ # Only the "current" bot responds
18
25
  if client.me.id == last_selected:
19
26
  result = await func(client, message, *args, **kwargs)
20
- last_selected = next(bot_cycle)
27
+
28
+ # Rotate for next message
29
+ alive_bots = [b for b in bot_order if b is not None] # optionally skip dead bots
30
+ idx = alive_bots.index(last_selected)
31
+ last_selected = alive_bots[(idx + 1) % len(alive_bots)]
21
32
  return result
22
33
  return wrapper
23
34
  return decorator
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d4rktg
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: A module for create with easy and fast
5
5
  Author: D4rkShell
6
6
  Author-email: premiumqtrst@gmail.com
@@ -16,9 +16,9 @@ d4rk/Utils/_fonts.py,sha256=CQsDqPgvp27t3f75Cxod0EmZogEssLwIpyesH-YY5KM,7518
16
16
  d4rk/Utils/_ip.py,sha256=KJJW2QSngshIVWCO5YPXF1wj4IPQzVN5oFofpfzlU5w,559
17
17
  d4rk/Utils/_movie_parser.py,sha256=QEPd3z04p4pk2vxZ-2fYlRxHmQbmwQd2mCIlBsBM5AY,7039
18
18
  d4rk/Utils/_ractions.py,sha256=wOVPyoFnbDuMgoP6NF_gLO1DYcfhERC0trdAK1jWSE8,2170
19
- d4rk/Utils/_round.py,sha256=g8j0DMM41ZOzQpNL83qBwPj3DVSE63bHgVXbA4ZZ8lo,717
19
+ d4rk/Utils/_round.py,sha256=WAU6pQDcjHRB_OugSwNeGLR7tw_7r7VTxdmvEpwtQbU,1246
20
20
  d4rk/Utils/_terminal.py,sha256=Anu4OcffY3v6LMOrCskP1cHrJIliomo1Hjownbhh2sQ,125
21
- d4rktg-0.4.2.dist-info/METADATA,sha256=N-4fXb4tUCYOZiay_F_UZzh1ehkW8bcXtIHDPmwp-pU,652
22
- d4rktg-0.4.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- d4rktg-0.4.2.dist-info/top_level.txt,sha256=qs1qTnKWImmGi7E0FoJS0OAEOHoVZA9vHRS3Pm6ncAo,5
24
- d4rktg-0.4.2.dist-info/RECORD,,
21
+ d4rktg-0.4.4.dist-info/METADATA,sha256=ukSCE1bouEcBnDA_AUAelTfU-nDXTMVd5CbP8fdVT3A,652
22
+ d4rktg-0.4.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ d4rktg-0.4.4.dist-info/top_level.txt,sha256=qs1qTnKWImmGi7E0FoJS0OAEOHoVZA9vHRS3Pm6ncAo,5
24
+ d4rktg-0.4.4.dist-info/RECORD,,
File without changes