1
0
Fork 0

Get ready for release

This commit is contained in:
Nyx 2025-01-31 20:35:55 -06:00
parent 212d97b42e
commit c92830f40b
2 changed files with 29 additions and 6 deletions

33
bot.py
View file

@ -2,14 +2,25 @@ import simplematrixbotlib as botLibrary
import json
import fetch
with open('config.json', 'r') as f:
config = json.load(f)
version = "0.0.0"
print("Imag/quotes bot version " + version)
print("Loading config…")
try:
with open('config.json', 'r') as f:
config = json.load(f)
print("Loaded config.")
except FileNotFoundError:
print("Config file not found. Did you read the README?")
except:
print("Something bad and unforseen happened, please report the bug to @n:everypizza.im")
print("Logging in…")
credentials = botLibrary.Creds(config['matrix']['server'], config['matrix']['userid'], config['matrix']['password'])
print(credentials)
bot = botLibrary.Bot(credentials)
PREFIX = "!q"
print("Logged in.")
print("Ready!")
@bot.listener.on_message_event
async def help_message(room, message):
match = botLibrary.MessageMatch(room, message, bot, PREFIX)
@ -24,6 +35,7 @@ async def help_message(room, message):
{PREFIX} help - show this message
{PREFIX} get - fetch a image from the defined instance
{PREFIX} source - send a link to the source code
{PREFIX} version - show the bot version
""")
await bot.api.send_text_message(room.room_id, message)
@ -64,4 +76,17 @@ async def help_message(room, message):
await bot.api.send_text_message(room.room_id, message)
@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("version")):
return
message = (f"""
quotes-bot-python version {version}
""")
await bot.api.send_text_message(room.room_id, message)
bot.run()

View file

@ -18,5 +18,3 @@ def fetchQuote(quoteId):
else:
print(f"An error occured while saving the file: {quote.status_code}")
return None
fetchQuote(34)