File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { Message } from "whatsapp-web.js" ;
22import { getUserbyLid } from "../services/user" ;
33import { addMessage } from "../services/message" ;
4+ import log from "../utils/log" ;
45
56/*
67 * TODO: Implement settings to enable/disable this event.
@@ -13,6 +14,8 @@ export default async function (
1314) {
1415 // const isGroup = !!msg.author;
1516 // const user = await getUserbyLid(msg.from) || "Your";
17+ //
18+ log . info ( "EditMessage" , prevBody ) ;
1619 await addMessage ( msg , prevBody , "edit" ) ;
1720 // await msg.reply(
1821 // `${isGroup ? user : "Your"} message was edited from "${prevBody}".`
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export default async function (notif: GroupNotification) {
1818 const name = contact . pushname || contact . name || contact . id . user ;
1919 const isSelf = contact . id . _serialized === client . info . wid . _serialized ;
2020
21- log . info ( "Group Join " , `${ name } joined the group ${ group . name } ` ) ;
21+ log . info ( "GroupJoin " , `${ name } joined the group ${ group . name } ` ) ;
2222
2323 if ( isSelf ) {
2424 await notif . reply (
@@ -40,6 +40,6 @@ export default async function (notif: GroupNotification) {
4040 await notif . reply ( getMessage ( "welcome" , `*${ newMembers . join ( ", " ) } *` ) ) ;
4141 }
4242 } catch ( err ) {
43- log . error ( "Group Join " , "Failed to process group join event:" , err ) ;
43+ log . error ( "GroupJoin " , "Failed to process group join event:" , err ) ;
4444 }
4545}
Original file line number Diff line number Diff line change @@ -16,16 +16,16 @@ export default async function (notif: GroupNotification) {
1616 const name = contact . pushname || contact . name || contact . id . user ;
1717 const isSelf = contact . id . _serialized === client . info . wid . _serialized ;
1818 if ( ! isSelf ) {
19- log . info ( "Group Leave " , `${ name } left the group ${ group . name } ` ) ;
19+ log . info ( "GroupLeave " , `${ name } left the group ${ group . name } ` ) ;
2020 leavers . push ( name ) ;
2121 } else {
22- log . info ( "Group Leave " , `the bot left the group ${ group . name } ` ) ;
22+ log . info ( "GroupLeave " , `the bot left the group ${ group . name } ` ) ;
2323 }
2424 }
2525
2626 if ( leavers . length > 0 )
2727 await notif . reply ( getMessage ( "leaving" , `*${ leavers . join ( ", " ) } *` ) ) ;
2828 } catch ( err ) {
29- log . error ( "Group Leave " , "Failed to process group leave event:" , err ) ;
29+ log . error ( "GroupLeave " , "Failed to process group leave event:" , err ) ;
3030 }
3131}
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ export default async function (msg: Message, type: string) {
7474
7575 await sleep ( randomMs ) ;
7676 const isEmoji = / .* [ A - Z a - z 0 - 9 ] .* / . test ( reaction ) ;
77+ log . info ( "AutoReact" , reaction ) ;
7778
7879 if ( Math . random ( ) < 0.1 && ! isEmoji )
7980 if ( Math . random ( ) < 0.2 )
@@ -157,6 +158,8 @@ export default async function (msg: Message, type: string) {
157158 ) : Promise < Message > => {
158159 let messageBody = typeof content === "string" ? Font ( content ) : content ;
159160
161+ log . info ( "ReplyMessage" , lid , content . toString ( ) . slice ( 0 , 150 ) ) ;
162+
160163 if ( Math . random ( ) < 0.5 )
161164 return await client . sendMessage ( msg . id . remote , messageBody , options ) ;
162165 return await originalReply ( messageBody , chatId , options ) ;
Original file line number Diff line number Diff line change 11import { Message } from "whatsapp-web.js" ;
22import { getQuizAttempts , setQuizAttemptAnswered } from "../services/quiz" ;
33import { quiz } from "../utils/data" ;
4+ import log from "../utils/log" ;
45
56const done = [
67 "Correct! 🎉" ,
@@ -56,11 +57,13 @@ export default async function (
5657 msg . reply ( done [ Math . floor ( Math . random ( ) * done . length ) ] ) ,
5758 setQuizAttemptAnswered ( msg , quoted ) ,
5859 quoted . delete ( true , true ) ,
60+ log . info ( "QuizAnswered" , "Correct" , quoted . body ) ,
5961 ] ) ;
6062 } else {
6163 await Promise . all ( [
6264 msg . reply ( wrong [ Math . floor ( Math . random ( ) * wrong . length ) ] ) ,
6365 quoted . delete ( true , true ) ,
66+ log . info ( "QuizAnswered" , "Wrong" , quoted . body ) ,
6467 ] ) ;
6568 }
6669 return true ;
Original file line number Diff line number Diff line change @@ -16,13 +16,13 @@ export default async function () {
1616
1717 await client . sendMessage ( tempData . id . remote , "Restart Finished." ) ;
1818 } catch ( err ) {
19- log . error ( "restart " , err ) ;
19+ log . error ( "Restart " , err ) ;
2020 } finally {
2121 fs . unlink ( hotReloadPath , ( err ) => {
2222 if ( err ) {
23- log . error ( "restart " , "Failed to delete restart file:" , err ) ;
23+ log . error ( "Restart " , "Failed to delete restart file:" , err ) ;
2424 } else {
25- log . info ( "restart " , "Restart file deleted successfully." ) ;
25+ log . info ( "Restart " , "Restart file deleted successfully." ) ;
2626 }
2727 } ) ;
2828 }
Original file line number Diff line number Diff line change 11import { Message } from "whatsapp-web.js" ;
22import { getUserbyLid } from "../services/user" ;
33import { addMessage } from "../services/message" ;
4+ import log from "../utils/log" ;
45
56/*
67 * TODO: Implement settings to enable/disable this event.
@@ -11,6 +12,7 @@ export default async function (msg: Message, revoked_msg?: Message) {
1112 if ( msg . timestamp < Date . now ( ) / 1000 - 10 ) return ;
1213 // const isGroup = !!msg.author;
1314 // const user = (await getUserbyLid(msg.from)) || "Your";
15+ log . info ( "RevokeMessage" , revoked_msg ?. body ) ;
1416 await addMessage ( msg , revoked_msg ?. body , "revoke" ) ;
1517 // await msg.reply(
1618 // `${isGroup ? user : "Your"} message "${revoked_msg?.body}" was deleted.`
Original file line number Diff line number Diff line change @@ -15,21 +15,21 @@ process.on("SIGINT", function () {
1515
1616process . on ( "uncaughtException" , ( err , origin ) => {
1717 log . error (
18- "Uncaught Exception " ,
18+ "UncaughtException " ,
1919 `Exception: ${ err . message } \nOrigin: ${ origin } `
2020 ) ;
2121} ) ;
2222
2323process . on ( "unhandledRejection" , ( reason , promise ) => {
24- log . error ( "Unhandled Rejection " , `Reason: ${ reason } \nPromise: ${ promise } ` ) ;
24+ log . error ( "UnhandledRejection " , `Reason: ${ reason } \nPromise: ${ promise } ` ) ;
2525} ) ;
2626
2727process . on ( "beforeExit" , ( code ) => {
28- log . info ( "Before Exit " , `Process is about to exit with code: ${ code } ` ) ;
28+ log . info ( "BeforeExit " , `Process is about to exit with code: ${ code } ` ) ;
2929} ) ;
3030
3131process . on ( "exit" , ( code ) => {
3232 console . log ( "" ) ;
3333} ) ;
3434
35- log . info ( "Process" , "Event listeners for process signals have been set up." ) ;
35+ log . info ( "Process" , "Event listeners for process signals have been set up." ) ;
You can’t perform that action at this time.
0 commit comments