Give up on ficing GIF upload.
Signed-off-by: Abdulkadir Furkan Şanlı <me@abdulocra.cy>
This commit is contained in:
parent
242c0ba362
commit
734362014c
11
main.py
11
main.py
@ -14,7 +14,7 @@ from google.auth.transport.requests import Request
|
||||
from google_auth_oauthlib.flow import InstalledAppFlow
|
||||
from googleapiclient.discovery import build
|
||||
from googleapiclient import errors
|
||||
from nio import AsyncClient, RoomMessageText, SyncResponse
|
||||
from nio import AsyncClient, RoomMessageText, SyncResponse, UploadResponse
|
||||
|
||||
DATA_DIR = os.getenv("DATA_DIR", "./")
|
||||
DB_PATH = os.path.join(DATA_DIR, "parkerbot.sqlite3")
|
||||
@ -211,9 +211,11 @@ async def message_callback(client, room, event):
|
||||
message_type="m.room.message",
|
||||
content={"msgtype": "m.text", "body": intro_message},
|
||||
)
|
||||
with open("./parker.gif", "rb") as gif_file:
|
||||
with open("./parker.gif", "rb") as gif_file: # this is broken as shit
|
||||
response = await client.upload(gif_file, content_type="image/gif")
|
||||
gif_uri = response[0]
|
||||
if isinstance(response, UploadResponse):
|
||||
print("Image was uploaded successfully to server. ")
|
||||
gif_uri = response.content_uri
|
||||
await client.room_send(
|
||||
room_id=room_id,
|
||||
message_type="m.room.message",
|
||||
@ -224,6 +226,9 @@ async def message_callback(client, room, event):
|
||||
"info": {"mimetype": "image/gif"},
|
||||
},
|
||||
)
|
||||
else:
|
||||
print(f"Failed to upload image. Failure response: {resp}")
|
||||
|
||||
|
||||
if body == "!pow" and current_time - timestamp_sec < datetime.timedelta(
|
||||
seconds=30
|
||||
|
Loading…
Reference in New Issue
Block a user