File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { Message } from "../../types/message" ;
2+ import { saveSetting } from "../components/services/settings" ;
3+ import log from "../components/utils/log" ;
4+
5+ export const info = {
6+ command : "callreject" ,
7+ description : "Enable/disable automatically rejecting calls." ,
8+ usage : "callreject <on|off>" ,
9+ example : "callreject on" ,
10+ role : "admin" ,
11+ cooldown : 5000 ,
12+ } ;
13+
14+ export default async function ( msg : Message ) {
15+ const query = msg . body . replace ( / ^ c a l l r e j e c t \b \s * / i, "" ) . trim ( ) ;
16+ if ( query . length === 0 && ! / ( o n | o f f ) / . test ( query ) ) {
17+ await msg . reply ( "Please provide a value its either on or off." ) ;
18+ return ;
19+ }
20+
21+ await saveSetting ( "call_reject" , query ) ;
22+ await msg . reply ( `Call Reject successfuly set \`${ query } \`.` ) ;
23+ }
Original file line number Diff line number Diff line change 1+ import { Message } from "../../types/message" ;
2+ import { getAllSettings } from "../components/services/settings" ;
3+ import log from "../components/utils/log" ;
4+
5+ export const info = {
6+ command : "printsettings" ,
7+ description : "Send all settings value" ,
8+ usage : "printsettings" ,
9+ example : "printsettings" ,
10+ role : "admin" ,
11+ cooldown : 5000 ,
12+ } ;
13+
14+ export default async function ( msg : Message ) {
15+ if ( ! / ^ p r i n t s e t t i n g s / i. test ( msg . body ) ) return ;
16+
17+ const allSettings = await getAllSettings ( ) ;
18+
19+ if ( ! allSettings || Object . keys ( allSettings ) . length === 0 ) {
20+ await msg . reply ( "No settings found." ) ;
21+ return ;
22+ }
23+
24+ const formatted = Object . entries ( allSettings )
25+ . map ( ( [ name , value ] ) => `${ name } : ${ value } ` )
26+ . join ( "\n " ) ;
27+
28+ const settings = `
29+ \`Settings\`
30+
31+ ${ formatted }
32+ ` ;
33+ await msg . reply ( settings ) ;
34+ }
Original file line number Diff line number Diff line change 1+ import { Message } from "../../types/message" ;
2+ import { saveSetting } from "../components/services/settings" ;
3+ import log from "../components/utils/log" ;
4+
5+ export const info = {
6+ command : "resentedit" ,
7+ description : "Enable/disable automatically resending of edit messages." ,
8+ usage : "resentedit <on|off>" ,
9+ example : "resentedit on" ,
10+ role : "admin" ,
11+ cooldown : 5000 ,
12+ } ;
13+
14+ export default async function ( msg : Message ) {
15+ const query = msg . body . replace ( / ^ r e s e n t e d i t \b \s * / i, "" ) . trim ( ) ;
16+ if ( query . length === 0 && ! / ( o n | o f f ) / . test ( query ) ) {
17+ await msg . reply ( "Please provide a value its either on or off." ) ;
18+ return ;
19+ }
20+
21+ await saveSetting ( "resent_edit" , query ) ;
22+ await msg . reply ( `Resent Edit successfuly set \`${ query } \`.` ) ;
23+ }
Original file line number Diff line number Diff line change 1+ import { Message } from "../../types/message" ;
2+ import { saveSetting } from "../components/services/settings" ;
3+ import log from "../components/utils/log" ;
4+
5+ export const info = {
6+ command : "recentunsent" ,
7+ description : "Enable/disable automatically resending of unsend messages." ,
8+ usage : "recentunsent <on|off>" ,
9+ example : "recentunsent on" ,
10+ role : "admin" ,
11+ cooldown : 5000 ,
12+ } ;
13+
14+ export default async function ( msg : Message ) {
15+ const query = msg . body . replace ( / ^ r e c e n t u n s e n t \b \s * / i, "" ) . trim ( ) ;
16+ if ( query . length === 0 && ! / ( o n | o f f ) / . test ( query ) ) {
17+ await msg . reply ( "Please provide a value its either on or off." ) ;
18+ return ;
19+ }
20+
21+ await saveSetting ( "resent_unsent" , query ) ;
22+ await msg . reply ( `Resent Unsent successfuly set \`${ query } \`.` ) ;
23+ }
Original file line number Diff line number Diff line change 11import { Call } from "whatsapp-web.js" ;
22import log from "../utils/log" ;
33import { client } from "../client" ;
4+ import { getSetting } from "../services/settings" ;
45
56const voiceResponses = [
67 "Sorry, I can't take voice calls right now." ,
@@ -23,6 +24,8 @@ function getRandomResponse(arr: string[]) {
2324export default async function ( call : Call ) {
2425 try {
2526 if ( call . fromMe ) return ;
27+ const isCallMustReject = await getSetting ( "call_reject" ) ;
28+ if ( ! isCallMustReject || isCallMustReject == "off" ) return ;
2629
2730 await call . reject ( ) ;
2831 if ( ! call . from ) return ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { Message } from "whatsapp-web.js";
22import { getUserbyLid } from "../services/user" ;
33import { addMessage } from "../services/message" ;
44import log from "../utils/log" ;
5+ import { getSetting } from "../services/settings" ;
56
67/*
78 * TODO: Implement settings to enable/disable this event.
@@ -14,12 +15,17 @@ export default async function (
1415) {
1516 if ( msg . fromMe ) return ;
1617 const lid = ( msg . author ?? msg . from ) . split ( "@" ) [ 0 ] ;
17- // const isGroup = !!msg.author;
18- // const user = await getUserbyLid(msg.from) || "Your";
19- //
18+
19+ // log
2020 log . info ( "EditMessage" , lid , prevBody ) ;
2121 await addMessage ( msg , prevBody , "edit" ) ;
22- // await msg.reply(
23- // `${isGroup ? user : "Your"} message was edited from "${prevBody}".`
24- // );
22+
23+ const isMustResent = await getSetting ( "resent_edit" ) ;
24+ if ( ! isMustResent || isMustResent == "off" ) return ;
25+
26+ const isGroup = ! ! msg . author ;
27+ const user = ( await getUserbyLid ( msg . from ) ) || "Your" ;
28+ await msg . reply (
29+ `${ isGroup ? user : "Your" } message was edited from "${ prevBody } ".` ,
30+ ) ;
2531}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { Message } from "whatsapp-web.js";
22import { getUserbyLid } from "../services/user" ;
33import { addMessage } from "../services/message" ;
44import log from "../utils/log" ;
5+ import { getSetting } from "../services/settings" ;
56
67/*
78 * TODO: Implement settings to enable/disable this event.
@@ -10,11 +11,16 @@ import log from "../utils/log";
1011export default async function ( msg : Message , revoked_msg ?: Message ) {
1112 if ( msg . fromMe || ! revoked_msg ) return ;
1213 const lid = ( msg . author ?? msg . from ) . split ( "@" ) [ 0 ] ;
13- // const isGroup = !!msg.author;
14- // const user = (await getUserbyLid(msg.from)) || "Your";
14+ const isGroup = ! ! msg . author ;
15+
1516 log . info ( "RevokeMessage" , lid , revoked_msg ?. body ) ;
1617 await addMessage ( msg , revoked_msg ?. body , "revoke" ) ;
17- // await msg.reply(
18- // `${isGroup ? user : "Your"} message "${revoked_msg?.body}" was deleted.`
19- // );
18+
19+ const isMustResent = await getSetting ( "resent_unsent" ) ;
20+ if ( ! isMustResent || isMustResent == "off" ) return ;
21+
22+ const user = ( await getUserbyLid ( msg . from ) ) || "Your" ;
23+ await msg . reply (
24+ `${ isGroup ? user : "Your" } message "${ revoked_msg ?. body } " was deleted.`
25+ ) ;
2026}
You can’t perform that action at this time.
0 commit comments