35 lines
795 B
Python
Executable File
35 lines
795 B
Python
Executable File
#!/usr/bin/python3 -tt
|
|
|
|
# pypy detection
|
|
from platform import python_implementation as py_imp
|
|
|
|
import sys
|
|
import logging
|
|
import concurrent.futures
|
|
import asyncio
|
|
|
|
import bot
|
|
|
|
# only use uvloop if not using pypy
|
|
if py_imp() != 'PyPy':
|
|
import uvloop
|
|
asyncio.set_event_loop_policy( uvloop.EventLoopPolicy() )
|
|
|
|
if __name__ == '__main__':
|
|
evloop = asyncio.get_event_loop()
|
|
evloop.set_default_executor( concurrent.futures.ThreadPoolExecutor( 4 ) )
|
|
|
|
# determine config filename
|
|
cfg_file = './cfg.toml'
|
|
if len( sys.argv ) > 1: cfg_file = sys.argv[1]
|
|
|
|
# initialize bot instance, takes name of a config file
|
|
bot.init( evloop, cfg_file )
|
|
|
|
try: evloop.run_forever()
|
|
except KeyboardInterrupt:
|
|
logging.log( logging.INFO, 'POOF!' )
|
|
|
|
logging.log( logging.INFO, 'Event loop stopped, goodbye...' )
|
|
|