]>
apps.delaporte.us Git - matrix-cadbury.git/blob - app.py
3 from matrix_chore_bot
.bot
import ChoreBot
4 from matrix_fridge_bot
.bot
import FridgeBot
5 from matrix_goal_bot
.bot
import GoalBot
6 from matrix_shop_bot
.bot
import shop_bot
9 # How to connect to Matrix
10 kwargs
['matrix_server'] = os
.environ
.get('MATRIX_SERVER')
11 kwargs
['bot_name'] = os
.environ
.get('MATRIX_BOT')
12 kwargs
['bot_pwd'] = os
.environ
.get('MATRIX_BOT_PWD')
14 # Prefix to listen for
17 DATA_DIR
= os
.environ
.get('MATRIX_DATA_DIR', '')
18 DB_FILE
= os
.environ
.get('CHORE_DB_FILE', 'chore.db')
19 kwargs
['db_file'] = os
.path
.join(DATA_DIR
, DB_FILE
)
20 kwargs
['bot_prefix'] = os
.environ
.get('CHORE_BOT_PREFIX', '!chore')
21 chore_bot
= ChoreBot(**kwargs
)
24 # Re-use chore_bot's inner bot for goal and shopping
28 DB_FILE
= os
.environ
.get('GOAL_DB_FILE', 'goal.db')
29 kwargs
['db_file'] = os
.path
.join(DATA_DIR
, DB_FILE
)
30 kwargs
['bot_prefix'] = os
.environ
.get('GOAL_BOT_PREFIX', '!goal')
31 goal_bot
= GoalBot(**kwargs
)
35 @bot.listener.on_message_event
36 async def do_chore_stuff(room
, message
):
37 await chore_bot
.handle_message(room
, message
)
40 @bot.listener.on_message_event
41 async def do_goal_stuff(room
, message
):
42 await goal_bot
.handle_message(room
, message
)
45 @bot.listener.on_message_event
46 async def do_shopping_stuff(room
, message
):
47 await shop_bot(room
, message
, bot
)
49 # Bot for daily school tasks, using ChoreBot source code
50 kwargs
['bot_prefix'] = os
.environ
.get('SCHOOL_BOT_PREFIX', '!school')
51 DB_FILE
= os
.environ
.get('SCHOOL_DB_FILE', 'school.db')
52 kwargs
['db_file'] = os
.path
.join(DATA_DIR
, DB_FILE
)
53 school_bot
= ChoreBot(**kwargs
)
56 @bot.listener.on_message_event
57 async def do_school_stuff(room
, message
):
58 await school_bot
.handle_message(room
, message
)