Skip to content

Commit

Permalink
fixing bug if message content is none
Browse files Browse the repository at this point in the history
  • Loading branch information
Deutscher775 committed Sep 1, 2024
1 parent f859300 commit 8a3b78a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/astroidapi/sending_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def distribute(cls, endpoint, updated_json):
registered_platforms = [platform for platform in updated_json["config"]["channels"] if len(updated_json["config"]["channels"][platform]) > 0]

is_eligible = await surrealdb_handler.AttachmentProcessor.check_eligibility(endpoint)

print(f"Is eligible: {is_eligible}")
if is_eligible is True:
if len(updated_json["meta"]["message"]["attachments"]) > 0:
Expand Down Expand Up @@ -120,7 +120,10 @@ async def send_to_discord(cls, updated_json, endpoint, attachments: list = None)
await surrealdb_handler.AttachmentProcessor.update_attachment(attachment.name.split("/")[-1].split(".")[0], sentby="discord")
async with aiohttp.ClientSession() as session:
webhook_obj = nextcord.Webhook.from_url(webhook, session=session)
await webhook_obj.send(content=updated_json["meta"]["message"]["content"], avatar_url=updated_json["meta"]["message"]["author"]["avatar"], username=formatter.Format.format_username(updated_json["meta"]["message"]["author"]["name"]), files=nextcord_files)
message_content = updated_json["meta"]["message"]["content"]
if message_content is None or message_content == "" or message_content == " ":
message_content = "||attachment||"
await webhook_obj.send(content=message_content, avatar_url=updated_json["meta"]["message"]["author"]["avatar"], username=formatter.Format.format_username(updated_json["meta"]["message"]["author"]["name"]), files=nextcord_files)
await session.close()
for file in nextcord_files:
file.close()
Expand Down Expand Up @@ -154,11 +157,15 @@ async def send_to_guilded(cls, updated_json, endpoint, attachments: list = None)
file = guilded.File(attachment.name, filename=attachment.name.split("/")[-1])
guilded_files.append(file)
await surrealdb_handler.AttachmentProcessor.update_attachment(attachment.name.split("/")[-1].split(".")[0], sentby="guilded")

async with aiohttp.ClientSession() as session:
asyncio.create_task(read_handler.ReadHandler.mark_read(endpoint, "guilded"))
webhook_obj = guilded.Webhook.from_url(webhook, session=session)
try:
await webhook_obj.send(content=updated_json["meta"]["message"]["content"], avatar_url=updated_json["meta"]["message"]["author"]["avatar"], username=formatter.Format.format_username(updated_json["meta"]["message"]["author"]["name"]), files=guilded_files)
message_content = updated_json["meta"]["message"]["content"]
if message_content is None or message_content == "" or message_content == " ":
message_content = "||attachment||"
await webhook_obj.send(content=message_content, avatar_url=updated_json["meta"]["message"]["author"]["avatar"], username=formatter.Format.format_username(updated_json["meta"]["message"]["author"]["name"]), files=guilded_files)
except AttributeError:
pass
for file in guilded_files:
Expand Down

0 comments on commit 8a3b78a

Please sign in to comment.