-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
39 lines (27 loc) · 1.03 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
37
38
39
from __future__ import annotations
import asyncio
import logging
from cs2posts.bot import settings
from cs2posts.bot.cs2 import CounterStrike2UpdateBot
from cs2posts.bot.spam import SpamProtector
from cs2posts.crawler import CounterStrike2Crawler
from cs2posts.db import ChatDatabase
from cs2posts.db import PostDatabase
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO
)
# set higher logging level for httpx to avoid all GET and POST requests being logged
logging.getLogger('httpx').setLevel(logging.WARNING)
def main() -> int:
cs2_update_bot = CounterStrike2UpdateBot(
crawler=CounterStrike2Crawler(),
spam_protector=SpamProtector(),
post_db=PostDatabase(settings.POST_DB_FILEPATH),
chat_db=ChatDatabase(settings.CHAT_DB_FILEPATH),
token=settings.TELEGRAM_TOKEN)
asyncio.get_event_loop().run_until_complete(
cs2_update_bot.async_init())
cs2_update_bot.run()
return 0
if __name__ == '__main__':
raise SystemExit(main())