X-Git-Url: https://apps.delaporte.us/gitweb/matrix-chore-bot.git/blobdiff_plain/577bad16ed9bf9a1128bcffbd4aafb7c1be85f38..0e8e2296efcfab2892ec552b04e46450554fd06a:/matrix_chore_bot/bot.py diff --git a/matrix_chore_bot/bot.py b/matrix_chore_bot/bot.py index 6d0e502..7e33ade 100644 --- a/matrix_chore_bot/bot.py +++ b/matrix_chore_bot/bot.py @@ -6,24 +6,18 @@ import simplematrixbotlib as botlib from .db import Data as ChoreData - SERVER = os.environ.get('MATRIX_SERVER') BOT_NAME = os.environ.get('MATRIX_BOT') BOT_PWD = os.environ.get('MATRIX_BOT_PWD') -DATA_DIR = os.environ.get('MATRIX_DATA_DIR') - -CHORES = ChoreData(os.path.join(DATA_DIR}, 'chores.db')) -def get_bot(): - creds = botlib.Creds(SERVER, BOT_NAME, BOT_PWD) - return botlib.Bot(creds) +CHORES = ChoreData() logger = logging.getLogger(__name__) logging.basicConfig(filename='matrix-chore-bot.log', encoding='utf-8', level=logging.DEBUG) logging.getLogger('nio').setLevel(logging.WARNING) -async def chore_bot(room, message, bot): - match = botlib.MessageMatch(room, message, bot, '!chore') +async def chore_bot(room, message, bot, prefix='!chore'): + match = botlib.MessageMatch(room, message, bot, prefix) if not match.is_not_from_this_bot() and match.prefix(): return @@ -35,7 +29,7 @@ async def chore_bot(room, message, bot): await bot.api.send_text_message( room.room_id, str(line)) except Exception as ex: - line = 'Ye flask must be load bearing, or something...' + line = f'Ye flask must be load bearing, or something... {str(ex)}' await bot.api.send_text_message( room.room_id, str(line))