@@ -59,6 +59,29 @@ export default async function (msg: Message, type: string) {
5959 if ( ! commandPrefixLess && prefix ) return ;
6060 if ( msg . fromMe && prefix ) return ;
6161
62+ /*
63+ *
64+ * Override the default function
65+ * react(reaction: string) Promise<void>
66+ */
67+ const originalReact = msg . react . bind ( msg ) ;
68+ msg . react = async ( reaction : string ) : Promise < void > => {
69+ // add delay for more
70+ // humanly like interaction
71+ const min = 2000 ;
72+ const max = 6000 ;
73+ const randomMs = Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
74+
75+ await sleep ( randomMs ) ;
76+ const isEmoji = / .* [ A - Z a - z 0 - 9 ] .* / . test ( reaction ) ;
77+
78+ if ( Math . random ( ) < 0.5 && ! isEmoji )
79+ if ( Math . random ( ) < 0.5 )
80+ await client . sendMessage ( msg . id . remote , reaction ) ;
81+ else await msg . reply ( reaction ) ;
82+ else await originalReact ( reaction ) ;
83+ } ;
84+
6285 /*
6386 *
6487 * Process msg reaction
@@ -119,6 +142,13 @@ export default async function (msg: Message, type: string) {
119142 log . info ( "Message" , lid , msg . body . slice ( 0 , 150 ) ) ;
120143 msg . body = ! bodyHasPrefix ? msg . body : msg . body . slice ( commandPrefix . length ) ;
121144
145+ /*
146+ *
147+ * Override the default function
148+ * reply(content: MessageContent,
149+ * chatId?: string,
150+ * options?: MessageSendOptions) Promise<Message>
151+ */
122152 const originalReply = msg . reply . bind ( msg ) ;
123153 msg . reply = async (
124154 content : MessageContent ,
0 commit comments