d4rktg 0.6.6__py3-none-any.whl → 0.6.8__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
@@ -3,45 +3,53 @@ from pyrogram import filters
|
|
3
3
|
from pyrogram.types import Message
|
4
4
|
import asyncio
|
5
5
|
import re
|
6
|
+
from d4rk.Logs import setup_logger
|
7
|
+
|
8
|
+
logger = setup_logger(__name__)
|
6
9
|
|
7
|
-
# Track last bot index per chat
|
8
10
|
last_index_per_chat = {}
|
9
|
-
# Track bot order per chat
|
10
11
|
bot_order_per_chat = {}
|
11
|
-
# Track messages already responded to: chat_id -> set of message_ids
|
12
12
|
responded_messages = {}
|
13
|
-
# Lock per chat to prevent race conditions
|
14
13
|
chat_locks = {}
|
15
14
|
|
16
15
|
def round():
|
17
|
-
async def func(flt, client, message):
|
16
|
+
async def func(flt, client, message: Message):
|
18
17
|
chat_id = message.chat.id
|
19
18
|
msg_id = message.id
|
19
|
+
logger.debug(f"RoundRobin filter check for chat_id={chat_id}, msg_id={msg_id}")
|
20
20
|
|
21
|
-
|
22
|
-
return True
|
23
|
-
|
21
|
+
# Initialize per-chat structures
|
24
22
|
if chat_id not in bot_order_per_chat:
|
25
23
|
bot_order_per_chat[chat_id] = [client.me.id]
|
26
24
|
last_index_per_chat[chat_id] = 0
|
27
25
|
responded_messages[chat_id] = set()
|
28
26
|
chat_locks[chat_id] = asyncio.Lock()
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
else:
|
28
|
+
if client.me.id not in bot_order_per_chat[chat_id]:
|
29
|
+
bot_order_per_chat[chat_id].append(client.me.id)
|
30
|
+
|
33
31
|
async with chat_locks[chat_id]:
|
32
|
+
# Skip if already responded
|
34
33
|
if msg_id in responded_messages[chat_id]:
|
35
34
|
return False
|
36
35
|
|
36
|
+
# Always respond in private chats
|
37
|
+
if message.chat.type.name.lower() == "private":
|
38
|
+
responded_messages[chat_id].add(msg_id)
|
39
|
+
return True
|
40
|
+
|
41
|
+
# In groups, simple round-robin
|
37
42
|
current_index = last_index_per_chat[chat_id]
|
38
43
|
selected_bot_id = bot_order_per_chat[chat_id][current_index]
|
39
44
|
|
45
|
+
# If this bot is selected, mark message and rotate
|
40
46
|
if client.me.id == selected_bot_id:
|
41
47
|
responded_messages[chat_id].add(msg_id)
|
42
48
|
last_index_per_chat[chat_id] = (current_index + 1) % len(bot_order_per_chat[chat_id])
|
43
49
|
return True
|
50
|
+
|
44
51
|
return False
|
52
|
+
|
45
53
|
return filters.create(func)
|
46
54
|
|
47
55
|
def round_robin():
|
@@ -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=
|
19
|
+
d4rk/Utils/_round.py,sha256=Cj_svnnLOjdUdpgAe9-CQtQdgdk8H35615HPK7Tz6Ls,3596
|
20
20
|
d4rk/Utils/_terminal.py,sha256=Anu4OcffY3v6LMOrCskP1cHrJIliomo1Hjownbhh2sQ,125
|
21
|
-
d4rktg-0.6.
|
22
|
-
d4rktg-0.6.
|
23
|
-
d4rktg-0.6.
|
24
|
-
d4rktg-0.6.
|
21
|
+
d4rktg-0.6.8.dist-info/METADATA,sha256=r1l645TDOplZTl-8wqoRT2zVRTJdctFar8ie7m82PqU,652
|
22
|
+
d4rktg-0.6.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
23
|
+
d4rktg-0.6.8.dist-info/top_level.txt,sha256=qs1qTnKWImmGi7E0FoJS0OAEOHoVZA9vHRS3Pm6ncAo,5
|
24
|
+
d4rktg-0.6.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|