d4rktg 0.4.9__tar.gz → 0.5.1__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.4.9 → d4rktg-0.5.1}/PKG-INFO +1 -1
- d4rktg-0.5.1/VERSION.txt +1 -0
- d4rktg-0.5.1/d4rk/Utils/_round.py +54 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rktg.egg-info/PKG-INFO +1 -1
- d4rktg-0.4.9/VERSION.txt +0 -1
- d4rktg-0.4.9/d4rk/Utils/_round.py +0 -39
- {d4rktg-0.4.9 → d4rktg-0.5.1}/MANIFEST.in +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/README.rst +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Database/__init__.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Database/db.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Handlers/__init__.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Handlers/_bot.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Handlers/_scheduler.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Logs/__init__.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Logs/_logger.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Models/__init__.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Models/_commands.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Models/_movie_title.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Utils/__init__.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Utils/_decorators.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Utils/_delete.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Utils/_fonts.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Utils/_ip.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Utils/_movie_parser.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Utils/_ractions.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/Utils/_terminal.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rk/__init__.py +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rktg.egg-info/SOURCES.txt +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rktg.egg-info/dependency_links.txt +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rktg.egg-info/requires.txt +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/d4rktg.egg-info/top_level.txt +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/requirements.txt +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/setup.cfg +0 -0
- {d4rktg-0.4.9 → d4rktg-0.5.1}/setup.py +0 -0
d4rktg-0.5.1/VERSION.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.5.1
|
@@ -0,0 +1,54 @@
|
|
1
|
+
from functools import wraps
|
2
|
+
from pyrogram.types import Message
|
3
|
+
import asyncio
|
4
|
+
|
5
|
+
# Track last bot index per chat
|
6
|
+
last_index_per_chat = {}
|
7
|
+
# Track bot order per chat
|
8
|
+
bot_order_per_chat = {}
|
9
|
+
# Track messages already responded to: chat_id -> set of message_ids
|
10
|
+
responded_messages = {}
|
11
|
+
# Lock per chat to prevent race conditions
|
12
|
+
chat_locks = {}
|
13
|
+
|
14
|
+
def round_robin():
|
15
|
+
def decorator(func):
|
16
|
+
@wraps(func)
|
17
|
+
async def wrapper(client, message: Message, *args, **kwargs):
|
18
|
+
chat_id = message.chat.id
|
19
|
+
msg_id = message.id
|
20
|
+
|
21
|
+
# Private chats: all bots respond
|
22
|
+
if message.chat.type.name.lower() == "private":
|
23
|
+
return await func(client, message, *args, **kwargs)
|
24
|
+
|
25
|
+
# Initialize tracking for this chat
|
26
|
+
if chat_id not in bot_order_per_chat:
|
27
|
+
bot_order_per_chat[chat_id] = [client.me.id]
|
28
|
+
last_index_per_chat[chat_id] = 0
|
29
|
+
responded_messages[chat_id] = set()
|
30
|
+
chat_locks[chat_id] = asyncio.Lock()
|
31
|
+
|
32
|
+
# Add new bot if not in the chat
|
33
|
+
if client.me.id not in bot_order_per_chat[chat_id]:
|
34
|
+
bot_order_per_chat[chat_id].append(client.me.id)
|
35
|
+
|
36
|
+
async with chat_locks[chat_id]:
|
37
|
+
# Skip if message already responded
|
38
|
+
if msg_id in responded_messages[chat_id]:
|
39
|
+
return
|
40
|
+
|
41
|
+
# Decide which bot should respond
|
42
|
+
current_index = last_index_per_chat[chat_id]
|
43
|
+
selected_bot_id = bot_order_per_chat[chat_id][current_index]
|
44
|
+
|
45
|
+
if client.me.id == selected_bot_id:
|
46
|
+
result = await func(client, message, *args, **kwargs)
|
47
|
+
# Mark message as responded
|
48
|
+
responded_messages[chat_id].add(msg_id)
|
49
|
+
# Rotate for next message
|
50
|
+
last_index_per_chat[chat_id] = (current_index + 1) % len(bot_order_per_chat[chat_id])
|
51
|
+
return result
|
52
|
+
|
53
|
+
return wrapper
|
54
|
+
return decorator
|
d4rktg-0.4.9/VERSION.txt
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.4.9
|
@@ -1,39 +0,0 @@
|
|
1
|
-
from functools import wraps
|
2
|
-
from pyrogram.types import Message
|
3
|
-
|
4
|
-
# Track last bot index per chat
|
5
|
-
last_index_per_chat = {}
|
6
|
-
# Track all bot IDs dynamically
|
7
|
-
active_bot_ids = []
|
8
|
-
|
9
|
-
def round_robin():
|
10
|
-
def decorator(func):
|
11
|
-
@wraps(func)
|
12
|
-
async def wrapper(client, message: Message, *args, **kwargs):
|
13
|
-
chat_id = message.chat.id
|
14
|
-
|
15
|
-
# Private chats: all bots respond
|
16
|
-
if message.chat.type.name.lower() == "private":
|
17
|
-
return await func(client, message, *args, **kwargs)
|
18
|
-
|
19
|
-
# Add bot ID to active list dynamically
|
20
|
-
if client.me.id not in active_bot_ids:
|
21
|
-
active_bot_ids.append(client.me.id)
|
22
|
-
|
23
|
-
# Initialize last_index for this chat
|
24
|
-
if chat_id not in last_index_per_chat:
|
25
|
-
last_index_per_chat[chat_id] = 0
|
26
|
-
|
27
|
-
current_index = last_index_per_chat[chat_id]
|
28
|
-
selected_bot_id = active_bot_ids[current_index]
|
29
|
-
|
30
|
-
# Only the selected bot responds
|
31
|
-
if client.me.id == selected_bot_id:
|
32
|
-
result = await func(client, message, *args, **kwargs)
|
33
|
-
|
34
|
-
# Rotate to next bot index
|
35
|
-
last_index_per_chat[chat_id] = (current_index + 1) % len(active_bot_ids)
|
36
|
-
return result
|
37
|
-
|
38
|
-
return wrapper
|
39
|
-
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
|
File without changes
|