X-Git-Url: https://us-delaporte.pagekite.me/gitweb/matrix-goal-bot.git/blobdiff_plain/db82cd2db6ee851341b7cde16799b416527fc75a:/bot.py..ec5ce64bec2a57f7b884d09b663c12f3447b3809:/goals/bot.py?ds=sidebyside diff --git a/bot.py b/goals/bot.py similarity index 97% rename from bot.py rename to goals/bot.py index d57358d..9b630f8 100644 --- a/bot.py +++ b/goals/bot.py @@ -6,18 +6,19 @@ import simplematrixbotlib as botlib from goals.db import Data, pretty_print - SERVER = os.environ.get('MATRIX_SERVER') BOT_NAME = os.environ.get('GOAL_BOT') BOT_PWD = os.environ.get('GOAL_BOT_PWD') +def get_bot(): + creds = botlib.Creds(SERVER, BOT_NAME, BOT_PWD) + return botlib.Bot(creds) + DATE_FORMAT = '%Y-%m-%d' def today(): return dt.now().strftime(DATE_FORMAT) -creds = botlib.Creds(SERVER, BOT_NAME, BOT_PWD) -bot = botlib.Bot(creds) PREFIX = '!goal' logger = logging.getLogger(__name__) @@ -153,8 +154,7 @@ async def do_goal(match): return [do_goal.__doc__] -@bot.listener.on_message_event -async def goals(room, message): +async def goal_bot(room, message): match = botlib.MessageMatch(room, message, bot, PREFIX) if not match.is_not_from_this_bot() and match.prefix(): @@ -170,5 +170,3 @@ async def goals(room, message): return ['Ye cannot get ye flask.'] -bot.run() -