randydev commited on
Commit
fc4a006
1 Parent(s): 0fafd63

Create __main__.py

Browse files
Files changed (1) hide show
  1. chatbot/__main__.py +57 -0
chatbot/__main__.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright 2020-2023 (c) Randy W @xtdevs, @xtsea
4
+ #
5
+ # from : https://github.com/TeamKillerX
6
+ # Channel : @RendyProjects
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Affero General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Affero General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Affero General Public License
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 importlib
24
+ from pyrogram import idle
25
+ import traceback
26
+
27
+ from chatbot import Randydev
28
+ from 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)
36
+ loop = asyncio.get_event_loop()
37
+
38
+ async def main():
39
+ try:
40
+ randydev = Randydev(loop=loop)
41
+ await randydev.start()
42
+ await idle()
43
+ except Exception as e:
44
+ traceback.print_exc()
45
+ LOGS.error(f"Error in main: {e}")
46
+ finally:
47
+ for task in asyncio.all_tasks():
48
+ task.cancel()
49
+
50
+ LOGS.info("All tasks completed successfully!")
51
+
52
+ if __name__ == "__main__":
53
+ install()
54
+ with closing(loop):
55
+ with suppress(asyncio.exceptions.CancelledError):
56
+ loop.run_until_complete(main())
57
+ loop.run_until_complete(asyncio.sleep(3.0))