@@ -16,6 +16,7 @@ import { errors } from "../utils/data";
1616import emojiRegex from "emoji-regex" ;
1717import { funD , happyEE , sadEE , loveEE } from "../../data/reaction" ;
1818import { containsAny } from "../utils/string" ;
19+ import { checkMessage } from "../utils/phishtank" ;
1920
2021const regex = emojiRegex ( ) ;
2122const commandPrefix = process . env . COMMAND_PREFIX || "!" ;
@@ -53,13 +54,35 @@ export default async function (msg: Message, type: string) {
5354 . replace ( / [ \u0300 - \u036f \u00b4 \u0060 \u005e \u007e ] / g, "" )
5455 . trim ( ) ;
5556
57+ /*
58+ *
59+ * Check for scam urls
60+ */
61+
62+ Promise . resolve ( ) . then ( async ( ) => {
63+ const spamUrls = checkMessage ( msg . body ) ;
64+
65+ if ( spamUrls . length == 0 ) return ;
66+
67+ const text = `
68+ \`Phishing Alert\`
69+
70+ We've found that this url(s): \`${ spamUrls . join ( ", " ) } \`
71+ to be phishing site/page.
72+ Proceed with caution.
73+ ` ;
74+ await msg . reply ( text ) ;
75+ } ) ;
76+
5677 /*
5778 *
5879 * Quiz command validation
5980 */
6081 if ( msg . hasQuotedMsg ) {
61- const quoted = await msg . getQuotedMessage ( ) ;
62- if ( await quiz ( msg , quoted ) ) return ;
82+ Promise . resolve ( ) . then ( async ( ) => {
83+ const quoted = await msg . getQuotedMessage ( ) ;
84+ await quiz ( msg , quoted ) ;
85+ } ) ;
6386 }
6487
6588 const prefix = ! msg . body . startsWith ( commandPrefix ) ;
@@ -99,22 +122,26 @@ export default async function (msg: Message, type: string) {
99122 *
100123 * Process msg reaction
101124 */
102- if ( ! msg . fromMe ) {
103- const emojis = [ ...new Set ( [ ...msg . body . matchAll ( regex ) ] . map ( ( m ) => m [ 0 ] ) ) ] ;
104- if ( emojis . length > 0 ) {
105- const react = emojis [ Math . floor ( Math . random ( ) * emojis . length ) ] ;
106-
107- await msg . react ( react ) ;
108- } else if ( containsAny ( msg . body , funD ) ) {
109- await msg . react ( "🤣" ) ;
110- } else if ( containsAny ( msg . body , happyEE ) ) {
111- await msg . reply ( funD [ Math . floor ( Math . random ( ) * funD . length ) ] ) ;
112- } else if ( containsAny ( msg . body , sadEE ) ) {
113- await msg . react ( "😭" ) ;
114- } else if ( containsAny ( msg . body , loveEE ) ) {
115- await msg . react ( "❤️" ) ;
125+ Promise . resolve ( ) . then ( async ( ) => {
126+ if ( ! msg . fromMe ) {
127+ const emojis = [
128+ ...new Set ( [ ...msg . body . matchAll ( regex ) ] . map ( ( m ) => m [ 0 ] ) ) ,
129+ ] ;
130+ if ( emojis . length > 0 ) {
131+ const react = emojis [ Math . floor ( Math . random ( ) * emojis . length ) ] ;
132+
133+ await msg . react ( react ) ;
134+ } else if ( containsAny ( msg . body , funD ) ) {
135+ await msg . react ( "🤣" ) ;
136+ } else if ( containsAny ( msg . body , happyEE ) ) {
137+ await msg . reply ( funD [ Math . floor ( Math . random ( ) * funD . length ) ] ) ;
138+ } else if ( containsAny ( msg . body , sadEE ) ) {
139+ await msg . react ( "😭" ) ;
140+ } else if ( containsAny ( msg . body , loveEE ) ) {
141+ await msg . react ( "❤️" ) ;
142+ }
116143 }
117- }
144+ } ) ;
118145
119146 /*
120147 * Check if the message starts with the command prefix.
0 commit comments