-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
44 lines (35 loc) · 1007 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
import asyncio
import logging
import platform
from tgram import TgBot
from tgram.types import LinkPreviewOptions
from config import TOKEN
logging.basicConfig(level=logging.INFO)
py_version = sys.version_info[:2]
os_name = platform.system()
async def main():
bot = TgBot(
TOKEN,
parse_mode="Markdown",
link_preview_options=LinkPreviewOptions(is_disabled=True),
plugins="./plugins",
retry_after=15,
)
await bot.run()
if __name__ == "__main__":
if os_name == "Linux":
import uvloop
if py_version >= (3, 11):
with asyncio.Runner(loop_factory=uvloop.new_event_loop) as runner:
runner.run(main())
else:
uvloop.install()
asyncio.run(main())
else:
try:
loop = asyncio.get_event_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(main())