Compare commits

..

No commits in common. "96ba32b610648aa3a45a6beac0ad58e7dcf1b046" and "d83463d27a030607401808d51a810a90cb633889" have entirely different histories.

3 changed files with 5 additions and 49 deletions

37
bot.py
View file

@ -2,7 +2,7 @@ import simplematrixbotlib as botLibrary
import json
import fetch
version = "0.2.0"
version = "0.1.5"
print("Imag/quotes bot version " + version)
print("Loading config…")
@ -73,45 +73,16 @@ async def make_choice(room, message):
id = match.args()
id = str(id[1])
quoteImage = fetch.fetchQuote(id)
quoteData = fetch.fetchQuoteData(id)
def formatData(data):
dataToFormat = data
created = str(data['created'])
description = str(data['desc'])
imageid = str(data['iid'])
ocr = str(data['ocr'])
score = str(data['score'])
return created, description, imageid, ocr, score
if debugMode == False:
created, description, imageid, ocr, score = formatData(quoteData)
message1 = (f"""
Created: {created}
Description: {description}
Image ID: {imageid}
OCR (Tesseract): {ocr}
Rating: {score}
""")
pass
else:
created, description, imageid, ocr, score = formatData(quoteData)
message1 = (f"""
Created: {created}
Description: {description}
Image ID: {imageid}
OCR (Tesseract): {ocr}
Rating: {score}
""")
message2 = (f"""
message = (f"""
Command recived (DEBUG).
(We're supposed to fetch quote number {id} now.)
""")
if debugMode == True:
await bot.api.send_text_message(room.room_id, message2)
await bot.api.send_text_message(room.room_id, message1)
else:
await bot.api.send_text_message(room.room_id, message1)
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

BIN
error.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View file

@ -17,19 +17,4 @@ def fetchQuote(quoteId):
return filename
else:
print(f"An error occured while saving the file: {quote.status_code}")
return "error.png"
def fetchQuoteData(quoteId):
processedId = str(config['imag']['server'] + "/api/image/" + str(quoteId))
print(processedId)
quoteData = requests.get(processedId)
code = 200
if quoteData.status_code == 200:
return quoteData.json()
# print(str(json.dumps(quoteData)))
print(quoteData.json())
else:
print(f"An error occured while saving the file: {quoteData.status_code}")
return "This file probably doesn't exist."
fetchQuoteData(178)
return None