Skip to content

Commit

Permalink
Fix: Emote board service will check for and insert bot messages (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkriste authored Feb 24, 2024
1 parent 232a0ee commit 730843e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 0 additions & 8 deletions ClemBot.Api/ClemBot.Api.Core/Features/Messages/Bot/Create.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using ClemBot.Api.Common.Utilities;
using ClemBot.Api.Data.Contexts;
using ClemBot.Api.Data.Models;
using ClemBot.Api.Services.Caching.Channels.Models;
using ClemBot.Api.Services.Caching.Guilds.Models;
using ClemBot.Api.Services.Caching.Users.Models;
using FluentValidation;
using MediatR;
using NodaTime.Text;

namespace ClemBot.Api.Core.Features.Messages.Bot;
Expand Down
3 changes: 3 additions & 0 deletions ClemBot.Bot/bot/api/message_route.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typing as t
from datetime import datetime

from bot.api.api_client import ApiClient
from bot.api.base_route import BaseRoute
Expand All @@ -16,6 +17,7 @@ async def create_message(
guild_id: int,
author_id: int,
channel_id: int,
time: datetime,
**kwargs: t.Any,
) -> None:
json = {
Expand All @@ -26,6 +28,7 @@ async def create_message(
"GuildId": guild_id,
"UserId": author_id,
"ChannelId": channel_id,
"Time": time.strftime("%Y-%m-%dT%H:%M:%S.%f"),
}
]
}
Expand Down
14 changes: 14 additions & 0 deletions ClemBot.Bot/bot/services/emote_board_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ async def on_reaction_add(self, event: RawReactionActionEvent) -> None:

post = await self.bot.emote_board_route.get_post_from_board(guild, message, board)

# if the user is a bot, it's very likely we did not store their message in the db...
if message.author.bot:
stored_message = await self.bot.message_route.get_message(message.id)
if stored_message is None:
await self.bot.message_route.create_message(
message.id,
message.content,
guild.id,
message.author.id,
channel.id,
message.created_at,
raise_on_error=True,
)

if not post:
await self._create_post(board, message, users)
return
Expand Down

0 comments on commit 730843e

Please # to comment.