import simplematrixbotlib as botLibrary import json import fetch with open('config.json', 'r') as f: config = json.load(f) credentials = botLibrary.Creds(config['matrix']['server'], config['matrix']['userid'], config['matrix']['password']) print(credentials) bot = botLibrary.Bot(credentials) PREFIX = "!q" @bot.listener.on_message_event async def help_message(room, message): match = botLibrary.MessageMatch(room, message, bot, PREFIX) if not (match.is_not_from_this_bot() and match.prefix() and match.command("help")): return message = (f""" Help ============================ A work-in-progress Python rewrite of the original quotes bot, aiming for a mostly complete remake. {PREFIX} help - show this message {PREFIX} get - fetch a image from the defined instance {PREFIX} source - send a link to the source code """) await bot.api.send_text_message(room.room_id, message) @bot.listener.on_message_event async def make_choice(room, message): match = botLibrary.MessageMatch(room, message, bot, PREFIX) if not (match.is_not_from_this_bot() and match.prefix() and match.command("get")): return temp = True if not match.args(): temp = False else: id = match.args() id = str(id[1]) quoteImage = fetch.fetchQuote(id) message = (f""" Command recived (DEBUG). (We're supposed to fetch quote number {id} now.) """) await bot.api.send_text_message(room.room_id, message) imageMessage = (quoteImage) await bot.api.send_image_message(room.room_id, imageMessage) # https://quotes.everypizza.im/image/178 @bot.listener.on_message_event async def help_message(room, message): match = botLibrary.MessageMatch(room, message, bot, PREFIX) if not (match.is_not_from_this_bot() and match.prefix() and match.command("source")): return message = (f""" quotes-bot-python by Nyx Tutt (@n:everypizza.im) https://git.everypizza.im/n/quotes-bot-python/ """) await bot.api.send_text_message(room.room_id, message) bot.run()