@@ -20,6 +20,9 @@ import { phishingSet } from "../../index";
2020import { getSetting } from "../services/settings" ;
2121import { normalize } from "../utils/url" ;
2222import { InstantDownloader } from "../utils/instantdl/downloader" ;
23+ import riddle from "../utils/riddle" ;
24+ import { checkInappropriate } from "../utils/contentChecker" ;
25+ import { prisma } from "../prisma" ;
2326
2427const regex = emojiRegex ( ) ;
2528const commandPrefix = process . env . COMMAND_PREFIX || "!" ;
@@ -114,7 +117,8 @@ export default async function (msg: Message, type: string) {
114117 Promise . resolve ( ) . then ( async ( ) => {
115118 const quoted = await msg . getQuotedMessage ( ) ;
116119 if ( ! quoted . body || isRateLimit . status ) return ;
117- await quiz ( msg , quoted ) ;
120+
121+ await Promise . all ( [ quiz ( msg , quoted ) , riddle ( msg , quoted ) ] ) ;
118122 } ) ;
119123 }
120124
@@ -226,14 +230,38 @@ export default async function (msg: Message, type: string) {
226230 options ?: MessageSendOptions ,
227231 ) : Promise < Message > => {
228232 let messageBody = typeof content === "string" ? Font ( content ) : content ;
229-
230233 log . info ( "ReplyMessage" , lid , content . toString ( ) . slice ( 0 , 150 ) ) ;
231234
232235 if ( Math . random ( ) < 0.5 )
233236 return ( await client ( ) ) . sendMessage ( msg . id . remote , messageBody , options ) ;
234237 return await originalReply ( messageBody , chatId , options ) ;
235238 } ;
236239
240+ const isInapproiateResponse = checkInappropriate ( msg . body ) ;
241+ if ( isInapproiateResponse . isInappropriate ) {
242+ const text =
243+ "You have been blocked. For more information \`terms\` & \`privacy\`." ;
244+ await Promise . all ( [
245+ originalReply ( text ) ,
246+ prisma . block . upsert ( {
247+ where : { lid } ,
248+ update : { } ,
249+ create : {
250+ lid,
251+ mode : msg . author ? "group" : "private" ,
252+ reason : `Inapproiate ${ isInapproiateResponse . words . join ( ", " ) } ` ,
253+ } ,
254+ } ) ,
255+ prisma . user . update ( {
256+ where : { lid } ,
257+ data : { points : { decrement : 100 } } ,
258+ } ) ,
259+ ] ) ;
260+
261+ log . info ( "BlockUser" , lid ) ;
262+ return ;
263+ }
264+
237265 if (
238266 / ^ ( - - ? h e l p | \b h e l p \b | - h ) $ / i. test (
239267 msg . body . trim ( ) . replace ( handler . command , "" ) . trim ( ) ,
@@ -256,23 +284,7 @@ export default async function (msg: Message, type: string) {
256284 * Execute the command handler.
257285 */
258286 try {
259- await Promise . all ( [
260- ( async ( ) => {
261- if ( msg . fromMe ) return ;
262-
263- const chat = await msg . getChat ( ) ;
264- chat . sendStateTyping ( ) ;
265- } ) ( ) ,
266-
267- handler . exec ( msg ) ,
268-
269- ( async ( ) => {
270- if ( ! msg . author ) return ;
271-
272- const user = await findOrCreateUser ( msg ) ;
273- if ( user ) await msg . react ( "✅" ) ;
274- } ) ( ) ,
275- ] ) ;
287+ await Promise . all ( [ handler . exec ( msg ) , findOrCreateUser ( msg ) ] ) ;
276288 } catch ( error : any ) {
277289 if ( error . response ) {
278290 const { status, headers } = error . response ;
0 commit comments