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,21 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+
3
+ async function slotCommand(sock, chatId, message) {
4
+ const fakeContact = createFakeContact(message);
5
+ const botName = getBotName();
6
+ const symbols = ['🍒', '🍋', '🍊', '🍇', '💎', '7️⃣', '🔔', '⭐'];
7
+
8
+ const s1 = symbols[Math.floor(Math.random() * symbols.length)];
9
+ const s2 = symbols[Math.floor(Math.random() * symbols.length)];
10
+ const s3 = symbols[Math.floor(Math.random() * symbols.length)];
11
+
12
+ let result;
13
+ if (s1 === s2 && s2 === s3) result = 'JACKPOT! You hit the jackpot!';
14
+ else if (s1 === s2 || s2 === s3 || s1 === s3) result = 'Nice! Two matching symbols!';
15
+ else result = 'Better luck next time!';
16
+
17
+ const text = `*${botName} SLOT MACHINE*\n\n┏━━━━━━━━━┓\n┃ ${s1} ${s2} ${s3} ┃\n┗━━━━━━━━━┛\n\n*${result}*`;
18
+ await sock.sendMessage(chatId, { text }, { quoted: fakeContact });
19
+ }
20
+
21
+ module.exports = slotCommand;
@@ -0,0 +1,263 @@
1
+ const TicTacToe = require('../../davelib/tictactoe');
2
+
3
+ const games = {};
4
+ const gameTimeouts = {};
5
+ const BOT_JID = 'bot@s.whatsapp.net';
6
+
7
+ function renderBoard(arr) {
8
+ const emojiMap = {
9
+ 'X': '❌', 'O': '⭕',
10
+ '1': '1️⃣', '2': '2️⃣', '3': '3️⃣',
11
+ '4': '4️⃣', '5': '5️⃣', '6': '6️⃣',
12
+ '7': '7️⃣', '8': '8️⃣', '9': '9️⃣',
13
+ };
14
+ const mapped = arr.map(v => emojiMap[v] || v);
15
+ return `${mapped.slice(0, 3).join('')}\n${mapped.slice(3, 6).join('')}\n${mapped.slice(6).join('')}`;
16
+ }
17
+
18
+ function clearGameTimeout(chatId) {
19
+ if (gameTimeouts[chatId]) {
20
+ clearTimeout(gameTimeouts[chatId]);
21
+ delete gameTimeouts[chatId];
22
+ }
23
+ }
24
+
25
+ function getPlayerName(jid) {
26
+ return (jid || '').split(':')[0].split('@')[0];
27
+ }
28
+
29
+ async function tictactoeCommand(sock, chatId, senderId, text, fake) {
30
+ try {
31
+ if (Object.values(games).find(room =>
32
+ room.id.startsWith('tictactoe') &&
33
+ [room.game.playerX, room.game.playerO].includes(senderId)
34
+ )) {
35
+ await sock.sendMessage(chatId, {
36
+ text: '❌ You are still in a game. Type *surrender* to quit.'
37
+ }, { quoted: fake });
38
+ return;
39
+ }
40
+
41
+ let room = Object.values(games).find(room =>
42
+ room.state === 'WAITING' && room.chatId === chatId &&
43
+ (text ? room.name === text : true)
44
+ );
45
+
46
+ if (room) {
47
+ room.game.playerO = senderId;
48
+ room.state = 'PLAYING';
49
+ clearGameTimeout(chatId);
50
+
51
+ const arr = room.game.render();
52
+ const boardStr = renderBoard(arr);
53
+
54
+ await sock.sendMessage(chatId, {
55
+ text: `🎮 *TIC TAC TOE - Game Started!*\n\nPlayer ❌: @${getPlayerName(room.game.playerX)}\nPlayer ⭕: @${getPlayerName(senderId)}\n\nWaiting for @${getPlayerName(room.game.currentTurn)} to play...\n\n${boardStr}\n\n_Type a number (1-9) to place your symbol_\n_Type *surrender* to give up_`,
56
+ mentions: [room.game.playerX, senderId, room.game.currentTurn]
57
+ });
58
+ } else {
59
+ room = {
60
+ id: 'tictactoe-' + (+new Date),
61
+ chatId: chatId,
62
+ game: new TicTacToe(senderId, 'o'),
63
+ state: 'WAITING',
64
+ isAI: false,
65
+ };
66
+ if (text) room.name = text;
67
+
68
+ await sock.sendMessage(chatId, {
69
+ text: `🎮 *TIC TAC TOE*\n\n@${getPlayerName(senderId)} wants to play!\n\n*Type "join" within 60 seconds to play!*\n\nPlayer ❌: @${getPlayerName(senderId)}\nPlayer ⭕: Waiting...\n\n${renderBoard(room.game.render())}\n\n_Auto-cancels in 60 seconds if no one joins_`,
70
+ mentions: [senderId]
71
+ }, { quoted: fake });
72
+
73
+ games[room.id] = room;
74
+
75
+ gameTimeouts[chatId] = setTimeout(async () => {
76
+ const r = Object.values(games).find(g => g.chatId === chatId && g.state === 'WAITING');
77
+ if (r) {
78
+ delete games[r.id];
79
+ await sock.sendMessage(chatId, {
80
+ text: `⏰ *TIC TAC TOE - TIMEOUT*\n\nNo one joined within 60 seconds.\nGame cancelled!\n\n@${getPlayerName(r.game.playerX)} can start a new game with *.ttt*`,
81
+ mentions: [r.game.playerX]
82
+ });
83
+ }
84
+ }, 60000);
85
+ }
86
+ } catch (error) {
87
+ console.error('Error in tictactoe command:', error);
88
+ await sock.sendMessage(chatId, { text: '❌ Error starting game. Please try again.' });
89
+ }
90
+ }
91
+
92
+ async function tictactoeAICommand(sock, chatId, senderId, fake) {
93
+ try {
94
+ if (Object.values(games).find(room =>
95
+ room.id.startsWith('tictactoe') &&
96
+ [room.game.playerX, room.game.playerO].includes(senderId)
97
+ )) {
98
+ await sock.sendMessage(chatId, {
99
+ text: '❌ You are still in a game. Type *surrender* to quit.'
100
+ }, { quoted: fake });
101
+ return;
102
+ }
103
+
104
+ const room = {
105
+ id: 'tictactoe-ai-' + (+new Date),
106
+ chatId: chatId,
107
+ game: new TicTacToe(senderId, BOT_JID),
108
+ state: 'PLAYING',
109
+ isAI: true,
110
+ };
111
+
112
+ games[room.id] = room;
113
+
114
+ const arr = room.game.render();
115
+ await sock.sendMessage(chatId, {
116
+ text: `🎮 *TIC TAC TOE vs AI* 🤖\n\nPlayer ❌: @${getPlayerName(senderId)}\nPlayer ⭕: DAVE-X Bot 🤖\n\nYour turn! Type a number (1-9)\n\n${renderBoard(arr)}\n\n_Type *surrender* to give up_`,
117
+ mentions: [senderId]
118
+ }, { quoted: fake });
119
+ } catch (error) {
120
+ console.error('Error in tictactoe AI command:', error);
121
+ await sock.sendMessage(chatId, { text: '❌ Error starting AI game.' });
122
+ }
123
+ }
124
+
125
+ async function handleTicTacToeJoin(sock, chatId, senderId) {
126
+ const room = Object.values(games).find(room =>
127
+ room.state === 'WAITING' && room.chatId === chatId &&
128
+ room.game.playerX !== senderId
129
+ );
130
+ if (!room) return false;
131
+
132
+ room.game.playerO = senderId;
133
+ room.state = 'PLAYING';
134
+ clearGameTimeout(chatId);
135
+
136
+ const arr = room.game.render();
137
+ await sock.sendMessage(chatId, {
138
+ text: `🎮 *TIC TAC TOE - Game Started!*\n\nPlayer ❌: @${getPlayerName(room.game.playerX)}\nPlayer ⭕: @${getPlayerName(senderId)}\n\nWaiting for @${getPlayerName(room.game.currentTurn)} to play...\n\n${renderBoard(arr)}\n\n_Type a number (1-9) to place your symbol_\n_Type *surrender* to give up_`,
139
+ mentions: [room.game.playerX, senderId, room.game.currentTurn]
140
+ });
141
+ return true;
142
+ }
143
+
144
+ async function handleTicTacToeMove(sock, chatId, senderId, text) {
145
+ try {
146
+ const room = Object.values(games).find(room =>
147
+ room.id.startsWith('tictactoe') &&
148
+ [room.game.playerX, room.game.playerO].includes(senderId) &&
149
+ room.state === 'PLAYING'
150
+ );
151
+ if (!room) return false;
152
+
153
+ const isSurrender = /^(surrender|give\s?up)$/i.test(text);
154
+ if (!isSurrender && !/^[1-9]$/.test(text)) return false;
155
+
156
+ if (isSurrender) {
157
+ const winner = senderId === room.game.playerX ? room.game.playerO : room.game.playerX;
158
+ const winnerLabel = room.isAI && winner === BOT_JID ? 'DAVE-X Bot 🤖' : `@${getPlayerName(winner)}`;
159
+ await sock.sendMessage(chatId, {
160
+ text: `🏳️ @${getPlayerName(senderId)} has surrendered! ${winnerLabel} wins!`,
161
+ mentions: [senderId, winner]
162
+ });
163
+ delete games[room.id];
164
+ return true;
165
+ }
166
+
167
+ if (senderId !== room.game.currentTurn) {
168
+ await sock.sendMessage(chatId, { text: '❌ Not your turn!' });
169
+ return true;
170
+ }
171
+
172
+ const isO = senderId === room.game.playerO;
173
+ const ok = room.game.turn(isO, parseInt(text) - 1);
174
+ if (!ok) {
175
+ await sock.sendMessage(chatId, { text: '❌ Invalid move! That position is already taken.' });
176
+ return true;
177
+ }
178
+
179
+ let winner = room.game.winner;
180
+ let isTie = room.game.isDraw;
181
+
182
+ if (!winner && !isTie && room.isAI && room.game.currentTurn === BOT_JID) {
183
+ const aiMove = room.game.findBestMove();
184
+ if (aiMove >= 0) {
185
+ room.game.turn(true, aiMove);
186
+ winner = room.game.winner;
187
+ isTie = room.game.isDraw;
188
+ }
189
+ }
190
+
191
+ const arr = room.game.render();
192
+ let gameStatus;
193
+ if (winner) {
194
+ if (room.isAI && winner === BOT_JID) {
195
+ gameStatus = '🤖 DAVE-X Bot wins! Better luck next time!';
196
+ } else {
197
+ gameStatus = `🎉 @${getPlayerName(winner)} wins the game!`;
198
+ }
199
+ } else if (isTie) {
200
+ gameStatus = '🤝 Game ended in a draw!';
201
+ } else {
202
+ const nextPlayer = room.isAI && room.game.currentTurn === BOT_JID
203
+ ? 'DAVE-X Bot 🤖' : `@${getPlayerName(room.game.currentTurn)}`;
204
+ gameStatus = `Turn: ${nextPlayer}`;
205
+ }
206
+
207
+ const p1Label = `@${getPlayerName(room.game.playerX)}`;
208
+ const p2Label = room.isAI ? 'DAVE-X Bot 🤖' : `@${getPlayerName(room.game.playerO)}`;
209
+
210
+ await sock.sendMessage(chatId, {
211
+ text: `🎮 *TIC TAC TOE${room.isAI ? ' vs AI' : ''}*\n\n${gameStatus}\n\n${renderBoard(arr)}\n\nPlayer ❌: ${p1Label}\nPlayer ⭕: ${p2Label}\n\n${!winner && !isTie ? '_Type a number (1-9) to make your move_\n_Type *surrender* to give up_' : ''}`,
212
+ mentions: [room.game.playerX, room.game.playerO, ...(winner && winner !== BOT_JID ? [winner] : []), room.game.currentTurn]
213
+ });
214
+
215
+ if (winner || isTie) {
216
+ delete games[room.id];
217
+ }
218
+ return true;
219
+ } catch (error) {
220
+ console.error('Error in tictactoe move:', error);
221
+ return false;
222
+ }
223
+ }
224
+
225
+ async function tictactoeEndCommand(sock, chatId, senderId, fake) {
226
+ const room = Object.values(games).find(room =>
227
+ room.id.startsWith('tictactoe') &&
228
+ (room.chatId === chatId) &&
229
+ (room.game.playerX === senderId || room.game.playerO === senderId || room.state === 'WAITING')
230
+ );
231
+ if (!room) {
232
+ await sock.sendMessage(chatId, { text: '❌ No active TicTacToe game to end!' }, { quoted: fake });
233
+ return;
234
+ }
235
+ clearGameTimeout(chatId);
236
+ delete games[room.id];
237
+ await sock.sendMessage(chatId, {
238
+ text: `🛑 TicTacToe game ended by @${getPlayerName(senderId)}!`,
239
+ mentions: [senderId]
240
+ });
241
+ }
242
+
243
+ function hasTTTGame(chatId) {
244
+ return !!Object.values(games).find(room =>
245
+ room.chatId === chatId && room.state === 'PLAYING'
246
+ );
247
+ }
248
+
249
+ function hasWaitingTTTGame(chatId) {
250
+ return !!Object.values(games).find(room =>
251
+ room.chatId === chatId && room.state === 'WAITING'
252
+ );
253
+ }
254
+
255
+ module.exports = {
256
+ tictactoeCommand,
257
+ tictactoeAICommand,
258
+ handleTicTacToeMove,
259
+ handleTicTacToeJoin,
260
+ tictactoeEndCommand,
261
+ hasTTTGame,
262
+ hasWaitingTTTGame,
263
+ };
@@ -0,0 +1,46 @@
1
+ const axios = require('axios');
2
+
3
+ let triviaGames = {};
4
+
5
+ async function startTrivia(sock, chatId) {
6
+ if (triviaGames[chatId]) {
7
+ sock.sendMessage(chatId, { text: 'A trivia game is already in progress!' });
8
+ return;
9
+ }
10
+
11
+ try {
12
+ const response = await axios.get('https://opentdb.com/api.php?amount=1&type=multiple');
13
+ const questionData = response.data.results[0];
14
+
15
+ triviaGames[chatId] = {
16
+ question: questionData.question,
17
+ correctAnswer: questionData.correct_answer,
18
+ options: [...questionData.incorrect_answers, questionData.correct_answer].sort(),
19
+ };
20
+
21
+ sock.sendMessage(chatId, {
22
+ text: `Trivia Time!\n\nQuestion: ${triviaGames[chatId].question}\nOptions:\n${triviaGames[chatId].options.join('\n')}`
23
+ });
24
+ } catch (error) {
25
+ sock.sendMessage(chatId, { text: 'Error fetching trivia question. Try again later.' });
26
+ }
27
+ }
28
+
29
+ function answerTrivia(sock, chatId, answer) {
30
+ if (!triviaGames[chatId]) {
31
+ sock.sendMessage(chatId, { text: 'No trivia game is in progress.' });
32
+ return;
33
+ }
34
+
35
+ const game = triviaGames[chatId];
36
+
37
+ if (answer.toLowerCase() === game.correctAnswer.toLowerCase()) {
38
+ sock.sendMessage(chatId, { text: `Correct! The answer is ${game.correctAnswer}` });
39
+ } else {
40
+ sock.sendMessage(chatId, { text: `Wrong! The correct answer was ${game.correctAnswer}` });
41
+ }
42
+
43
+ delete triviaGames[chatId];
44
+ }
45
+
46
+ module.exports = { startTrivia, answerTrivia };
@@ -0,0 +1,242 @@
1
+ const WordChainGame = require('../../davelib/wordchain');
2
+
3
+ const games = {};
4
+ const gameTimeouts = {};
5
+ const BOT_JID = 'bot@s.whatsapp.net';
6
+
7
+ function getPlayerName(jid) {
8
+ return (jid || '').split(':')[0].split('@')[0];
9
+ }
10
+
11
+ function clearWcgTimeout(chatId) {
12
+ if (gameTimeouts[chatId]) {
13
+ clearTimeout(gameTimeouts[chatId]);
14
+ delete gameTimeouts[chatId];
15
+ }
16
+ }
17
+
18
+ async function wcgCommand(sock, chatId, senderId, fake) {
19
+ try {
20
+ if (games[chatId]) {
21
+ await sock.sendMessage(chatId, {
22
+ text: '❌ There is already a Word Chain game in this chat!\nUse *.wcgend* to end it first.'
23
+ }, { quoted: fake });
24
+ return;
25
+ }
26
+
27
+ const game = new WordChainGame(senderId);
28
+ games[chatId] = game;
29
+
30
+ await sock.sendMessage(chatId, {
31
+ text: `🔤 *WORD CHAIN GAME*\n\n@${getPlayerName(senderId)} started a Word Chain game!\n\n*Type "join" within 60 seconds to play!*\n\nPlayers: 1 (need at least 2)\n\n_Rules:_\n- Each word must start with the last letter of the previous word\n- No repeating words\n- Longer words = more points\n- Host types *.wcgbegin* to start when ready\n\n_Auto-cancels in 60 seconds if not enough players_`,
32
+ mentions: [senderId]
33
+ }, { quoted: fake });
34
+
35
+ gameTimeouts[chatId] = setTimeout(async () => {
36
+ if (games[chatId] && games[chatId].state === 'WAITING') {
37
+ delete games[chatId];
38
+ await sock.sendMessage(chatId, {
39
+ text: '⏰ *WORD CHAIN - TIMEOUT*\n\nNot enough players joined. Game cancelled!'
40
+ });
41
+ }
42
+ }, 60000);
43
+ } catch (error) {
44
+ console.error('Error in wcg command:', error);
45
+ await sock.sendMessage(chatId, { text: '❌ Error starting game.' });
46
+ }
47
+ }
48
+
49
+ async function wcgAICommand(sock, chatId, senderId, fake) {
50
+ try {
51
+ if (games[chatId]) {
52
+ await sock.sendMessage(chatId, {
53
+ text: '❌ There is already a Word Chain game in this chat!\nUse *.wcgend* to end it first.'
54
+ }, { quoted: fake });
55
+ return;
56
+ }
57
+
58
+ const game = new WordChainGame(senderId);
59
+ game.addPlayer(BOT_JID);
60
+ game.isAI = true;
61
+ game.start();
62
+ games[chatId] = game;
63
+
64
+ await sock.sendMessage(chatId, {
65
+ text: `🔤 *WORD CHAIN vs AI* 🤖\n\n@${getPlayerName(senderId)} vs DAVE-X Bot\n\nYou go first! Type any word to start.\n\n_Rules:_\n- Each word must start with the last letter of the previous word\n- No repeating words\n- Longer words = more points`,
66
+ mentions: [senderId]
67
+ }, { quoted: fake });
68
+ } catch (error) {
69
+ console.error('Error in wcgai command:', error);
70
+ await sock.sendMessage(chatId, { text: '❌ Error starting AI game.' });
71
+ }
72
+ }
73
+
74
+ async function wcgBeginCommand(sock, chatId, senderId, fake) {
75
+ const game = games[chatId];
76
+ if (!game) {
77
+ await sock.sendMessage(chatId, { text: '❌ No Word Chain game to start!' }, { quoted: fake });
78
+ return;
79
+ }
80
+ if (game.host !== senderId) {
81
+ await sock.sendMessage(chatId, { text: '❌ Only the host can start the game!' }, { quoted: fake });
82
+ return;
83
+ }
84
+ if (!game.start()) {
85
+ await sock.sendMessage(chatId, { text: '❌ Need at least 2 players to start!' }, { quoted: fake });
86
+ return;
87
+ }
88
+ clearWcgTimeout(chatId);
89
+
90
+ const playerList = game.players.map((p, i) => `${i + 1}. @${getPlayerName(p)}`).join('\n');
91
+ await sock.sendMessage(chatId, {
92
+ text: `🔤 *WORD CHAIN - Game Started!*\n\nPlayers:\n${playerList}\n\n@${getPlayerName(game.currentPlayer)} goes first! Type any word to start.\n\n_60 seconds per turn or you're eliminated!_`,
93
+ mentions: game.players
94
+ });
95
+
96
+ setTurnTimeout(sock, chatId);
97
+ }
98
+
99
+ function setTurnTimeout(sock, chatId) {
100
+ clearWcgTimeout(chatId);
101
+ const game = games[chatId];
102
+ if (!game || game.state !== 'PLAYING') return;
103
+
104
+ gameTimeouts[chatId] = setTimeout(async () => {
105
+ const g = games[chatId];
106
+ if (!g || g.state !== 'PLAYING') return;
107
+
108
+ const eliminated = g.currentPlayer;
109
+ g.eliminateCurrentPlayer();
110
+
111
+ if (g.state === 'ENDED') {
112
+ const winner = g.winner;
113
+ await sock.sendMessage(chatId, {
114
+ text: `⏰ @${getPlayerName(eliminated)} took too long and is eliminated!\n\n🏆 @${getPlayerName(winner)} wins the Word Chain!\n\n*Scores:*\n${g.getScoreboard()}`,
115
+ mentions: [eliminated, winner]
116
+ });
117
+ delete games[chatId];
118
+ } else {
119
+ await sock.sendMessage(chatId, {
120
+ text: `⏰ @${getPlayerName(eliminated)} took too long and is eliminated!\n\n@${getPlayerName(g.currentPlayer)}'s turn!${g.lastWord ? ` Word must start with "${g.lastWord.charAt(g.lastWord.length - 1).toUpperCase()}"` : ''}`,
121
+ mentions: [eliminated, g.currentPlayer]
122
+ });
123
+ setTurnTimeout(sock, chatId);
124
+ }
125
+ }, 60000);
126
+ }
127
+
128
+ async function handleWcgJoin(sock, chatId, senderId) {
129
+ const game = games[chatId];
130
+ if (!game || game.state !== 'WAITING') return false;
131
+ if (game.players.includes(senderId)) return false;
132
+
133
+ if (game.addPlayer(senderId)) {
134
+ await sock.sendMessage(chatId, {
135
+ text: `🔤 @${getPlayerName(senderId)} joined the Word Chain!\n\nPlayers: ${game.players.length}\nHost can type *.wcgbegin* to start.`,
136
+ mentions: [senderId]
137
+ });
138
+ return true;
139
+ }
140
+ return false;
141
+ }
142
+
143
+ async function handleWcgWord(sock, chatId, senderId, text) {
144
+ const game = games[chatId];
145
+ if (!game || game.state !== 'PLAYING') return false;
146
+ if (!game.players.includes(senderId)) return false;
147
+
148
+ const word = text.toLowerCase().trim();
149
+ if (word.length < 2 || word.includes(' ')) return false;
150
+
151
+ const result = game.submitWord(senderId, word);
152
+ if (!result.ok) {
153
+ await sock.sendMessage(chatId, {
154
+ text: `❌ @${getPlayerName(senderId)}: ${result.reason}`,
155
+ mentions: [senderId]
156
+ });
157
+ return true;
158
+ }
159
+
160
+ clearWcgTimeout(chatId);
161
+
162
+ if (game.isAI && game.currentPlayer === BOT_JID) {
163
+ const lastChar = word.charAt(word.length - 1);
164
+ const aiWord = WordChainGame.findAIWord(lastChar, game.usedWords);
165
+
166
+ if (aiWord) {
167
+ const aiResult = game.submitWord(BOT_JID, aiWord);
168
+ if (aiResult.ok) {
169
+ const nextChar = aiWord.charAt(aiWord.length - 1).toUpperCase();
170
+ await sock.sendMessage(chatId, {
171
+ text: `🔤 @${getPlayerName(senderId)}: *${word}* (+${word.length}pts)\n🤖 Bot: *${aiWord}* (+${aiWord.length}pts)\n\nYour turn! Word must start with "${nextChar}"\n\n*Scores:*\n${game.getScoreboard()}`,
172
+ mentions: [senderId]
173
+ });
174
+ setTurnTimeout(sock, chatId);
175
+ return true;
176
+ }
177
+ }
178
+
179
+ game.state = 'ENDED';
180
+ await sock.sendMessage(chatId, {
181
+ text: `🔤 @${getPlayerName(senderId)}: *${word}* (+${word.length}pts)\n🤖 Bot can't find a word! You win!\n\n🏆 *Final Scores:*\n${game.getScoreboard()}`,
182
+ mentions: [senderId]
183
+ });
184
+ delete games[chatId];
185
+ return true;
186
+ }
187
+
188
+ const nextChar = word.charAt(word.length - 1).toUpperCase();
189
+ await sock.sendMessage(chatId, {
190
+ text: `🔤 @${getPlayerName(senderId)}: *${word}* (+${word.length}pts)\n\n@${getPlayerName(game.currentPlayer)}'s turn! Word must start with "${nextChar}"\n\n*Scores:*\n${game.getScoreboard()}`,
191
+ mentions: [senderId, game.currentPlayer]
192
+ });
193
+
194
+ setTurnTimeout(sock, chatId);
195
+ return true;
196
+ }
197
+
198
+ async function wcgEndCommand(sock, chatId, senderId, fake) {
199
+ const game = games[chatId];
200
+ if (!game) {
201
+ await sock.sendMessage(chatId, { text: '❌ No Word Chain game to end!' }, { quoted: fake });
202
+ return;
203
+ }
204
+ clearWcgTimeout(chatId);
205
+ const scores = game.getScoreboard();
206
+ delete games[chatId];
207
+ await sock.sendMessage(chatId, {
208
+ text: `🛑 Word Chain ended by @${getPlayerName(senderId)}!\n\n*Final Scores:*\n${scores || 'No scores yet'}`,
209
+ mentions: [senderId]
210
+ });
211
+ }
212
+
213
+ async function wcgScoresCommand(sock, chatId, fake) {
214
+ const game = games[chatId];
215
+ if (!game) {
216
+ await sock.sendMessage(chatId, { text: '❌ No active Word Chain game!' }, { quoted: fake });
217
+ return;
218
+ }
219
+ await sock.sendMessage(chatId, {
220
+ text: `🔤 *Word Chain Scores*\n\n${game.getScoreboard()}\n\nWords used: ${game.usedWords.size}\nRounds: ${game.rounds}`,
221
+ });
222
+ }
223
+
224
+ function hasWcgGame(chatId) {
225
+ return !!games[chatId] && games[chatId].state === 'PLAYING';
226
+ }
227
+
228
+ function hasWaitingWcgGame(chatId) {
229
+ return !!games[chatId] && games[chatId].state === 'WAITING';
230
+ }
231
+
232
+ module.exports = {
233
+ wcgCommand,
234
+ wcgAICommand,
235
+ wcgBeginCommand,
236
+ wcgEndCommand,
237
+ wcgScoresCommand,
238
+ handleWcgJoin,
239
+ handleWcgWord,
240
+ hasWcgGame,
241
+ hasWaitingWcgGame,
242
+ };
@@ -0,0 +1,101 @@
1
+ const isAdmin = require('../../davelib/isAdmin');
2
+ const db = require('../../Database/database');
3
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
4
+
5
+ async function addMemberCommand(sock, chatId, message, text) {
6
+ const senderId = message.key.participant || message.key.remoteJid;
7
+ const fake = createFakeContact(senderId);
8
+ const botName = getBotName();
9
+
10
+ try {
11
+ if (!chatId.endsWith('@g.us')) {
12
+ await sock.sendMessage(chatId, {
13
+ text: `*${botName}*\nGroup command only!`
14
+ }, { quoted: fake });
15
+ return;
16
+ }
17
+
18
+ const adminStatus = await isAdmin(sock, chatId, senderId);
19
+
20
+ if (!adminStatus.isBotAdmin) {
21
+ await sock.sendMessage(chatId, {
22
+ text: `*${botName}*\nBot needs admin!`
23
+ }, { quoted: fake });
24
+ return;
25
+ }
26
+
27
+ if (!adminStatus.isSenderAdmin && !message.key.fromMe && !db.isSudo(senderId)) {
28
+ await sock.sendMessage(chatId, {
29
+ text: `*${botName}*\nAdmin only command!`
30
+ }, { quoted: fake });
31
+ return;
32
+ }
33
+
34
+ if (!text || text.trim() === '') {
35
+ await sock.sendMessage(chatId, {
36
+ text: `*${botName}*\nUsage: .add 6281234567890\n(Include country code, no + sign)`
37
+ }, { quoted: fake });
38
+ return;
39
+ }
40
+
41
+ const phoneNumber = text.replace(/[^0-9]/g, '');
42
+ if (!phoneNumber) {
43
+ await sock.sendMessage(chatId, {
44
+ text: `*${botName}*\nInvalid phone number!`
45
+ }, { quoted: fake });
46
+ return;
47
+ }
48
+
49
+ const userJid = phoneNumber + '@s.whatsapp.net';
50
+
51
+ try {
52
+ const result = await sock.groupParticipantsUpdate(chatId, [userJid], 'add');
53
+
54
+ if (result && result[0] && result[0].status === 200) {
55
+ await sock.sendMessage(chatId, {
56
+ text: `*${botName}*\n\n+${phoneNumber} added to the group!`
57
+ }, { quoted: fake });
58
+ return;
59
+ }
60
+
61
+ const groupMetadata = await sock.groupMetadata(chatId);
62
+ const inviteCode = await sock.groupInviteCode(chatId);
63
+ const inviteLink = `https://chat.whatsapp.com/${inviteCode}`;
64
+
65
+ try {
66
+ await sock.sendMessage(userJid, {
67
+ text: `Hello! You're invited to join:\n\n*${groupMetadata.subject}*\n\n${inviteLink}\n\nInvited by: ${message.pushName || 'Admin'}`
68
+ });
69
+
70
+ await sock.sendMessage(chatId, {
71
+ text: `*${botName}*\n\nInvite sent to +${phoneNumber}`
72
+ }, { quoted: fake });
73
+ } catch (inviteError) {
74
+ await sock.sendMessage(chatId, {
75
+ text: `*${botName}*\n\nGroup link:\n${inviteLink}\n\nShare with +${phoneNumber}`
76
+ }, { quoted: fake });
77
+ }
78
+
79
+ } catch (error) {
80
+ console.error('Add member error:', error.message, 'Line:', error.stack?.split('\n')[1]);
81
+
82
+ try {
83
+ const inviteCode = await sock.groupInviteCode(chatId);
84
+ const inviteLink = `https://chat.whatsapp.com/${inviteCode}`;
85
+
86
+ await sock.sendMessage(chatId, {
87
+ text: `*${botName}*\n\nFailed to add. Share this link:\n${inviteLink}`
88
+ }, { quoted: fake });
89
+ } catch (linkError) {
90
+ await sock.sendMessage(chatId, {
91
+ text: `*${botName}*\nFailed to add member.`
92
+ }, { quoted: fake });
93
+ }
94
+ }
95
+
96
+ } catch (error) {
97
+ console.error('Error in add command:', error.message, 'Line:', error.stack?.split('\n')[1]);
98
+ }
99
+ }
100
+
101
+ module.exports = { addMemberCommand };