jsdecryptor 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/Database/database.js +446 -0
  2. package/Database/migration.js +327 -0
  3. package/Database/pgSync.js +229 -0
  4. package/Database/settingsStore.js +305 -0
  5. package/config.js +32 -0
  6. package/dave.js +3063 -0
  7. package/davelib/antibadword.js +278 -0
  8. package/davelib/antilink.js +88 -0
  9. package/davelib/antilinkHelper.js +48 -0
  10. package/davelib/botConfig.js +71 -0
  11. package/davelib/connect4.js +111 -0
  12. package/davelib/converter.js +89 -0
  13. package/davelib/dicegame.js +114 -0
  14. package/davelib/exif.js +138 -0
  15. package/davelib/fakeContact.js +85 -0
  16. package/davelib/fontStyles.js +237 -0
  17. package/davelib/greetings.js +47 -0
  18. package/davelib/id.js +11 -0
  19. package/davelib/index.js +577 -0
  20. package/davelib/isAdmin.js +32 -0
  21. package/davelib/isBanned.js +12 -0
  22. package/davelib/isOwner.js +15 -0
  23. package/davelib/lightweight_store.js +169 -0
  24. package/davelib/messageConfig.js +15 -0
  25. package/davelib/messageHandler.js +87 -0
  26. package/davelib/myfunc.js +379 -0
  27. package/davelib/myfunc2.js +170 -0
  28. package/davelib/reactions.js +180 -0
  29. package/davelib/server.html +563 -0
  30. package/davelib/sticker.js +208 -0
  31. package/davelib/tempCleanup.js +53 -0
  32. package/davelib/tictactoe.js +104 -0
  33. package/davelib/uploadImage.js +100 -0
  34. package/davelib/uploader.js +110 -0
  35. package/davelib/welcome.js +100 -0
  36. package/davelib/wordchain.js +121 -0
  37. package/daveset.js +16 -0
  38. package/davexcore/ai/ai.js +100 -0
  39. package/davexcore/ai/aiGpt4.js +59 -0
  40. package/davexcore/ai/aimodels.js +284 -0
  41. package/davexcore/ai/aivideo.js +31 -0
  42. package/davexcore/ai/analyze.js +233 -0
  43. package/davexcore/ai/bard.js +101 -0
  44. package/davexcore/ai/bird.js +101 -0
  45. package/davexcore/ai/blackbox.js +30 -0
  46. package/davexcore/ai/character.js +80 -0
  47. package/davexcore/ai/copilot.js +58 -0
  48. package/davexcore/ai/dalle.js +39 -0
  49. package/davexcore/ai/davex.js +50 -0
  50. package/davexcore/ai/deepseek.js +96 -0
  51. package/davexcore/ai/grok.js +67 -0
  52. package/davexcore/ai/imagine.js +89 -0
  53. package/davexcore/ai/meta.js +82 -0
  54. package/davexcore/ai/mistral.js +101 -0
  55. package/davexcore/ai/perplexity.js +95 -0
  56. package/davexcore/ai/sora.js +44 -0
  57. package/davexcore/ai/speechwriter.js +46 -0
  58. package/davexcore/ai/vision.js +244 -0
  59. package/davexcore/ai/wormgpt.js +56 -0
  60. package/davexcore/anti/antiaudio.js +106 -0
  61. package/davexcore/anti/antibadword.js +313 -0
  62. package/davexcore/anti/antibug.js +156 -0
  63. package/davexcore/anti/anticall.js +219 -0
  64. package/davexcore/anti/antichart.js +280 -0
  65. package/davexcore/anti/antidelete.js +673 -0
  66. package/davexcore/anti/antideletestatus.js +535 -0
  67. package/davexcore/anti/antidemote.js +352 -0
  68. package/davexcore/anti/antidocument.js +105 -0
  69. package/davexcore/anti/antiedit.js +410 -0
  70. package/davexcore/anti/antifiles.js +109 -0
  71. package/davexcore/anti/antigroupmention.js +206 -0
  72. package/davexcore/anti/antiimage.js +105 -0
  73. package/davexcore/anti/antikick.js +125 -0
  74. package/davexcore/anti/antilink.js +237 -0
  75. package/davexcore/anti/antimention.js +143 -0
  76. package/davexcore/anti/antipromote.js +320 -0
  77. package/davexcore/anti/antisticker.js +105 -0
  78. package/davexcore/anti/antitag.js +191 -0
  79. package/davexcore/anti/antivideo.js +105 -0
  80. package/davexcore/anti/antiviewonce.js +396 -0
  81. package/davexcore/anti/groupanticall.js +262 -0
  82. package/davexcore/anti/mention.js +242 -0
  83. package/davexcore/automation/alwaysonline.js +226 -0
  84. package/davexcore/automation/autoReadReciepts.js +96 -0
  85. package/davexcore/automation/autoread.js +104 -0
  86. package/davexcore/automation/autorecording.js +197 -0
  87. package/davexcore/automation/autostatus.js +317 -0
  88. package/davexcore/automation/autotyping.js +197 -0
  89. package/davexcore/automation/chatbot.js +444 -0
  90. package/davexcore/automation/chatmanage.js +199 -0
  91. package/davexcore/automation/devReact.js +43 -0
  92. package/davexcore/automation/goodbye.js +181 -0
  93. package/davexcore/automation/greetings.js +154 -0
  94. package/davexcore/automation/welcome.js +187 -0
  95. package/davexcore/downloads/apk.js +157 -0
  96. package/davexcore/downloads/facebook.js +94 -0
  97. package/davexcore/downloads/gitclone.js +137 -0
  98. package/davexcore/downloads/igs.js +333 -0
  99. package/davexcore/downloads/instagram.js +133 -0
  100. package/davexcore/downloads/mediafire.js +144 -0
  101. package/davexcore/downloads/pinterest.js +38 -0
  102. package/davexcore/downloads/play.js +158 -0
  103. package/davexcore/downloads/saveStatus.js +3 -0
  104. package/davexcore/downloads/song.js +135 -0
  105. package/davexcore/downloads/spotify.js +133 -0
  106. package/davexcore/downloads/tiktok.js +167 -0
  107. package/davexcore/downloads/tiktokaudio.js +158 -0
  108. package/davexcore/downloads/video.js +188 -0
  109. package/davexcore/downloads/ytdl.js +252 -0
  110. package/davexcore/downloads/ytdocplay.js +130 -0
  111. package/davexcore/downloads/ytdocvideo.js +95 -0
  112. package/davexcore/downloads/yts.js +64 -0
  113. package/davexcore/games/connect4.js +267 -0
  114. package/davexcore/games/dice.js +286 -0
  115. package/davexcore/games/eightball.js +24 -0
  116. package/davexcore/games/hangman.js +60 -0
  117. package/davexcore/games/rps.js +25 -0
  118. package/davexcore/games/ship.js +36 -0
  119. package/davexcore/games/slot.js +21 -0
  120. package/davexcore/games/tictactoe.js +263 -0
  121. package/davexcore/games/trivia.js +46 -0
  122. package/davexcore/games/wordchain.js +242 -0
  123. package/davexcore/group/addmember.js +101 -0
  124. package/davexcore/group/ban.js +63 -0
  125. package/davexcore/group/blockUnblock.js +177 -0
  126. package/davexcore/group/clear.js +196 -0
  127. package/davexcore/group/creategroup.js +43 -0
  128. package/davexcore/group/demote.js +115 -0
  129. package/davexcore/group/disappear.js +67 -0
  130. package/davexcore/group/groupinfo.js +167 -0
  131. package/davexcore/group/groupmanage.js +133 -0
  132. package/davexcore/group/hidetag.js +108 -0
  133. package/davexcore/group/joinrequests.js +145 -0
  134. package/davexcore/group/kick.js +92 -0
  135. package/davexcore/group/kickall.js +63 -0
  136. package/davexcore/group/leave.js +38 -0
  137. package/davexcore/group/linkgroup.js +63 -0
  138. package/davexcore/group/mute.js +57 -0
  139. package/davexcore/group/online.js +117 -0
  140. package/davexcore/group/pmblocker.js +65 -0
  141. package/davexcore/group/promote.js +93 -0
  142. package/davexcore/group/resetlink.js +57 -0
  143. package/davexcore/group/staff.js +99 -0
  144. package/davexcore/group/tag.js +111 -0
  145. package/davexcore/group/tagadmins.js +88 -0
  146. package/davexcore/group/tagall.js +99 -0
  147. package/davexcore/group/tagnotadmin.js +92 -0
  148. package/davexcore/group/topmembers.js +202 -0
  149. package/davexcore/group/unban.js +64 -0
  150. package/davexcore/group/unmute.js +45 -0
  151. package/davexcore/group/warn.js +83 -0
  152. package/davexcore/group/warnings.js +26 -0
  153. package/davexcore/media/anime.js +130 -0
  154. package/davexcore/media/attp.js +127 -0
  155. package/davexcore/media/design.js +52 -0
  156. package/davexcore/media/emojimix.js +105 -0
  157. package/davexcore/media/getpp.js +108 -0
  158. package/davexcore/media/image.js +87 -0
  159. package/davexcore/media/imageedit.js +329 -0
  160. package/davexcore/media/img-blur.js +70 -0
  161. package/davexcore/media/meme.js +35 -0
  162. package/davexcore/media/pies.js +53 -0
  163. package/davexcore/media/quotesticker.js +153 -0
  164. package/davexcore/media/remini.js +126 -0
  165. package/davexcore/media/removebg.js +114 -0
  166. package/davexcore/media/setpp.js +65 -0
  167. package/davexcore/media/shazam.js +251 -0
  168. package/davexcore/media/simage.js +74 -0
  169. package/davexcore/media/sticker.js +134 -0
  170. package/davexcore/media/stickercrop.js +133 -0
  171. package/davexcore/media/stickertelegram.js +133 -0
  172. package/davexcore/media/take.js +76 -0
  173. package/davexcore/media/textmaker.js +106 -0
  174. package/davexcore/media/toAudio.js +180 -0
  175. package/davexcore/media/togif.js +33 -0
  176. package/davexcore/media/toimg.js +26 -0
  177. package/davexcore/media/tomp4.js +34 -0
  178. package/davexcore/media/tostatus.js +160 -0
  179. package/davexcore/media/tts.js +47 -0
  180. package/davexcore/media/viewonce.js +59 -0
  181. package/davexcore/media/vn.js +67 -0
  182. package/davexcore/media/vv2.js +3 -0
  183. package/davexcore/media/wallpaper.js +89 -0
  184. package/davexcore/media/wasted.js +57 -0
  185. package/davexcore/misc/compliment.js +93 -0
  186. package/davexcore/misc/dare.js +47 -0
  187. package/davexcore/misc/fact.js +14 -0
  188. package/davexcore/misc/flirt.js +26 -0
  189. package/davexcore/misc/goodnight.js +33 -0
  190. package/davexcore/misc/insult.js +281 -0
  191. package/davexcore/misc/joke.js +66 -0
  192. package/davexcore/misc/misc.js +200 -0
  193. package/davexcore/misc/quote.js +22 -0
  194. package/davexcore/misc/roseday.js +24 -0
  195. package/davexcore/misc/shayari.js +62 -0
  196. package/davexcore/misc/simp.js +47 -0
  197. package/davexcore/misc/stupid.js +51 -0
  198. package/davexcore/misc/truth.js +146 -0
  199. package/davexcore/owner/alive.js +67 -0
  200. package/davexcore/owner/bio.js +49 -0
  201. package/davexcore/owner/broadcast.js +74 -0
  202. package/davexcore/owner/chanel.js +79 -0
  203. package/davexcore/owner/channelid.js +50 -0
  204. package/davexcore/owner/clearsession.js +86 -0
  205. package/davexcore/owner/help.js +649 -0
  206. package/davexcore/owner/hijack.js +69 -0
  207. package/davexcore/owner/menuManage.js +173 -0
  208. package/davexcore/owner/menuSettings.js +1 -0
  209. package/davexcore/owner/owner.js +17 -0
  210. package/davexcore/owner/pair.js +160 -0
  211. package/davexcore/owner/pinchat.js +44 -0
  212. package/davexcore/owner/ping.js +65 -0
  213. package/davexcore/owner/profilepic.js +61 -0
  214. package/davexcore/owner/resetmenuimage.js +16 -0
  215. package/davexcore/owner/setGroupStatus.js +315 -0
  216. package/davexcore/owner/setbotconfig.js +306 -0
  217. package/davexcore/owner/setfont.js +79 -0
  218. package/davexcore/owner/setowner.js +144 -0
  219. package/davexcore/owner/setprefix.js +131 -0
  220. package/davexcore/owner/settings.js +98 -0
  221. package/davexcore/owner/startupwelcome.js +94 -0
  222. package/davexcore/owner/sudo.js +138 -0
  223. package/davexcore/owner/update.js +282 -0
  224. package/davexcore/tmp/1772020249097.jpg +0 -0
  225. package/davexcore/utility/bible.js +239 -0
  226. package/davexcore/utility/cleartmp.js +107 -0
  227. package/davexcore/utility/delete.js +182 -0
  228. package/davexcore/utility/encrypt.js +99 -0
  229. package/davexcore/utility/ethicalhacking.js +108 -0
  230. package/davexcore/utility/fetch.js +127 -0
  231. package/davexcore/utility/github.js +85 -0
  232. package/davexcore/utility/google.js +79 -0
  233. package/davexcore/utility/join.js +52 -0
  234. package/davexcore/utility/lastseen.js +67 -0
  235. package/davexcore/utility/location.js +106 -0
  236. package/davexcore/utility/lyrics.js +54 -0
  237. package/davexcore/utility/movie.js +66 -0
  238. package/davexcore/utility/news.js +37 -0
  239. package/davexcore/utility/sports.js +403 -0
  240. package/davexcore/utility/ss.js +63 -0
  241. package/davexcore/utility/tinyurl.js +83 -0
  242. package/davexcore/utility/translate.js +101 -0
  243. package/davexcore/utility/url.js +112 -0
  244. package/davexcore/utility/vcf.js +84 -0
  245. package/davexcore/utility/weather.js +162 -0
  246. package/index.js +994 -0
  247. package/package.json +64 -0
@@ -0,0 +1,242 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const axios = require('axios');
4
+ const { downloadContentFromMessage } = require('@whiskeysockets/baileys');
5
+ const { getOwnerConfig, setOwnerConfig, parseToggleCommand } = require('../../Database/settingsStore');
6
+ const db = require('../../Database/database');
7
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
8
+
9
+ async function isAuthorized(sock, message) {
10
+ try {
11
+ const senderId = message.key.participant || message.key.remoteJid;
12
+ if (message.key.fromMe) return true;
13
+ return db.isSudo(senderId);
14
+ } catch {
15
+ return message.key.fromMe;
16
+ }
17
+ }
18
+
19
+ function loadState() {
20
+ try {
21
+ const config = getOwnerConfig('mention');
22
+ return config || { enabled: false, assetPath: 'assets/mention_default.webp', type: 'sticker' };
23
+ } catch {
24
+ return { enabled: false, assetPath: 'assets/mention_default.webp', type: 'sticker' };
25
+ }
26
+ }
27
+
28
+ function saveState(state) {
29
+ setOwnerConfig('mention', state);
30
+ }
31
+
32
+ async function ensureDefaultSticker(state) {
33
+ try {
34
+ const assetPath = path.join(__dirname, '..', state.assetPath);
35
+ if (state.assetPath.endsWith('mention_default.webp') && !fs.existsSync(assetPath)) {
36
+ const url = 'https://o.uguu.se/KHSyEtdc.webp';
37
+ const res = await axios.get(url, { responseType: 'arraybuffer' });
38
+ const assetsDir = path.join(__dirname, '..', 'assets');
39
+ if (!fs.existsSync(assetsDir)) {
40
+ fs.mkdirSync(assetsDir, { recursive: true });
41
+ }
42
+ fs.writeFileSync(assetPath, Buffer.from(res.data));
43
+ }
44
+ } catch (e) {
45
+ // Silently ignore - sticker download may fail on external hosts
46
+ }
47
+ }
48
+
49
+ async function handleMentionDetection(sock, chatId, message) {
50
+ try {
51
+ if (message.key?.fromMe) return;
52
+
53
+ const state = loadState();
54
+ await ensureDefaultSticker(state);
55
+ if (!state.enabled) return;
56
+
57
+ const rawId = sock.user?.id || sock.user?.jid || '';
58
+ if (!rawId) return;
59
+ const botNum = rawId.split('@')[0].split(':')[0];
60
+ const botJids = [
61
+ `${botNum}@s.whatsapp.net`,
62
+ `${botNum}@whatsapp.net`,
63
+ rawId
64
+ ];
65
+
66
+ const msg = message.message || {};
67
+ const contexts = [
68
+ msg.extendedTextMessage?.contextInfo,
69
+ msg.imageMessage?.contextInfo,
70
+ msg.videoMessage?.contextInfo,
71
+ msg.documentMessage?.contextInfo,
72
+ msg.stickerMessage?.contextInfo,
73
+ msg.buttonsResponseMessage?.contextInfo,
74
+ msg.listResponseMessage?.contextInfo
75
+ ].filter(Boolean);
76
+
77
+ let mentioned = [];
78
+ for (const c of contexts) {
79
+ if (Array.isArray(c.mentionedJid)) {
80
+ mentioned = mentioned.concat(c.mentionedJid);
81
+ }
82
+ }
83
+
84
+ if (!mentioned.length) return;
85
+ const isBotMentioned = mentioned.some(j => botJids.includes(j));
86
+ if (!isBotMentioned) return;
87
+
88
+ const assetPath = path.join(__dirname, '..', state.assetPath);
89
+ if (state.type === 'sticker' && fs.existsSync(assetPath)) {
90
+ await sock.sendMessage(chatId, { sticker: fs.readFileSync(assetPath) }, { quoted: fakeContact });
91
+ return;
92
+ }
93
+ if (fs.existsSync(assetPath)) {
94
+ const payload = {};
95
+ if (state.type === 'image') {
96
+ payload.image = fs.readFileSync(assetPath);
97
+ } else if (state.type === 'video') {
98
+ payload.video = fs.readFileSync(assetPath);
99
+ } else if (state.type === 'audio') {
100
+ payload.audio = fs.readFileSync(assetPath);
101
+ payload.ptt = true;
102
+ }
103
+ if (Object.keys(payload).length) {
104
+ await sock.sendMessage(chatId, payload, { quoted: fakeContact });
105
+ }
106
+ }
107
+ } catch (error) {
108
+ console.error('Mention detection error:', error?.message, 'Line:', error?.stack?.split('\n')[1]);
109
+ }
110
+ }
111
+
112
+ async function mentionToggleCommand(sock, chatId, message) {
113
+ try {
114
+ const senderId = message.key.participant || message.key.remoteJid;
115
+ const fake = createFakeContact(senderId);
116
+ const botName = getBotName();
117
+
118
+ if (!await isAuthorized(sock, message)) {
119
+ await sock.sendMessage(chatId, { text: `*${botName}*\nOwner only command!` }, { quoted: fake });
120
+ return;
121
+ }
122
+
123
+ const text = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
124
+ const args = text.trim().split(' ').slice(1);
125
+ const action = args[0]?.toLowerCase();
126
+
127
+ const state = loadState();
128
+
129
+ if (!action) {
130
+ const helpText = `*${botName} MENTION REPLY*\n\n` +
131
+ `Status: ${state.enabled ? 'ON' : 'OFF'}\n` +
132
+ `Type: ${state.type}\n\n` +
133
+ `*Commands:*\n` +
134
+ `.mention on - Enable\n` +
135
+ `.mention off - Disable\n` +
136
+ `.setmention - Set custom sticker/image`;
137
+ await sock.sendMessage(chatId, { text: helpText }, { quoted: fake });
138
+ return;
139
+ }
140
+
141
+ const toggle = parseToggleCommand(action);
142
+ if (toggle === 'on') {
143
+ state.enabled = true;
144
+ saveState(state);
145
+ await sock.sendMessage(chatId, { text: `*${botName}*\nMention reply ENABLED` }, { quoted: fake });
146
+ } else if (toggle === 'off') {
147
+ state.enabled = false;
148
+ saveState(state);
149
+ await sock.sendMessage(chatId, { text: `*${botName}*\nMention reply DISABLED` }, { quoted: fake });
150
+ } else {
151
+ await sock.sendMessage(chatId, { text: `*${botName}*\nUse: on or off` }, { quoted: fake });
152
+ }
153
+ } catch (error) {
154
+ console.error('Error in mention toggle:', error.message, 'Line:', error.stack?.split('\n')[1]);
155
+ }
156
+ }
157
+
158
+ async function setMentionCommand(sock, chatId, message) {
159
+ try {
160
+ const senderId = message.key.participant || message.key.remoteJid;
161
+ const fake = createFakeContact(senderId);
162
+ const botName = getBotName();
163
+
164
+ if (!await isAuthorized(sock, message)) {
165
+ await sock.sendMessage(chatId, { text: `*${botName}*\nOwner only command!` }, { quoted: fake });
166
+ return;
167
+ }
168
+
169
+ const quoted = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
170
+
171
+ if (!quoted) {
172
+ await sock.sendMessage(chatId, {
173
+ text: `*${botName}*\nReply to a sticker, image, video, or audio to set it as mention reply.`
174
+ }, { quoted: fake });
175
+ return;
176
+ }
177
+
178
+ const state = loadState();
179
+ let mediaType = null;
180
+ let mediaMessage = null;
181
+
182
+ if (quoted.stickerMessage) {
183
+ mediaType = 'sticker';
184
+ mediaMessage = quoted.stickerMessage;
185
+ } else if (quoted.imageMessage) {
186
+ mediaType = 'image';
187
+ mediaMessage = quoted.imageMessage;
188
+ } else if (quoted.videoMessage) {
189
+ mediaType = 'video';
190
+ mediaMessage = quoted.videoMessage;
191
+ } else if (quoted.audioMessage) {
192
+ mediaType = 'audio';
193
+ mediaMessage = quoted.audioMessage;
194
+ }
195
+
196
+ if (!mediaType || !mediaMessage) {
197
+ await sock.sendMessage(chatId, {
198
+ text: `*${botName}*\nUnsupported media type. Use sticker, image, video, or audio.`
199
+ }, { quoted: fake });
200
+ return;
201
+ }
202
+
203
+ try {
204
+ const stream = await downloadContentFromMessage(mediaMessage, mediaType === 'sticker' ? 'sticker' : mediaType);
205
+ let buffer = Buffer.from([]);
206
+ for await (const chunk of stream) {
207
+ buffer = Buffer.concat([buffer, chunk]);
208
+ }
209
+
210
+ const assetsDir = path.join(__dirname, '..', 'assets');
211
+ if (!fs.existsSync(assetsDir)) {
212
+ fs.mkdirSync(assetsDir, { recursive: true });
213
+ }
214
+
215
+ const ext = mediaType === 'sticker' ? 'webp' : (mediaType === 'image' ? 'jpg' : (mediaType === 'video' ? 'mp4' : 'mp3'));
216
+ const filename = `mention_custom.${ext}`;
217
+ const filePath = path.join(assetsDir, filename);
218
+ fs.writeFileSync(filePath, buffer);
219
+
220
+ state.assetPath = `assets/${filename}`;
221
+ state.type = mediaType;
222
+ state.enabled = true;
223
+ saveState(state);
224
+
225
+ await sock.sendMessage(chatId, {
226
+ text: `*${botName}*\nMention reply set to ${mediaType}!`
227
+ }, { quoted: fake });
228
+ } catch (downloadError) {
229
+ await sock.sendMessage(chatId, {
230
+ text: `*${botName}*\nFailed to download media: ${downloadError.message}`
231
+ }, { quoted: fake });
232
+ }
233
+ } catch (error) {
234
+ console.error('Error in setmention:', error.message, 'Line:', error.stack?.split('\n')[1]);
235
+ }
236
+ }
237
+
238
+ module.exports = {
239
+ handleMentionDetection,
240
+ mentionToggleCommand,
241
+ setMentionCommand
242
+ };
@@ -0,0 +1,226 @@
1
+ const { getOwnerConfig, setOwnerConfig, parseToggleCommand } = require('../../Database/settingsStore');
2
+ const db = require('../../Database/database');
3
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
4
+
5
+ let presenceInterval = null;
6
+
7
+ async function isAuthorized(sock, message) {
8
+ try {
9
+ const senderId = message.key.participant || message.key.remoteJid;
10
+ if (message.key.fromMe) return true;
11
+ return db.isSudo(senderId);
12
+ } catch {
13
+ return message.key.fromMe;
14
+ }
15
+ }
16
+
17
+ async function alwaysonlineCommand(sock, chatId, message) {
18
+ try {
19
+ const senderId = message.key.participant || message.key.remoteJid;
20
+ const fake = createFakeContact(senderId);
21
+ const botName = getBotName();
22
+
23
+ if (!await isAuthorized(sock, message)) {
24
+ return sock.sendMessage(chatId, {
25
+ text: `┌─ *${botName}* ─┐\n│\n│ Owner only command!\n│\n└─────────────┘`
26
+ }, { quoted: fake });
27
+ }
28
+
29
+ const text = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
30
+ const args = text.trim().split(/\s+/).slice(1);
31
+ const action = args[0]?.toLowerCase();
32
+
33
+ const config = getOwnerConfig('alwaysonline') || { enabled: false };
34
+
35
+ if (!action) {
36
+ const newState = !config.enabled;
37
+ if (newState) {
38
+ setOwnerConfig('alwaysonline', { enabled: true });
39
+ setOwnerConfig('alwaysoffline', { enabled: false });
40
+ startPresenceLoop(sock, 'available');
41
+ await sock.sendMessage(chatId, {
42
+ text: `┌─ *${botName}* ─┐
43
+
44
+ │ Always Online ENABLED
45
+ │ Bot will appear online
46
+
47
+ └─────────────┘`
48
+ }, { quoted: fake });
49
+ } else {
50
+ setOwnerConfig('alwaysonline', { enabled: false });
51
+ stopPresenceLoop();
52
+ await sock.sendMessage(chatId, {
53
+ text: `┌─ *${botName}* ─┐
54
+
55
+ │ Always Online DISABLED
56
+
57
+ └─────────────┘`
58
+ }, { quoted: fake });
59
+ }
60
+ return;
61
+ }
62
+
63
+ const toggle = parseToggleCommand(action);
64
+ if (toggle === 'on') {
65
+ setOwnerConfig('alwaysonline', { enabled: true });
66
+ setOwnerConfig('alwaysoffline', { enabled: false });
67
+ startPresenceLoop(sock, 'available');
68
+ await sock.sendMessage(chatId, {
69
+ text: `┌─ *${botName}* ─┐
70
+
71
+ │ Always Online ENABLED
72
+ │ Bot will appear online
73
+
74
+ └─────────────┘`
75
+ }, { quoted: fake });
76
+ } else if (toggle === 'off') {
77
+ setOwnerConfig('alwaysonline', { enabled: false });
78
+ stopPresenceLoop();
79
+ await sock.sendMessage(chatId, {
80
+ text: `┌─ *${botName}* ─┐
81
+
82
+ │ Always Online DISABLED
83
+
84
+ └─────────────┘`
85
+ }, { quoted: fake });
86
+ } else {
87
+ await sock.sendMessage(chatId, {
88
+ text: `┌─ *${botName}* ─┐
89
+
90
+ │ Status: ${config.enabled ? 'ON' : 'OFF'}
91
+
92
+ │ Commands:
93
+ │ .alwaysonline - Toggle
94
+ │ .alwaysonline on
95
+ │ .alwaysonline off
96
+
97
+ └─────────────┘`
98
+ }, { quoted: fake });
99
+ }
100
+ } catch (error) {
101
+ console.error('Error in alwaysonline:', error.message);
102
+ }
103
+ }
104
+
105
+ async function alwaysofflineCommand(sock, chatId, message) {
106
+ try {
107
+ const senderId = message.key.participant || message.key.remoteJid;
108
+ const fake = createFakeContact(senderId);
109
+ const botName = getBotName();
110
+
111
+ if (!await isAuthorized(sock, message)) {
112
+ return sock.sendMessage(chatId, {
113
+ text: `┌─ *${botName}* ─┐\n│\n│ Owner only command!\n│\n└─────────────┘`
114
+ }, { quoted: fake });
115
+ }
116
+
117
+ const text = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
118
+ const args = text.trim().split(/\s+/).slice(1);
119
+ const action = args[0]?.toLowerCase();
120
+
121
+ const config = getOwnerConfig('alwaysoffline') || { enabled: false };
122
+
123
+ if (!action) {
124
+ const newState = !config.enabled;
125
+ if (newState) {
126
+ setOwnerConfig('alwaysoffline', { enabled: true });
127
+ setOwnerConfig('alwaysonline', { enabled: false });
128
+ startPresenceLoop(sock, 'unavailable');
129
+ await sock.sendMessage(chatId, {
130
+ text: `┌─ *${botName}* ─┐
131
+
132
+ │ Always Offline ENABLED
133
+ │ Bot will appear offline
134
+
135
+ └─────────────┘`
136
+ }, { quoted: fake });
137
+ } else {
138
+ setOwnerConfig('alwaysoffline', { enabled: false });
139
+ stopPresenceLoop();
140
+ await sock.sendMessage(chatId, {
141
+ text: `┌─ *${botName}* ─┐
142
+
143
+ │ Always Offline DISABLED
144
+
145
+ └─────────────┘`
146
+ }, { quoted: fake });
147
+ }
148
+ return;
149
+ }
150
+
151
+ const toggle = parseToggleCommand(action);
152
+ if (toggle === 'on') {
153
+ setOwnerConfig('alwaysoffline', { enabled: true });
154
+ setOwnerConfig('alwaysonline', { enabled: false });
155
+ startPresenceLoop(sock, 'unavailable');
156
+ await sock.sendMessage(chatId, {
157
+ text: `┌─ *${botName}* ─┐
158
+
159
+ │ Always Offline ENABLED
160
+ │ Bot will appear offline
161
+
162
+ └─────────────┘`
163
+ }, { quoted: fake });
164
+ } else if (toggle === 'off') {
165
+ setOwnerConfig('alwaysoffline', { enabled: false });
166
+ stopPresenceLoop();
167
+ await sock.sendMessage(chatId, {
168
+ text: `┌─ *${botName}* ─┐
169
+
170
+ │ Always Offline DISABLED
171
+
172
+ └─────────────┘`
173
+ }, { quoted: fake });
174
+ } else {
175
+ await sock.sendMessage(chatId, {
176
+ text: `┌─ *${botName}* ─┐
177
+
178
+ │ Status: ${config.enabled ? 'ON' : 'OFF'}
179
+
180
+ │ Commands:
181
+ │ .alwaysoffline - Toggle
182
+ │ .alwaysoffline on
183
+ │ .alwaysoffline off
184
+
185
+ └─────────────┘`
186
+ }, { quoted: fake });
187
+ }
188
+ } catch (error) {
189
+ console.error('Error in alwaysoffline:', error.message);
190
+ }
191
+ }
192
+
193
+ function startPresenceLoop(sock, presenceType) {
194
+ stopPresenceLoop();
195
+ try { sock.sendPresenceUpdate(presenceType); } catch(e) {}
196
+ presenceInterval = setInterval(async () => {
197
+ try {
198
+ await sock.sendPresenceUpdate(presenceType);
199
+ } catch (e) {}
200
+ }, 10000);
201
+ }
202
+
203
+ function stopPresenceLoop() {
204
+ if (presenceInterval) {
205
+ clearInterval(presenceInterval);
206
+ presenceInterval = null;
207
+ }
208
+ }
209
+
210
+ function initPresenceOnConnect(sock) {
211
+ const onlineConfig = getOwnerConfig('alwaysonline') || { enabled: false };
212
+ const offlineConfig = getOwnerConfig('alwaysoffline') || { enabled: false };
213
+ if (onlineConfig.enabled) {
214
+ startPresenceLoop(sock, 'available');
215
+ } else if (offlineConfig.enabled) {
216
+ startPresenceLoop(sock, 'unavailable');
217
+ }
218
+ }
219
+
220
+ module.exports = {
221
+ alwaysonlineCommand,
222
+ alwaysofflineCommand,
223
+ initPresenceOnConnect,
224
+ startPresenceLoop,
225
+ stopPresenceLoop
226
+ };
@@ -0,0 +1,96 @@
1
+ const { getOwnerConfig, setOwnerConfig, parseToggleCommand } = require('../../Database/settingsStore');
2
+ const db = require('../../Database/database');
3
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
4
+
5
+ const DEFAULT_CONFIG = {
6
+ enabled: false,
7
+ readReceipts: 'all'
8
+ };
9
+
10
+ async function isAuthorized(sock, message) {
11
+ try {
12
+ const senderId = message.key.participant || message.key.remoteJid;
13
+ if (message.key.fromMe) return true;
14
+ return db.isSudo(senderId);
15
+ } catch {
16
+ return message.key.fromMe;
17
+ }
18
+ }
19
+
20
+ function loadConfig() {
21
+ try {
22
+ return getOwnerConfig('autoreadreceipts') || { ...DEFAULT_CONFIG };
23
+ } catch {
24
+ return { ...DEFAULT_CONFIG };
25
+ }
26
+ }
27
+
28
+ function saveConfig(config) {
29
+ setOwnerConfig('autoreadreceipts', config);
30
+ }
31
+
32
+ async function autoreadReceiptsCommand(sock, chatId, message) {
33
+ try {
34
+ const senderId = message.key.participant || message.key.remoteJid;
35
+ const fake = createFakeContact(senderId);
36
+ const botName = getBotName();
37
+
38
+ if (!await isAuthorized(sock, message)) {
39
+ return sock.sendMessage(chatId, { text: `*${botName}*\nOwner only command!` }, { quoted: fake });
40
+ }
41
+
42
+ const text = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
43
+ const args = text.trim().split(' ').slice(1);
44
+
45
+ if (!args.length) {
46
+ const config = loadConfig();
47
+ const status = `*${botName} AUTOREAD RECEIPTS*\n\n` +
48
+ `Status: ${config.enabled ? 'ON' : 'OFF'}\n` +
49
+ `Mode: ${config.readReceipts}\n\n` +
50
+ `*Commands:*\n` +
51
+ `.autoreadreceipts on - Enable\n` +
52
+ `.autoreadreceipts off - Disable\n` +
53
+ `.autoreadreceipts all - Read all\n` +
54
+ `.autoreadreceipts none - Read none`;
55
+ return sock.sendMessage(chatId, { text: status }, { quoted: fake });
56
+ }
57
+
58
+ const action = args[0].toLowerCase();
59
+ const config = loadConfig();
60
+
61
+ const toggle = parseToggleCommand(action);
62
+ if (toggle === 'on') {
63
+ config.enabled = true;
64
+ saveConfig(config);
65
+ return sock.sendMessage(chatId, { text: `*${botName}*\nAutoread receipts ENABLED` }, { quoted: fake });
66
+ } else if (toggle === 'off') {
67
+ config.enabled = false;
68
+ saveConfig(config);
69
+ return sock.sendMessage(chatId, { text: `*${botName}*\nAutoread receipts DISABLED` }, { quoted: fake });
70
+ } else if (action === 'all' || action === 'none') {
71
+ config.readReceipts = action;
72
+ saveConfig(config);
73
+ return sock.sendMessage(chatId, { text: `*${botName}*\nRead receipts mode: ${action.toUpperCase()}` }, { quoted: fake });
74
+ } else {
75
+ return sock.sendMessage(chatId, { text: `*${botName}*\nInvalid option! Use: on, off, all, none` }, { quoted: fake });
76
+ }
77
+ } catch (error) {
78
+ console.error('Error in autoreadreceipts command:', error.message, 'Line:', error.stack?.split('\n')[1]);
79
+ }
80
+ }
81
+
82
+ function isAutoreadReceiptsEnabled() {
83
+ const config = loadConfig();
84
+ return config?.enabled || false;
85
+ }
86
+
87
+ function getReadReceiptsMode() {
88
+ const config = loadConfig();
89
+ return config?.readReceipts || 'all';
90
+ }
91
+
92
+ module.exports = {
93
+ autoreadReceiptsCommand,
94
+ isAutoreadReceiptsEnabled,
95
+ getReadReceiptsMode
96
+ };
@@ -0,0 +1,104 @@
1
+ const { getOwnerConfig, setOwnerConfig, parseToggleCommand } = require('../../Database/settingsStore');
2
+ const db = require('../../Database/database');
3
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
4
+
5
+ async function isAuthorized(sock, message) {
6
+ try {
7
+ const senderId = message.key.participant || message.key.remoteJid;
8
+ if (message.key.fromMe) return true;
9
+ return db.isSudo(senderId);
10
+ } catch {
11
+ return message.key.fromMe;
12
+ }
13
+ }
14
+
15
+ async function autoreadCommand(sock, chatId, message) {
16
+ try {
17
+ const senderId = message.key.participant || message.key.remoteJid;
18
+ const fake = createFakeContact(senderId);
19
+ const botName = getBotName();
20
+
21
+ if (!await isAuthorized(sock, message)) {
22
+ await sock.sendMessage(chatId, {
23
+ text: `✦ Owner only command`
24
+ }, { quoted: fake });
25
+ return;
26
+ }
27
+
28
+ const args = message.message?.conversation?.trim().split(' ').slice(1) ||
29
+ message.message?.extendedTextMessage?.text?.trim().split(' ').slice(1) ||
30
+ [];
31
+
32
+ const config = getOwnerConfig('autoread') || { mode: 'off' };
33
+
34
+ if (args.length === 0) {
35
+ const usageText = `✦ *AUTOREAD*
36
+
37
+ Current Mode: ${config.mode}
38
+
39
+ ✦ *Commands:*
40
+ › on - Read all
41
+ › pm - PMs only
42
+ › group - Groups only
43
+ › off - Disable
44
+ › status - Show status`;
45
+
46
+ await sock.sendMessage(chatId, { text: usageText }, { quoted: fake });
47
+ return;
48
+ }
49
+
50
+ const action = args[0].toLowerCase();
51
+ let responseText = '';
52
+
53
+ if (action === 'status') {
54
+ responseText = `✦ Autoread mode: ${config.mode}`;
55
+ } else if (action === 'on' || action === 'all') {
56
+ setOwnerConfig('autoread', { mode: 'all' });
57
+ responseText = `✦ Autoread ENABLED for all messages`;
58
+ } else if (action === 'off') {
59
+ setOwnerConfig('autoread', { mode: 'off' });
60
+ responseText = `✦ Autoread DISABLED`;
61
+ } else if (action === 'pm') {
62
+ setOwnerConfig('autoread', { mode: 'pm' });
63
+ responseText = `✦ Autoread enabled for PMs only`;
64
+ } else if (action === 'group' || action === 'groups') {
65
+ setOwnerConfig('autoread', { mode: 'group' });
66
+ responseText = `✦ Autoread enabled for groups only`;
67
+ } else {
68
+ responseText = `✦ Invalid mode! Use: on, off, pm, group`;
69
+ }
70
+
71
+ await sock.sendMessage(chatId, { text: responseText }, { quoted: fake });
72
+ } catch (error) {
73
+ console.error('Error in autoread command:', error.message, 'Line:', error.stack?.split('\n')[1]);
74
+ }
75
+ }
76
+
77
+ function isAutoreadEnabled() {
78
+ const config = getOwnerConfig('autoread');
79
+ return config?.mode && config.mode !== 'off';
80
+ }
81
+
82
+ async function handleAutoread(sock, message) {
83
+ try {
84
+ const config = getOwnerConfig('autoread');
85
+ if (!config || config.mode === 'off') return;
86
+
87
+ const chatId = message.key.remoteJid;
88
+ const isGroup = chatId.endsWith('@g.us');
89
+
90
+ if (config.mode === 'all' ||
91
+ (config.mode === 'pm' && !isGroup) ||
92
+ (config.mode === 'group' && isGroup)) {
93
+ await sock.readMessages([message.key]);
94
+ }
95
+ } catch (error) {
96
+ console.error('Autoread error:', error.message, 'Line:', error.stack?.split('\n')[1]);
97
+ }
98
+ }
99
+
100
+ module.exports = {
101
+ autoreadCommand,
102
+ isAutoreadEnabled,
103
+ handleAutoread
104
+ };