Spaces:
Running
Running
Upload 3 files
Browse files- akn/__init__.py +14 -3
- akn/__main__.py +4 -10
- akn/clientmulti_bot.py +4 -2
akn/__init__.py
CHANGED
@@ -63,6 +63,18 @@ app = Client(
|
|
63 |
in_memory=True
|
64 |
)
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
class Randydev(Client):
|
67 |
def __init__(self, loop=None):
|
68 |
self.loop = loop or asyncio.get_event_loop()
|
@@ -93,8 +105,7 @@ class Randydev(Client):
|
|
93 |
LOGS.warning("akn stopped, Bye!")
|
94 |
if self.loop and not self.loop.is_closed():
|
95 |
self.loop.close()
|
96 |
-
|
97 |
-
bot = Randydev()
|
98 |
|
99 |
GROUP_ID = -1002290885889
|
100 |
|
@@ -115,4 +126,4 @@ async def log_detailed_error(error, where="Unknown", who="Unknown"):
|
|
115 |
f"Text code: `{text}`\n\n"
|
116 |
f"Full Traceback:\n<blockquote>{traceback_info}</blockquote>\n"
|
117 |
)
|
118 |
-
await app.send_message(GROUP_ID, formating)
|
|
|
63 |
in_memory=True
|
64 |
)
|
65 |
|
66 |
+
assistant = Client(
|
67 |
+
"akenome",
|
68 |
+
app_version="akeno latest",
|
69 |
+
api_id=API_ID,
|
70 |
+
api_hash=API_HASH,
|
71 |
+
bot_token=BOT_TOKEN,
|
72 |
+
workers=300,
|
73 |
+
plugins=dict(root="akn.manage"),
|
74 |
+
sleep_threshold=180
|
75 |
+
)
|
76 |
+
|
77 |
+
"""
|
78 |
class Randydev(Client):
|
79 |
def __init__(self, loop=None):
|
80 |
self.loop = loop or asyncio.get_event_loop()
|
|
|
105 |
LOGS.warning("akn stopped, Bye!")
|
106 |
if self.loop and not self.loop.is_closed():
|
107 |
self.loop.close()
|
108 |
+
"""
|
|
|
109 |
|
110 |
GROUP_ID = -1002290885889
|
111 |
|
|
|
126 |
f"Text code: `{text}`\n\n"
|
127 |
f"Full Traceback:\n<blockquote>{traceback_info}</blockquote>\n"
|
128 |
)
|
129 |
+
await app.send_message(GROUP_ID, formating)
|
akn/__main__.py
CHANGED
@@ -21,7 +21,7 @@ import asyncio
|
|
21 |
import logging
|
22 |
import traceback
|
23 |
from pyrogram import idle
|
24 |
-
from akn import
|
25 |
from akn.clientmulti_bot import start_user, start_magic_bot, start_gemini_bot
|
26 |
from akn.utils.logger import LOGS
|
27 |
from akn.utils.database import db
|
@@ -48,8 +48,8 @@ async def client_multi_bot():
|
|
48 |
async def only_bots():
|
49 |
try:
|
50 |
await app.start()
|
51 |
-
|
52 |
-
|
53 |
except Exception as e:
|
54 |
LOGS.error(f"Error in only_bots: {e}")
|
55 |
traceback.print_exc()
|
@@ -70,10 +70,4 @@ async def main():
|
|
70 |
LOGS.info("All tasks completed successfully!")
|
71 |
|
72 |
if __name__ == "__main__":
|
73 |
-
|
74 |
-
with closing(loop):
|
75 |
-
with suppress(asyncio.exceptions.CancelledError):
|
76 |
-
loop.run_until_complete(main())
|
77 |
-
loop.run_until_complete(asyncio.sleep(3.0))
|
78 |
-
except (KeyboardInterrupt, SystemExit):
|
79 |
-
LOGS.info("Bot and userbot instances stopped.")
|
|
|
21 |
import logging
|
22 |
import traceback
|
23 |
from pyrogram import idle
|
24 |
+
from akn import assistant, app
|
25 |
from akn.clientmulti_bot import start_user, start_magic_bot, start_gemini_bot
|
26 |
from akn.utils.logger import LOGS
|
27 |
from akn.utils.database import db
|
|
|
48 |
async def only_bots():
|
49 |
try:
|
50 |
await app.start()
|
51 |
+
await assistant.start()
|
52 |
+
LOGS.info(f"Started Assistant: {assistant.me.username}")
|
53 |
except Exception as e:
|
54 |
LOGS.error(f"Error in only_bots: {e}")
|
55 |
traceback.print_exc()
|
|
|
70 |
LOGS.info("All tasks completed successfully!")
|
71 |
|
72 |
if __name__ == "__main__":
|
73 |
+
loop.run_until_complete(main())
|
|
|
|
|
|
|
|
|
|
|
|
akn/clientmulti_bot.py
CHANGED
@@ -9,13 +9,13 @@ from pyrogram.raw.all import layer
|
|
9 |
from pyromod import listen
|
10 |
from pyrogram.handlers import MessageHandler
|
11 |
from config import API_HASH, API_ID, BOT_TOKEN
|
12 |
-
from akn import app
|
13 |
from akn.utils.database import db
|
14 |
from akn.utils.logger import LOGS
|
|
|
15 |
from akn import ids, bot_clone_id
|
16 |
from platform import python_version
|
17 |
from pyrogram import __version__ as pyrogram_version
|
18 |
-
from akn import send_log
|
19 |
|
20 |
async def start_user() -> None:
|
21 |
sessions = await db.get_all_sessions()
|
@@ -78,6 +78,7 @@ async def start_user() -> None:
|
|
78 |
async def start_magic_bot() -> None:
|
79 |
sessions = await db.get_all_magic_bot()
|
80 |
for i, data in enumerate(sessions):
|
|
|
81 |
try:
|
82 |
bot_token = data.get("bot_token")
|
83 |
client = Client(
|
@@ -100,6 +101,7 @@ async def start_magic_bot() -> None:
|
|
100 |
continue
|
101 |
except Exception as e:
|
102 |
continue
|
|
|
103 |
|
104 |
async def start_gemini_bot() -> None:
|
105 |
sessions = await db.get_all_gemini_bot()
|
|
|
9 |
from pyromod import listen
|
10 |
from pyrogram.handlers import MessageHandler
|
11 |
from config import API_HASH, API_ID, BOT_TOKEN
|
12 |
+
from akn import app, assistant
|
13 |
from akn.utils.database import db
|
14 |
from akn.utils.logger import LOGS
|
15 |
+
from akn.utils.expired_bot import watch_do_time
|
16 |
from akn import ids, bot_clone_id
|
17 |
from platform import python_version
|
18 |
from pyrogram import __version__ as pyrogram_version
|
|
|
19 |
|
20 |
async def start_user() -> None:
|
21 |
sessions = await db.get_all_sessions()
|
|
|
78 |
async def start_magic_bot() -> None:
|
79 |
sessions = await db.get_all_magic_bot()
|
80 |
for i, data in enumerate(sessions):
|
81 |
+
user_id = data.get("user_id", 0)
|
82 |
try:
|
83 |
bot_token = data.get("bot_token")
|
84 |
client = Client(
|
|
|
101 |
continue
|
102 |
except Exception as e:
|
103 |
continue
|
104 |
+
await watch_do_time(user_id, client, assistant)
|
105 |
|
106 |
async def start_gemini_bot() -> None:
|
107 |
sessions = await db.get_all_gemini_bot()
|