-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (38 loc) · 1.29 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
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""The script that runs the bot."""
import logging
from configparser import ConfigParser
from telegram import ParseMode
from telegram.ext import Updater, Defaults, PicklePersistence
from bot.constants import TIMEZONE
from bot.setup import setup_dispatcher # type: ignore[attr-defined]
# Enable logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.WARNING,
# filename='abb.log',
)
logger = logging.getLogger(__name__)
def main() -> None:
"""Start the bot."""
# Read configuration values from bot.ini
config = ConfigParser()
config.read('bot.ini')
token = config['yourls-bot']['token']
admin = int(config['yourls-bot']['admins_chat_id'])
# Create the Updater and pass it your bot's token.
defaults = Defaults(
parse_mode=ParseMode.HTML,
disable_notification=True,
disable_web_page_preview=True,
tzinfo=TIMEZONE,
)
persistence = PicklePersistence(filename='abb.db', single_file=False)
updater = Updater(token, defaults=defaults, persistence=persistence)
setup_dispatcher(dispatcher=updater.dispatcher, admin=admin)
# Start the Bot
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()