Merge pull request #6 from NoiTheCat/fixes/no-bot-updates

Prevent logging and reporting of bot messages
This commit is contained in:
Noi 2023-11-16 09:12:40 -08:00 committed by GitHub
commit 0bc04a20d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -13,6 +13,7 @@ internal partial class ModLogs {
private async Task HandleDelete(Cacheable<IMessage, ulong> argMsg, Cacheable<IMessageChannel, ulong> argChannel) {
const int MaxPreviewLength = 750;
if (argChannel.Value is not SocketTextChannel channel) return;
var conf = GetGuildState<ModuleConfig>(channel.Guild.Id);
if ((conf?.LogMessageDeletions ?? false) == false) return;
var reportChannel = conf?.ReportingChannel?.FindChannelIn(channel.Guild, true);
@ -71,6 +72,7 @@ internal partial class ModLogs {
var channel = (SocketTextChannel)newMsg.Channel;
var conf = GetGuildState<ModuleConfig>(channel.Guild.Id);
if (newMsg.Author.IsBot || newMsg.Author.IsWebhook) return;
var reportChannel = conf?.ReportingChannel?.FindChannelIn(channel.Guild, true);
if (reportChannel == null) return;
if (reportChannel.Id == channel.Id) {

View file

@ -17,13 +17,14 @@ class MessageCachingSubservice {
// This event is fired also when a link preview embed is added to a message. In those situations, the message's edited timestamp
// remains null, in addition to having other unusual and unexpected properties. We are not interested in these.
if (!arg2.EditedTimestamp.HasValue) return Task.CompletedTask;
if (arg2.Author.IsBot || arg2.Author.IsWebhook) return Task.CompletedTask; // we don't log these anyway, so don't pass them on
return AddOrUpdateCacheItemAsync(arg2, true);
}
private async Task AddOrUpdateCacheItemAsync(SocketMessage arg, bool isUpdate) {
//if (!Common.Utilities.IsValidUserMessage(arg, out _)) return;
if (arg.Channel is not SocketTextChannel) return;
if (arg.Author.IsWebhook) return; // do get bot messages, don't get webhooks
if (arg.Author.IsBot || arg.Author.IsWebhook) return; // do not get messages from an automated source
if (((IMessage)arg).Type != MessageType.Default) return;
if (arg is SocketSystemMessage) return;