]>
us-delaporte.pagekite.me Git - matrix-cadbury.git/blob - app.py
72ab7a3a0ee553bc11340e71dcbe2aef0d57ce5e
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 @bot.listener.on_message_event
29 async def do_chore_stuff(room
, message
):
30 await chore_bot
.handle_message(room
, message
)
33 DB_FILE
= os
.environ
.get('GOAL_DB_FILE', 'fridge.db')
34 kwargs
['db_file'] = os
.path
.join(DATA_DIR
, DB_FILE
)
35 kwargs
['bot_prefix'] = os
.environ
.get('GOAL_BOT_PREFIX', '!fridge')
36 fridge_bot
= FridgeBot(**kwargs
)
39 @bot.listener.on_message_event
40 async def do_fridge_stuff(room
, message
):
41 await fridge_bot
.handle_message(room
, message
)
44 DB_FILE
= os
.environ
.get('GOAL_DB_FILE', 'goal.db')
45 kwargs
['db_file'] = os
.path
.join(DATA_DIR
, DB_FILE
)
46 kwargs
['bot_prefix'] = os
.environ
.get('GOAL_BOT_PREFIX', '.goal')
47 goal_bot
= GoalBot(**kwargs
)
50 @bot.listener.on_message_event
51 async def do_goal_stuff(room
, message
):
52 await goal_bot
.handle_message(room
, message
)
54 # Shop bot has not been updated to use a class object.
55 @bot.listener.on_message_event
56 async def do_shopping_stuff(room
, message
):
57 await shop_bot(room
, message
, bot
)
59 # Bot for daily school tasks, using ChoreBot source code
60 kwargs
['bot_prefix'] = os
.environ
.get('SCHOOL_BOT_PREFIX', '.school')
61 DB_FILE
= os
.environ
.get('SCHOOL_DB_FILE', 'school.db')
62 kwargs
['db_file'] = os
.path
.join(DATA_DIR
, DB_FILE
)
63 school_bot
= ChoreBot(**kwargs
)
66 @bot.listener.on_message_event
67 async def do_school_stuff(room
, message
):
68 await school_bot
.handle_message(room
, message
)