Upload __main__.py
Browse files- Akeno/__main__.py +17 -12
Akeno/__main__.py
CHANGED
@@ -18,18 +18,20 @@
|
|
18 |
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
|
20 |
import asyncio
|
|
|
21 |
import logging
|
22 |
import sys
|
23 |
-
import
|
|
|
24 |
import aiohttp
|
25 |
from pyrogram import idle
|
26 |
-
|
27 |
-
from Akeno import clients
|
28 |
-
from Akeno.utils.logger import LOGS
|
29 |
from pyrogram.errors import *
|
30 |
-
from contextlib import closing, suppress
|
31 |
from uvloop import install
|
32 |
|
|
|
|
|
|
|
|
|
33 |
logging.basicConfig(level=logging.INFO)
|
34 |
logging.getLogger("pyrogram.syncer").setLevel(logging.WARNING)
|
35 |
logging.getLogger("pyrogram.client").setLevel(logging.WARNING)
|
@@ -37,25 +39,28 @@ loop = asyncio.get_event_loop()
|
|
37 |
|
38 |
async def main():
|
39 |
try:
|
|
|
40 |
for cli in clients:
|
41 |
try:
|
42 |
await cli.start()
|
43 |
ex = await cli.get_me()
|
44 |
LOGS.info(f"Started {ex.first_name}")
|
45 |
-
await cli.send_message("me", "Starting
|
|
|
|
|
|
|
|
|
46 |
except Exception as e:
|
47 |
LOGS.error(f"Error starting userbot: {e}")
|
48 |
await idle()
|
49 |
except Exception as e:
|
50 |
LOGS.error(f"Error in main: {e}")
|
51 |
finally:
|
52 |
-
await
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
for task in asyncio.all_tasks():
|
57 |
task.cancel()
|
58 |
-
|
59 |
LOGS.info("All tasks completed successfully!")
|
60 |
|
61 |
if __name__ == "__main__":
|
|
|
18 |
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
|
20 |
import asyncio
|
21 |
+
import importlib
|
22 |
import logging
|
23 |
import sys
|
24 |
+
from contextlib import closing, suppress
|
25 |
+
|
26 |
import aiohttp
|
27 |
from pyrogram import idle
|
|
|
|
|
|
|
28 |
from pyrogram.errors import *
|
|
|
29 |
from uvloop import install
|
30 |
|
31 |
+
from Akeno import aiohttpsession, clients
|
32 |
+
from Akeno.utils.logger import LOGS
|
33 |
+
from Akeno.utils.database import db
|
34 |
+
|
35 |
logging.basicConfig(level=logging.INFO)
|
36 |
logging.getLogger("pyrogram.syncer").setLevel(logging.WARNING)
|
37 |
logging.getLogger("pyrogram.client").setLevel(logging.WARNING)
|
|
|
39 |
|
40 |
async def main():
|
41 |
try:
|
42 |
+
await db.connect()
|
43 |
for cli in clients:
|
44 |
try:
|
45 |
await cli.start()
|
46 |
ex = await cli.get_me()
|
47 |
LOGS.info(f"Started {ex.first_name}")
|
48 |
+
await cli.send_message("me", "Starting Userbot")
|
49 |
+
await cli.join_chat("RendyProjects")
|
50 |
+
except UserIsBlocked:
|
51 |
+
LOGS.error("You have been blocked. Please support @xtdevs")
|
52 |
+
return
|
53 |
except Exception as e:
|
54 |
LOGS.error(f"Error starting userbot: {e}")
|
55 |
await idle()
|
56 |
except Exception as e:
|
57 |
LOGS.error(f"Error in main: {e}")
|
58 |
finally:
|
59 |
+
await aiohttpsession.close()
|
60 |
+
tasks = asyncio.all_tasks()
|
61 |
+
for task in tasks:
|
|
|
|
|
62 |
task.cancel()
|
63 |
+
await asyncio.gather(*tasks, return_exceptions=True)
|
64 |
LOGS.info("All tasks completed successfully!")
|
65 |
|
66 |
if __name__ == "__main__":
|