d4rktg 0.8.3__tar.gz → 0.8.4__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.
- {d4rktg-0.8.3 → d4rktg-0.8.4}/PKG-INFO +1 -1
- d4rktg-0.8.4/VERSION.txt +1 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Utils/__init__.py +1 -1
- d4rktg-0.8.4/d4rk/Utils/_round.py +55 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rktg.egg-info/PKG-INFO +1 -1
- d4rktg-0.8.3/VERSION.txt +0 -1
- d4rktg-0.8.3/d4rk/Utils/_round.py +0 -103
- {d4rktg-0.8.3 → d4rktg-0.8.4}/MANIFEST.in +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/README.rst +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Database/__init__.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Database/db.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Handlers/__init__.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Handlers/_bot.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Handlers/_scheduler.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Logs/__init__.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Logs/_logger.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Models/__init__.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Models/_commands.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Models/_movie_title.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Utils/_decorators.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Utils/_delete.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Utils/_fonts.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Utils/_ip.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Utils/_movie_parser.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Utils/_ractions.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/Utils/_terminal.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rk/__init__.py +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rktg.egg-info/SOURCES.txt +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rktg.egg-info/dependency_links.txt +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rktg.egg-info/requires.txt +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/d4rktg.egg-info/top_level.txt +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/requirements.txt +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/setup.cfg +0 -0
- {d4rktg-0.8.3 → d4rktg-0.8.4}/setup.py +0 -0
d4rktg-0.8.4/VERSION.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.8.4
|
@@ -0,0 +1,55 @@
|
|
1
|
+
from functools import wraps
|
2
|
+
from pyrogram import filters
|
3
|
+
from pyrogram.types import Message
|
4
|
+
import asyncio
|
5
|
+
import re
|
6
|
+
from d4rk.Logs import setup_logger
|
7
|
+
|
8
|
+
logger = setup_logger(__name__)
|
9
|
+
|
10
|
+
last_index_per_chat = {}
|
11
|
+
bot_order_per_chat = {}
|
12
|
+
responded_messages = {}
|
13
|
+
chat_locks = {}
|
14
|
+
|
15
|
+
def round_robin():
|
16
|
+
def decorator(func):
|
17
|
+
@wraps(func)
|
18
|
+
async def wrapper(client, message, *args, **kwargs):
|
19
|
+
chat_id = message.chat.id
|
20
|
+
msg_id = message.id
|
21
|
+
|
22
|
+
# Private chats: all bots respond
|
23
|
+
if message.chat.type.name.lower() == "private":
|
24
|
+
return await func(client, message, *args, **kwargs)
|
25
|
+
|
26
|
+
# Initialize tracking for this chat
|
27
|
+
if chat_id not in bot_order_per_chat:
|
28
|
+
bot_order_per_chat[chat_id] = [client.me.id]
|
29
|
+
last_index_per_chat[chat_id] = 0
|
30
|
+
responded_messages[chat_id] = set()
|
31
|
+
chat_locks[chat_id] = asyncio.Lock()
|
32
|
+
|
33
|
+
# Add new bot if not in the chat
|
34
|
+
if client.me.id not in bot_order_per_chat[chat_id]:
|
35
|
+
bot_order_per_chat[chat_id].append(client.me.id)
|
36
|
+
|
37
|
+
async with chat_locks[chat_id]:
|
38
|
+
# Skip if message already responded
|
39
|
+
if msg_id in responded_messages[chat_id]:
|
40
|
+
return
|
41
|
+
|
42
|
+
# Decide which bot should respond
|
43
|
+
current_index = last_index_per_chat[chat_id]
|
44
|
+
selected_bot_id = bot_order_per_chat[chat_id][current_index]
|
45
|
+
|
46
|
+
if client.me.id == selected_bot_id:
|
47
|
+
result = await func(client, message, *args, **kwargs)
|
48
|
+
# Mark message as responded
|
49
|
+
responded_messages[chat_id].add(msg_id)
|
50
|
+
# Rotate for next message
|
51
|
+
last_index_per_chat[chat_id] = (current_index + 1) % len(bot_order_per_chat[chat_id])
|
52
|
+
return result
|
53
|
+
|
54
|
+
return wrapper
|
55
|
+
return decorator
|
d4rktg-0.8.3/VERSION.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.8.3
|
@@ -1,103 +0,0 @@
|
|
1
|
-
from functools import wraps
|
2
|
-
from pyrogram import filters
|
3
|
-
from pyrogram.types import Message
|
4
|
-
import asyncio
|
5
|
-
import re
|
6
|
-
from d4rk.Logs import setup_logger
|
7
|
-
|
8
|
-
logger = setup_logger(__name__)
|
9
|
-
|
10
|
-
last_index_per_chat = {}
|
11
|
-
bot_order_per_chat = {}
|
12
|
-
responded_messages = {}
|
13
|
-
chat_locks = {}
|
14
|
-
|
15
|
-
def round():
|
16
|
-
async def func(flt, client, message: Message):
|
17
|
-
chat_id = message.chat.id
|
18
|
-
msg_id = message.id
|
19
|
-
text = message.text or message.caption or ""
|
20
|
-
logger.info(f"RoundRobin filter check for chat_id={chat_id}, msg_id={msg_id} text='{text}'")
|
21
|
-
|
22
|
-
# Initialize per-chat structures
|
23
|
-
if chat_id not in bot_order_per_chat:
|
24
|
-
bot_order_per_chat[chat_id] = [client.me.id]
|
25
|
-
last_index_per_chat[chat_id] = 0
|
26
|
-
responded_messages[chat_id] = set()
|
27
|
-
chat_locks[chat_id] = asyncio.Lock()
|
28
|
-
else:
|
29
|
-
if client.me.id not in bot_order_per_chat[chat_id]:
|
30
|
-
bot_order_per_chat[chat_id].append(client.me.id)
|
31
|
-
|
32
|
-
async with chat_locks[chat_id]:
|
33
|
-
# Skip if already responded
|
34
|
-
if msg_id in responded_messages[chat_id]:
|
35
|
-
logger.info(f"Message {text} in chat {chat_id} already responded by {client.me.first_name}.")
|
36
|
-
logger.info(f"FILTER NOT PASSED - {client.me.first_name} should now execute the command handler")
|
37
|
-
return False
|
38
|
-
|
39
|
-
# Always respond in private chats
|
40
|
-
if message.chat.type.name.lower() == "private":
|
41
|
-
responded_messages[chat_id].add(msg_id)
|
42
|
-
logger.info(f"{client.me.first_name} Responding to private message {text} in chat {chat_id}")
|
43
|
-
logger.info(f"FILTER PASSED - {client.me.first_name} should now execute the command handler")
|
44
|
-
return True
|
45
|
-
|
46
|
-
# In groups, simple round-robin
|
47
|
-
current_index = last_index_per_chat[chat_id]
|
48
|
-
selected_bot_id = bot_order_per_chat[chat_id][current_index]
|
49
|
-
|
50
|
-
# If this bot is selected, mark message and rotate
|
51
|
-
if client.me.id == selected_bot_id:
|
52
|
-
responded_messages[chat_id].add(msg_id)
|
53
|
-
last_index_per_chat[chat_id] = (current_index + 1) % len(bot_order_per_chat[chat_id])
|
54
|
-
logger.info(f"Bot {client.me.first_name} responding to message {text} in chat {chat_id}")
|
55
|
-
logger.info(f"FILTER PASSED - {client.me.first_name} should now execute the command handler")
|
56
|
-
return True
|
57
|
-
else:
|
58
|
-
logger.info(f"Bot {client.me.first_name} not selected to respond to message {text} in chat {chat_id}")
|
59
|
-
return False
|
60
|
-
|
61
|
-
return filters.create(func)
|
62
|
-
|
63
|
-
def round_robin():
|
64
|
-
def decorator(func):
|
65
|
-
@wraps(func)
|
66
|
-
async def wrapper(client, message, *args, **kwargs):
|
67
|
-
chat_id = message.chat.id
|
68
|
-
msg_id = message.id
|
69
|
-
|
70
|
-
# Private chats: all bots respond
|
71
|
-
if message.chat.type.name.lower() == "private":
|
72
|
-
return await func(client, message, *args, **kwargs)
|
73
|
-
|
74
|
-
# Initialize tracking for this chat
|
75
|
-
if chat_id not in bot_order_per_chat:
|
76
|
-
bot_order_per_chat[chat_id] = [client.me.id]
|
77
|
-
last_index_per_chat[chat_id] = 0
|
78
|
-
responded_messages[chat_id] = set()
|
79
|
-
chat_locks[chat_id] = asyncio.Lock()
|
80
|
-
|
81
|
-
# Add new bot if not in the chat
|
82
|
-
if client.me.id not in bot_order_per_chat[chat_id]:
|
83
|
-
bot_order_per_chat[chat_id].append(client.me.id)
|
84
|
-
|
85
|
-
async with chat_locks[chat_id]:
|
86
|
-
# Skip if message already responded
|
87
|
-
if msg_id in responded_messages[chat_id]:
|
88
|
-
return
|
89
|
-
|
90
|
-
# Decide which bot should respond
|
91
|
-
current_index = last_index_per_chat[chat_id]
|
92
|
-
selected_bot_id = bot_order_per_chat[chat_id][current_index]
|
93
|
-
|
94
|
-
if client.me.id == selected_bot_id:
|
95
|
-
result = await func(client, message, *args, **kwargs)
|
96
|
-
# Mark message as responded
|
97
|
-
responded_messages[chat_id].add(msg_id)
|
98
|
-
# Rotate for next message
|
99
|
-
last_index_per_chat[chat_id] = (current_index + 1) % len(bot_order_per_chat[chat_id])
|
100
|
-
return result
|
101
|
-
|
102
|
-
return wrapper
|
103
|
-
return decorator
|
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
|
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
|