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