-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (29 loc) · 1 KB
/
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
import asyncio
import logging as log
import os
from pyrogram import Client, compose
# noinspection PyUnresolvedReferences
import essential
from app import handlers, CallbackQuery
from app.dependencies import Postgresql, run_sequence
from config import settings
async def main():
client = Client(
name="magic-money", api_id=settings().TG_API_ID, api_hash=settings().TG_API_HASH,
bot_token=settings().TG_BOT_TOKEN, workers=min(32, (os.cpu_count() or 1) + 4),
test_mode=~settings().production + 2, in_memory=~settings().production + 2
)
print(asyncio.get_event_loop())
async with Postgresql() as db:
# noinspection PyPep8Naming
cbQuery = CallbackQuery(client=client, db=db)
# noinspection PyPep8Naming
log.debug("Entered mainloop")
await run_sequence(
handlers.init(
client=client, cbQuery=cbQuery, db=db
),
compose([client]),
)
if __name__ == "__main__":
asyncio.run(main())