@@ -116,6 +116,52 @@ public static async Task MessageHandlerAsync(DiscordClient client, DiscordMessag
116
116
}
117
117
public static async Task MessageHandlerAsync ( DiscordClient client , MockDiscordMessage message , DiscordChannel channel , bool isAnEdit = false , bool limitFilters = false , bool wasAutoModBlock = false )
118
118
{
119
+ // Get forwarded msg & embeds, if any, and combine with content to evaluate
120
+ // Combined as a single long string
121
+
122
+ string msgContentWithEmbedData = message . Content ;
123
+ var embeds = new List < DiscordEmbed > ( ) ;
124
+ embeds . AddRange ( message . Embeds ) ;
125
+
126
+ if ( message . MessageSnapshots is not null )
127
+ foreach ( var snapshot in message . MessageSnapshots )
128
+ {
129
+ msgContentWithEmbedData += $ " { snapshot . Message . Content } ";
130
+ embeds . AddRange ( snapshot . Message . Embeds ) ;
131
+ }
132
+
133
+ foreach ( var embed in embeds )
134
+ {
135
+ // Add any text from the embed into the content to be checked
136
+
137
+ if ( embed . Author is not null )
138
+ {
139
+ if ( embed . Author . Name is not null )
140
+ msgContentWithEmbedData += $ " { embed . Author . Name } ";
141
+
142
+ if ( embed . Author . Url is not null )
143
+ msgContentWithEmbedData += $ " { embed . Author . Url } ";
144
+ }
145
+
146
+ if ( embed . Title is not null )
147
+ msgContentWithEmbedData += $ " { embed . Title } ";
148
+
149
+ if ( embed . Url is not null )
150
+ msgContentWithEmbedData += $ " { embed . Url } ";
151
+
152
+ if ( embed . Description is not null )
153
+ msgContentWithEmbedData += $ " { embed . Description } ";
154
+
155
+ if ( embed . Footer is not null && embed . Footer . Text is not null )
156
+ msgContentWithEmbedData += $ " { embed . Footer . Text } ";
157
+
158
+ if ( embed . Fields is not null )
159
+ foreach ( var field in embed . Fields )
160
+ {
161
+ msgContentWithEmbedData += $ " { field . Name } { field . Value } ";
162
+ }
163
+ }
164
+
119
165
try
120
166
{
121
167
if ( message . Timestamp is not null && message . Timestamp . Value . Year < ( DateTime . Now . Year - 2 ) )
@@ -317,7 +363,7 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
317
363
}
318
364
else
319
365
{
320
- ( bool success , string flaggedWord ) = Checks . ListChecks . CheckForNaughtyWords ( message . Content . ToLower ( ) , listItem ) ;
366
+ ( bool success , string flaggedWord ) = Checks . ListChecks . CheckForNaughtyWords ( msgContentWithEmbedData . ToLower ( ) , listItem ) ;
321
367
if ( success )
322
368
{
323
369
if ( wasAutoModBlock )
@@ -359,7 +405,7 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
359
405
return ;
360
406
361
407
// Unapproved invites
362
- string checkedMessage = message . Content . Replace ( '\\ ' , '/' ) ;
408
+ string checkedMessage = msgContentWithEmbedData . Replace ( '\\ ' , '/' ) ;
363
409
364
410
if ( ( await GetPermLevelAsync ( member ) ) < ( ServerPermLevel ) Program . cfgjson . InviteTierRequirement && checkedMessage . Contains ( "dsc.gg/" ) ||
365
411
checkedMessage . Contains ( "invite.gg/" )
@@ -499,9 +545,9 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
499
545
return ;
500
546
501
547
// Mass emoji
502
- if ( ! Program . cfgjson . UnrestrictedEmojiChannels . Contains ( channel . Id ) && message . Content . Length >= Program . cfgjson . MassEmojiThreshold )
548
+ if ( ! Program . cfgjson . UnrestrictedEmojiChannels . Contains ( channel . Id ) && msgContentWithEmbedData . Length >= Program . cfgjson . MassEmojiThreshold )
503
549
{
504
- char [ ] tempArray = message . Content . Replace ( "🏻" , "" ) . Replace ( "🏼" , "" ) . Replace ( "🏽" , "" ) . Replace ( "🏾" , "" ) . Replace ( "🏿" , "" ) . ToCharArray ( ) ;
550
+ char [ ] tempArray = msgContentWithEmbedData . Replace ( "🏻" , "" ) . Replace ( "🏼" , "" ) . Replace ( "🏽" , "" ) . Replace ( "🏾" , "" ) . Replace ( "🏿" , "" ) . ToCharArray ( ) ;
505
551
int pos = 0 ;
506
552
foreach ( char c in tempArray )
507
553
{
@@ -613,10 +659,10 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
613
659
}
614
660
615
661
// phishing API
616
- var urlMatches = url_rx . Matches ( message . Content ) ;
662
+ var urlMatches = url_rx . Matches ( msgContentWithEmbedData ) ;
617
663
if ( urlMatches . Count > 0 && Environment . GetEnvironmentVariable ( "CLIPTOK_ANTIPHISHING_ENDPOINT" ) is not null && Environment . GetEnvironmentVariable ( "CLIPTOK_ANTIPHISHING_ENDPOINT" ) != "useyourimagination" )
618
664
{
619
- var ( phishingMatch , httpStatus , responseText , phishingResponse ) = await APIs . PhishingAPI . PhishingAPICheckAsync ( message . Content ) ;
665
+ var ( phishingMatch , httpStatus , responseText , phishingResponse ) = await APIs . PhishingAPI . PhishingAPICheckAsync ( msgContentWithEmbedData ) ;
620
666
621
667
if ( httpStatus == HttpStatusCode . OK )
622
668
{
@@ -645,7 +691,7 @@ public static async Task MessageHandlerAsync(DiscordClient client, MockDiscordMe
645
691
}
646
692
647
693
// attempted to ping @everyone/@here
648
- var msgContent = message . Content ;
694
+ var msgContent = msgContentWithEmbedData ;
649
695
foreach ( var letter in Checks . ListChecks . lookalikeAlphabetMap )
650
696
msgContent = msgContent . Replace ( letter . Key , letter . Value ) ;
651
697
if ( Program . cfgjson . EveryoneFilter && ! member . Roles . Any ( role => Program . cfgjson . EveryoneExcludedRoles . Contains ( role . Id ) ) && ! Program . cfgjson . EveryoneExcludedChannels . Contains ( channel . Id ) && ( msgContent . Contains ( "@everyone" ) || msgContent . Contains ( "@here" ) ) )
@@ -824,7 +870,7 @@ await LogChannelHelper.LogMessageAsync("messages",
824
870
}
825
871
else
826
872
{
827
- ( bool success , string flaggedWord ) = Checks . ListChecks . CheckForNaughtyWords ( message . Content . ToLower ( ) , listItem ) ;
873
+ ( bool success , string flaggedWord ) = Checks . ListChecks . CheckForNaughtyWords ( msgContentWithEmbedData . ToLower ( ) , listItem ) ;
828
874
if ( success )
829
875
{
830
876
DiscordChannel logChannel = default ;
0 commit comments