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
|
*config.json
|
||||||
*.kate-swp
|
*.kate-swp
|
||||||
session.txt
|
session.txt
|
||||||
*.jpg
|
|
||||||
|
|
||||||
|
|
6
bot.py
6
bot.py
|
@ -40,15 +40,13 @@ async def make_choice(room, message):
|
||||||
else:
|
else:
|
||||||
id = match.args()
|
id = match.args()
|
||||||
id = str(id[1])
|
id = str(id[1])
|
||||||
quoteImage = fetch.fetchQuote(id)
|
quoteLink = fetch.fetchQuote(id)
|
||||||
message = (f"""
|
message = (f"""
|
||||||
Command recived (DEBUG).
|
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)
|
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
|
@bot.listener.on_message_event
|
||||||
async def help_message(room, message):
|
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)
|
config = json.load(f)
|
||||||
|
|
||||||
def fetchQuote(quoteId):
|
def fetchQuote(quoteId):
|
||||||
processedId = str(config['imag']['server'] + "/image/" + str(quoteId))
|
processedId = str(config['imag']['server'] + "/image/" + quoteId)
|
||||||
print(processedId)
|
# quote = requests.get(processedId)
|
||||||
quote = requests.get(processedId)
|
#temporary
|
||||||
filename = str(quoteId) + ".jpg"
|
|
||||||
code = 200
|
code = 200
|
||||||
if quote.status_code == 200:
|
if code == 200:
|
||||||
with open(filename, "wb") as f:
|
# return quote.content
|
||||||
f.write(quote.content)
|
return processedId
|
||||||
print(f"File saved as {filename}")
|
print(processedId)
|
||||||
return filename
|
|
||||||
else:
|
else:
|
||||||
print(f"An error occured while saving the file: {quote.status_code}")
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
fetchQuote(34)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue