Get ready for release
This commit is contained in:
parent
212d97b42e
commit
c92830f40b
2 changed files with 29 additions and 6 deletions
29
bot.py
29
bot.py
|
@ -2,14 +2,25 @@ import simplematrixbotlib as botLibrary
|
|||
import json
|
||||
import fetch
|
||||
|
||||
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()
|
||||
|
|
2
fetch.py
2
fetch.py
|
@ -18,5 +18,3 @@ def fetchQuote(quoteId):
|
|||
else:
|
||||
print(f"An error occured while saving the file: {quote.status_code}")
|
||||
return None
|
||||
|
||||
fetchQuote(34)
|
||||
|
|
Loading…
Add table
Reference in a new issue