d4rktg 0.8.2__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.
Files changed (34) hide show
  1. {d4rktg-0.8.2 → d4rktg-0.8.4}/PKG-INFO +1 -1
  2. d4rktg-0.8.4/VERSION.txt +1 -0
  3. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Models/_commands.py +4 -1
  4. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Utils/__init__.py +1 -1
  5. d4rktg-0.8.4/d4rk/Utils/_round.py +55 -0
  6. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rktg.egg-info/PKG-INFO +1 -1
  7. d4rktg-0.8.2/VERSION.txt +0 -1
  8. d4rktg-0.8.2/d4rk/Utils/_round.py +0 -103
  9. {d4rktg-0.8.2 → d4rktg-0.8.4}/MANIFEST.in +0 -0
  10. {d4rktg-0.8.2 → d4rktg-0.8.4}/README.rst +0 -0
  11. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Database/__init__.py +0 -0
  12. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Database/db.py +0 -0
  13. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Handlers/__init__.py +0 -0
  14. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Handlers/_bot.py +0 -0
  15. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Handlers/_scheduler.py +0 -0
  16. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Logs/__init__.py +0 -0
  17. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Logs/_logger.py +0 -0
  18. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Models/__init__.py +0 -0
  19. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Models/_movie_title.py +0 -0
  20. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Utils/_decorators.py +0 -0
  21. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Utils/_delete.py +0 -0
  22. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Utils/_fonts.py +0 -0
  23. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Utils/_ip.py +0 -0
  24. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Utils/_movie_parser.py +0 -0
  25. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Utils/_ractions.py +0 -0
  26. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/Utils/_terminal.py +0 -0
  27. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rk/__init__.py +0 -0
  28. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rktg.egg-info/SOURCES.txt +0 -0
  29. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rktg.egg-info/dependency_links.txt +0 -0
  30. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rktg.egg-info/requires.txt +0 -0
  31. {d4rktg-0.8.2 → d4rktg-0.8.4}/d4rktg.egg-info/top_level.txt +0 -0
  32. {d4rktg-0.8.2 → d4rktg-0.8.4}/requirements.txt +0 -0
  33. {d4rktg-0.8.2 → d4rktg-0.8.4}/setup.cfg +0 -0
  34. {d4rktg-0.8.2 → d4rktg-0.8.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d4rktg
3
- Version: 0.8.2
3
+ Version: 0.8.4
4
4
  Summary: A module for create with easy and fast
5
5
  Author: D4rkShell
6
6
  Author-email: premiumqtrst@gmail.com
@@ -0,0 +1 @@
1
+ 0.8.4
@@ -89,7 +89,10 @@ def command(command: Union[str, list], description: str,Custom_filter=None):
89
89
  "handler": func
90
90
  })
91
91
  logger.info(f"Registered command: {command} - {description}")
92
- filter = filters.command(command)
92
+ if Custom_filter:
93
+ filter = filters.command(command) & Custom_filter
94
+ else:
95
+ filter = filters.command(command)
93
96
  @Client.on_message(filter)
94
97
  @round_robin()
95
98
  @wraps(func)
@@ -5,4 +5,4 @@ from ._delete import delete
5
5
  from ._ractions import Reacts
6
6
  from ._fonts import FontMessageMixin , get_font , web_app_data
7
7
  from ._movie_parser import parser
8
- from ._round import round_robin , round
8
+ from ._round import round_robin
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: d4rktg
3
- Version: 0.8.2
3
+ Version: 0.8.4
4
4
  Summary: A module for create with easy and fast
5
5
  Author: D4rkShell
6
6
  Author-email: premiumqtrst@gmail.com
d4rktg-0.8.2/VERSION.txt DELETED
@@ -1 +0,0 @@
1
- 0.8.2
@@ -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