]>
us-delaporte.pagekite.me Git - matrix-goal-bot.git/blob - app.py
4 from matrix_goal_bot
.bot
import GoalBot
6 logging
.basicConfig(filename
='matrix-goal-bot.log', encoding
='utf-8', level
=logging
.DEBUG
)
7 logging
.getLogger('nio').setLevel(logging
.WARNING
)
8 logging
.getLogger('asyncio').setLevel(logging
.WARNING
)
10 logger
= logging
.getLogger(__name__
)
11 logger
.info("Starting goal bot...")
14 # How to connect to Matrix
15 kwargs
['matrix_server'] = os
.environ
.get('MATRIX_SERVER')
16 kwargs
['bot_name'] = os
.environ
.get('MATRIX_BOT')
17 kwargs
['bot_pwd'] = os
.environ
.get('MATRIX_BOT_PWD')
19 # Prefix to listen for
20 kwargs
['bot_prefix'] = os
.environ
.get('MATRIX_BOT_PREFIX', '.goal')
22 logger
.info(f
'Goal bot will connect to {kwargs["matrix_server"]} as {kwargs["bot_name"]}')
25 DATA_DIR
= os
.environ
.get('MATRIX_DATA_DIR', '')
26 DB_FILE
= os
.environ
.get('MATRIX_DB_FILE', 'goal.db')
27 kwargs
['db_file'] = os
.path
.join(DATA_DIR
, DB_FILE
)
29 logger
.info(f
'Goal bot will store data at {kwargs["db_file"]}')
32 goal_bot
= GoalBot(**kwargs
)
34 @goal_bot.bot.listener.on_message_event
35 async def do_bot_stuff(room
, message
):
36 '''Pass messages to our bot'''
37 await goal_bot
.handle_message(room
, message
)