-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
37 lines (25 loc) · 852 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
import logging
import configparser
import signal
from telegram_server import TelegramServer
# logging
console_logging = logging.StreamHandler()
console_logging.setLevel(logging.WARNING)
logging.basicConfig(level=logging.NOTSET,
handlers=[console_logging],
format='%(asctime)23s - %(levelname)8s - %(name)25s - %(funcName)25s - %(message)s'
)
def signal_handler(sig, frame):
logging.debug('User aborted server')
def main():
logging.debug('Start program')
signal.signal(signal.SIGINT, signal_handler)
bot_config = configparser.ConfigParser()
bot_config.read('bot.config')
server = TelegramServer(token=bot_config['BOT']['TOKEN'])
server.start()
signal.pause()
server.stop()
logging.debug('Exit program')
if __name__ == '__main__':
main()