Compare commits
No commits in common. "212d97b42edf0d03059e0cf4a6e05cde0562aa43" and "186563a5608a23b00e6e9f33da295257fd1fa83f" have entirely different histories.
212d97b42e
...
186563a560
3 changed files with 9 additions and 17 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -165,5 +165,4 @@ cython_debug/
|
|||
*config.json
|
||||
*.kate-swp
|
||||
session.txt
|
||||
*.jpg
|
||||
|
||||
|
|
6
bot.py
6
bot.py
|
@ -40,15 +40,13 @@ async def make_choice(room, message):
|
|||
else:
|
||||
id = match.args()
|
||||
id = str(id[1])
|
||||
quoteImage = fetch.fetchQuote(id)
|
||||
quoteLink = fetch.fetchQuote(id)
|
||||
message = (f"""
|
||||
Command recived (DEBUG).
|
||||
(We're supposed to fetch quote number {id} now.)
|
||||
(We're supposed to fetch quote number {id} now, from {quoteLink}.)
|
||||
""")
|
||||
|
||||
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):
|
||||
|
|
19
fetch.py
19
fetch.py
|
@ -5,18 +5,13 @@ with open('config.json', 'r') as f:
|
|||
config = json.load(f)
|
||||
|
||||
def fetchQuote(quoteId):
|
||||
processedId = str(config['imag']['server'] + "/image/" + str(quoteId))
|
||||
print(processedId)
|
||||
quote = requests.get(processedId)
|
||||
filename = str(quoteId) + ".jpg"
|
||||
processedId = str(config['imag']['server'] + "/image/" + quoteId)
|
||||
# quote = requests.get(processedId)
|
||||
#temporary
|
||||
code = 200
|
||||
if quote.status_code == 200:
|
||||
with open(filename, "wb") as f:
|
||||
f.write(quote.content)
|
||||
print(f"File saved as {filename}")
|
||||
return filename
|
||||
if code == 200:
|
||||
# return quote.content
|
||||
return processedId
|
||||
print(processedId)
|
||||
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