Merge pull request #6 from NoiTheCat/fixes/no-bot-updates
Prevent logging and reporting of bot messages
This commit is contained in:
commit
0bc04a20d1
2 changed files with 4 additions and 1 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue