]>
apps.delaporte.us Git - matrix-cadbury.git/blob - app.py
3 from matrix_goal_bot
.bot
import get_bot
, goal_bot
4 from matrix_shop_bot
.bot
import shop_bot
5 from matrix_chore_bot
.bot
import ChoreBot
7 SERVER
= os
.environ
.get('MATRIX_SERVER')
8 BOT_NAME
= os
.environ
.get('MATRIX_BOT')
9 BOT_PWD
= os
.environ
.get('MATRIX_BOT_PWD')
12 # How to connect to Matrix
13 kwargs
['matrix_server'] = os
.environ
.get('MATRIX_SERVER')
14 kwargs
['bot_name'] = os
.environ
.get('MATRIX_BOT')
15 kwargs
['bot_pwd'] = os
.environ
.get('MATRIX_BOT_PWD')
17 # Prefix to listen for
20 DATA_DIR
= os
.environ
.get('MATRIX_DATA_DIR', '')
21 DB_FILE
= os
.environ
.get('CHORE_DB_FILE', 'chore.db')
22 kwargs
['db_file'] = os
.path
.join(DATA_DIR
, DB_FILE
)
24 kwargs
['bot_prefix'] = os
.environ
.get('CHORE_BOT_PREFIX', '!chore')
25 chore_bot
= ChoreBot(**kwargs
)
28 @bot.listener.on_message_event
29 async def do_chore_stuff(room
, message
):
30 await chore_bot
.handle_message(room
, message
)
32 # Re-use chore_bot's inner bot for goal and shopping
34 @bot.listener.on_message_event
35 async def do_goal_stuff(room
, message
):
36 await goal_bot(room
, message
, bot
)
38 @bot.listener.on_message_event
39 async def do_shopping_stuff(room
, message
):
40 await shop_bot(room
, message
, bot
)
42 # New bot for daily school, using ChoreBot source code
43 kwargs
['bot_prefix'] = os
.environ
.get('SCHOOL_BOT_PREFIX', '!school')
44 DB_FILE
= os
.environ
.get('SCHOOL_DB_FILE', 'school.db')
45 kwargs
['db_file'] = os
.path
.join(DATA_DIR
, DB_FILE
)
46 school_bot
= ChoreBot(**kwargs
)
49 @bot.listener.on_message_event
50 async def do_school_stuff(room
, message
):
51 await school_bot
.handle_message(room
, message
)