Compare commits
3 commits
cd181af11d
...
d83463d27a
Author | SHA1 | Date | |
---|---|---|---|
d83463d27a | |||
5c3f9031dc | |||
94e871556e |
2 changed files with 41 additions and 14 deletions
52
bot.py
52
bot.py
|
@ -2,7 +2,7 @@ import simplematrixbotlib as botLibrary
|
||||||
import json
|
import json
|
||||||
import fetch
|
import fetch
|
||||||
|
|
||||||
version = "0.1.0"
|
version = "0.1.5"
|
||||||
|
|
||||||
print("Imag/quotes bot version " + version)
|
print("Imag/quotes bot version " + version)
|
||||||
print("Loading config…")
|
print("Loading config…")
|
||||||
|
@ -15,6 +15,11 @@ except FileNotFoundError:
|
||||||
except:
|
except:
|
||||||
print("Something bad and unforseen happened, please report the bug to @n:everypizza.im")
|
print("Something bad and unforseen happened, please report the bug to @n:everypizza.im")
|
||||||
|
|
||||||
|
if config['bot']['debugMode'] == True:
|
||||||
|
debugMode = True
|
||||||
|
else:
|
||||||
|
debugMode = False
|
||||||
|
|
||||||
print("Logging in…")
|
print("Logging in…")
|
||||||
credentials = botLibrary.Creds(config['matrix']['server'], config['matrix']['userid'], config['matrix']['password'])
|
credentials = botLibrary.Creds(config['matrix']['server'], config['matrix']['userid'], config['matrix']['password'])
|
||||||
bot = botLibrary.Bot(credentials)
|
bot = botLibrary.Bot(credentials)
|
||||||
|
@ -27,16 +32,31 @@ async def help_message(room, message):
|
||||||
if not (match.is_not_from_this_bot() and match.prefix()
|
if not (match.is_not_from_this_bot() and match.prefix()
|
||||||
and match.command("help")):
|
and match.command("help")):
|
||||||
return
|
return
|
||||||
|
if debugMode == False:
|
||||||
|
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
|
||||||
|
{PREFIX} version - show the bot version
|
||||||
|
""")
|
||||||
|
else:
|
||||||
|
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
|
||||||
|
{PREFIX} version - show the bot version
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
NOTE: Debug mode is on. Output will be more verbose.
|
||||||
|
""")
|
||||||
|
|
||||||
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
|
|
||||||
{PREFIX} version - show the bot version
|
|
||||||
""")
|
|
||||||
|
|
||||||
await bot.api.send_text_message(room.room_id, message)
|
await bot.api.send_text_message(room.room_id, message)
|
||||||
|
|
||||||
|
@ -53,10 +73,14 @@ async def make_choice(room, message):
|
||||||
id = match.args()
|
id = match.args()
|
||||||
id = str(id[1])
|
id = str(id[1])
|
||||||
quoteImage = fetch.fetchQuote(id)
|
quoteImage = fetch.fetchQuote(id)
|
||||||
message = (f"""
|
|
||||||
Command recived (DEBUG).
|
if debugMode == False:
|
||||||
(We're supposed to fetch quote number {id} now.)
|
pass
|
||||||
""")
|
else:
|
||||||
|
message = (f"""
|
||||||
|
Command recived (DEBUG).
|
||||||
|
(We're supposed to fetch quote number {id} now.)
|
||||||
|
""")
|
||||||
|
|
||||||
await bot.api.send_text_message(room.room_id, message)
|
await bot.api.send_text_message(room.room_id, message)
|
||||||
imageMessage = (quoteImage)
|
imageMessage = (quoteImage)
|
||||||
|
|
|
@ -7,5 +7,8 @@
|
||||||
"imag":{
|
"imag":{
|
||||||
"_comment": "Don't put a slash at an end of this. That took quite a bit of running around in circles to fix.",
|
"_comment": "Don't put a slash at an end of this. That took quite a bit of running around in circles to fix.",
|
||||||
"server": "https://quotes.example.com"
|
"server": "https://quotes.example.com"
|
||||||
|
},
|
||||||
|
"bot": {
|
||||||
|
"debugMode": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue