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,267 @@
1
+ const ConnectFour = require('../../davelib/connect4');
2
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
3
+
4
+ // Store games globally
5
+ const connectFourGames = {};
6
+ async function connectFourCommand(sock, chatId, senderId, text, message) {
7
+ try {
8
+ const fake = createFakeContact(message || { key: { participant: senderId, remoteJid: chatId } });
9
+
10
+ // Check if player is already in a game
11
+ const existingGame = Object.values(connectFourGames).find(room =>
12
+ room.id && room.id.startsWith('connectfour') &&
13
+ (room.game.playerRed === senderId || room.game.playerYellow === senderId) &&
14
+ room.state !== 'ENDED'
15
+ );
16
+
17
+ if (existingGame) {
18
+ await sock.sendMessage(chatId, {
19
+ text: 'You are already in a Connect Four game. Type .forfeit to quit.'
20
+ }, { quoted: fake });
21
+ return;
22
+ }
23
+
24
+ // Clean up old games
25
+ Object.keys(connectFourGames).forEach(id => {
26
+ if (connectFourGames[id].state === 'ENDED' || Date.now() - parseInt(id.split('-')[1]) > 3600000) {
27
+ delete connectFourGames[id];
28
+ }
29
+ });
30
+
31
+ // Look for existing room to join
32
+ let room = Object.values(connectFourGames).find(room =>
33
+ room.id &&
34
+ room.id.startsWith('connectfour') &&
35
+ room.state === 'WAITING' &&
36
+ (!text || room.name === text) &&
37
+ room.red !== chatId // Prevent joining your own waiting room
38
+ );
39
+
40
+ if (room) {
41
+ // Join existing room
42
+ room.yellow = chatId;
43
+ room.game.playerYellow = senderId;
44
+ room.state = 'PLAYING';
45
+
46
+ const board = room.game.render();
47
+ const str = `Connect Four Game Started!
48
+
49
+ Waiting for @${room.game.currentTurn.split('@')[0]} to make a move...
50
+
51
+ ${board}
52
+
53
+ Room ID: ${room.id}
54
+ Rules:
55
+ Use .drop <column> to drop your disc (1-7)
56
+ Connect 4 discs horizontally, vertically, or diagonally to win
57
+ Type .forfeit to give up
58
+
59
+ Red Player: @${room.game.playerRed.split('@')[0]}
60
+ Yellow Player: @${room.game.playerYellow.split('@')[0]}
61
+ `;
62
+
63
+ await sock.sendMessage(chatId, {
64
+ text: str,
65
+ mentions: [room.game.currentTurn, room.game.playerRed, room.game.playerYellow]
66
+ }, { quoted: fake });
67
+
68
+ // Also notify the creator
69
+ if (room.red !== chatId) {
70
+ const creatorFake = createFakeContact({ key: { participant: senderId, remoteJid: room.red } });
71
+ await sock.sendMessage(room.red, {
72
+ text: 'Opponent found! Connect Four game has started.'
73
+ }, { quoted: creatorFake });
74
+ }
75
+
76
+ } else {
77
+ // Create new room
78
+ room = {
79
+ id: 'connectfour-' + Date.now(),
80
+ red: chatId,
81
+ yellow: '',
82
+ game: new ConnectFour(senderId, 'yellow'), // Creator is red
83
+ state: 'WAITING'
84
+ };
85
+
86
+ // Store game type/name if provided
87
+ if (text) room.name = text;
88
+
89
+ connectFourGames[room.id] = room;
90
+
91
+ await sock.sendMessage(chatId, {
92
+ text: `Waiting for Connect Four opponent...\nType .connectfour${text ? ' ' + text : ''} to join!\n\nYou will be Red. Room will expire in 5 minutes.\n\nCommands:\n.drop <1-7> - Drop disc in column\n.forfeit - Give up`
93
+ }, { quoted: fake });
94
+
95
+ // Auto-cleanup after 5 minutes if no one joins
96
+ setTimeout(() => {
97
+ if (connectFourGames[room.id] && connectFourGames[room.id].state === 'WAITING') {
98
+ delete connectFourGames[room.id];
99
+ const cleanupFake = createFakeContact({ key: { participant: senderId, remoteJid: chatId } });
100
+ sock.sendMessage(chatId, {
101
+ text: 'Room expired. No one joined the Connect Four game.'
102
+ }, { quoted: cleanupFake }).catch(() => {});
103
+ }
104
+ }, 300000); // 5 minutes
105
+
106
+ }
107
+
108
+ } catch (error) {
109
+ console.error('Error in connectfour command:', error);
110
+ const fake = createFakeContact(message || { key: { participant: senderId, remoteJid: chatId } });
111
+ await sock.sendMessage(chatId, {
112
+ text: 'Error starting Connect Four game. Please try again.'
113
+ }, { quoted: fake });
114
+ }
115
+ }
116
+
117
+ async function handleConnectFourMove(sock, chatId, senderId, columnText, message) {
118
+ try {
119
+ const fake = createFakeContact(message || { key: { participant: senderId, remoteJid: chatId } });
120
+
121
+ // Find player's game
122
+ const room = Object.values(connectFourGames).find(room =>
123
+ room.id &&
124
+ room.id.startsWith('connectfour') &&
125
+ (room.game.playerRed === senderId || room.game.playerYellow === senderId) &&
126
+ room.state === 'PLAYING'
127
+ );
128
+
129
+ if (!room) return false; // Return false if no game found
130
+
131
+ const isForfeit = /^(forfeit|give up|quit|resign|surrender)$/i.test(columnText);
132
+ const column = parseInt(columnText);
133
+
134
+ // If not a valid move command and not forfeit, ignore
135
+ if (!isForfeit && (isNaN(column) || column < 1 || column > 7)) return false;
136
+
137
+ // Check if it's player's turn (except for forfeit)
138
+ if (senderId !== room.game.currentTurn && !isForfeit) {
139
+ await sock.sendMessage(chatId, {
140
+ text: 'Not your turn! Wait for your opponent to move.'
141
+ }, { quoted: fake });
142
+ return true;
143
+ }
144
+
145
+ let moveResult;
146
+ if (isForfeit) {
147
+ moveResult = true; // Allow forfeit
148
+ } else {
149
+ try {
150
+ moveResult = room.game.dropDisc(
151
+ senderId === room.game.playerYellow, // true if player is yellow
152
+ column - 1 // Convert to 0-indexed
153
+ );
154
+ } catch (error) {
155
+ console.error('Move error:', error);
156
+ await sock.sendMessage(chatId, {
157
+ text: 'Invalid column! Please use .drop 1 to .drop 7.'
158
+ }, { quoted: fake });
159
+ return true;
160
+ }
161
+ }
162
+
163
+ if (!moveResult && !isForfeit) {
164
+ await sock.sendMessage(chatId, {
165
+ text: 'Column is full! Choose another column.'
166
+ }, { quoted: fake });
167
+ return true;
168
+ }
169
+
170
+ let winner = null;
171
+ let isDraw = false;
172
+
173
+ if (isForfeit) {
174
+ // Set winner to opponent
175
+ winner = senderId === room.game.playerRed ? room.game.playerYellow : room.game.playerRed;
176
+ room.state = 'ENDED';
177
+
178
+ const forfeitMessage = `@${senderId.split('@')[0]} has forfeited!\n@${winner.split('@')[0]} wins the Connect Four game!`;
179
+
180
+ // Send to both players
181
+ const mentions = [senderId, winner];
182
+ await sock.sendMessage(room.red, {
183
+ text: forfeitMessage,
184
+ mentions: mentions
185
+ }, { quoted: fake });
186
+
187
+ if (room.yellow && room.red !== room.yellow) {
188
+ await sock.sendMessage(room.yellow, {
189
+ text: forfeitMessage,
190
+ mentions: mentions
191
+ }, { quoted: fake });
192
+ }
193
+
194
+ delete connectFourGames[room.id];
195
+ return true;
196
+ }
197
+
198
+ // Check game status
199
+ winner = room.game.winner || null;
200
+ isDraw = room.game.isDraw();
201
+
202
+ const board = room.game.render();
203
+ let gameStatus;
204
+ if (winner) {
205
+ const winnerSymbol = winner === room.game.playerRed ? 'Red' : 'Yellow';
206
+ gameStatus = `@${winner.split('@')[0]} wins by connecting four!`;
207
+ room.state = 'ENDED';
208
+ } else if (isDraw) {
209
+ gameStatus = `Game ended in a draw! Board is full.`;
210
+ room.state = 'ENDED';
211
+ } else {
212
+ gameStatus = `Turn: @${room.game.currentTurn.split('@')[0]}`;
213
+ }
214
+
215
+ const str = `Connect Four Game
216
+
217
+ ${gameStatus}
218
+
219
+ ${board}
220
+
221
+ Red Player: @${room.game.playerRed.split('@')[0]}
222
+ Yellow Player: @${room.game.playerYellow.split('@')[0]}
223
+
224
+ ${!winner && !isDraw ? 'Use .drop <1-7> to make your move\nType .forfeit to give up' : 'Type .connectfour to start a new game'}
225
+ `;
226
+
227
+ const mentions = [
228
+ room.game.playerRed,
229
+ room.game.playerYellow,
230
+ ...(winner ? [winner] : [room.game.currentTurn])
231
+ ];
232
+
233
+ // Send to both players
234
+ await sock.sendMessage(room.red, {
235
+ text: str,
236
+ mentions: mentions
237
+ }, { quoted: fake });
238
+
239
+ if (room.yellow && room.red !== room.yellow) {
240
+ await sock.sendMessage(room.yellow, {
241
+ text: str,
242
+ mentions: mentions
243
+ }, { quoted: fake });
244
+ }
245
+
246
+ if (winner || isDraw) {
247
+ delete connectFourGames[room.id];
248
+ }
249
+
250
+ return true;
251
+
252
+ } catch (error) {
253
+ console.error('Error in connectfour move:', error);
254
+ try {
255
+ const fake = createFakeContact(message || { key: { participant: senderId, remoteJid: chatId } });
256
+ await sock.sendMessage(chatId, {
257
+ text: 'An error occurred during the move. Please start a new game.'
258
+ }, { quoted: fake });
259
+ } catch (e) {}
260
+ return true;
261
+ }
262
+ }
263
+
264
+ module.exports = {
265
+ connectFourCommand,
266
+ handleConnectFourMove
267
+ };
@@ -0,0 +1,286 @@
1
+ const DiceGame = require('../../davelib/dicegame');
2
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
3
+
4
+ const games = {};
5
+ const gameTimeouts = {};
6
+
7
+ function getPlayerName(jid) {
8
+ return (jid || '').split(':')[0].split('@')[0];
9
+ }
10
+
11
+ function clearDiceTimeout(chatId) {
12
+ if (gameTimeouts[chatId]) {
13
+ clearTimeout(gameTimeouts[chatId]);
14
+ delete gameTimeouts[chatId];
15
+ }
16
+ }
17
+
18
+ async function diceCommand(sock, chatId, senderId, fullArgs) {
19
+ try {
20
+ const fake = createFakeContact(senderId);
21
+ const botName = getBotName();
22
+
23
+ if (games[chatId] && games[chatId].state !== 'ENDED') {
24
+ const g = games[chatId];
25
+ const players = g.players.map(p => `@${getPlayerName(p)}`).join(', ');
26
+ await sock.sendMessage(chatId, {
27
+ text: `✦ *${botName}* Dice\n\nGame active!\nPlayers: ${players}\nRound: ${g.round}/${g.maxRounds}\n\nUse .roll | .diceend`,
28
+ mentions: g.players
29
+ }, { quoted: fake });
30
+ return;
31
+ }
32
+
33
+ const rounds = parseInt(fullArgs) || 3;
34
+ const maxRounds = Math.min(Math.max(rounds, 1), 10);
35
+
36
+ games[chatId] = new DiceGame(senderId, maxRounds);
37
+
38
+ clearDiceTimeout(chatId);
39
+ gameTimeouts[chatId] = setTimeout(() => {
40
+ if (games[chatId] && games[chatId].state === 'WAITING') {
41
+ delete games[chatId];
42
+ sock.sendMessage(chatId, {
43
+ text: `✦ *${botName}*\nGame expired - no one joined`
44
+ }).catch(() => {});
45
+ }
46
+ }, 120000);
47
+
48
+ await sock.sendMessage(chatId, {
49
+ text: `✦ *${botName}* Dice\n\n@${getPlayerName(senderId)} started a game!\n\nRounds: ${maxRounds}\n\nJoin: .dicejoin\nStart: .dicebegin\nRoll: .roll`,
50
+ mentions: [senderId]
51
+ }, { quoted: fake });
52
+ } catch (err) {
53
+ console.error('Dice command error:', err);
54
+ }
55
+ }
56
+
57
+ async function diceAICommand(sock, chatId, senderId, fullArgs) {
58
+ try {
59
+ const fake = createFakeContact(senderId);
60
+ const botName = getBotName();
61
+
62
+ if (games[chatId] && games[chatId].state !== 'ENDED') {
63
+ await sock.sendMessage(chatId, {
64
+ text: `✦ *${botName}*\nGame active! Use .diceend first`
65
+ }, { quoted: fake });
66
+ return;
67
+ }
68
+
69
+ const rounds = parseInt(fullArgs) || 3;
70
+ const maxRounds = Math.min(Math.max(rounds, 1), 10);
71
+ const botJid = 'bot@s.whatsapp.net';
72
+
73
+ const game = new DiceGame(senderId, maxRounds);
74
+ game.addPlayer(botJid);
75
+ game.start();
76
+ games[chatId] = game;
77
+
78
+ await sock.sendMessage(chatId, {
79
+ text: `✦ *${botName}* Dice vs AI\n\n@${getPlayerName(senderId)} vs Bot\nRounds: ${maxRounds}\n\nYour turn! .roll`,
80
+ mentions: [senderId]
81
+ }, { quoted: fake });
82
+ } catch (err) {
83
+ console.error('Dice AI error:', err);
84
+ }
85
+ }
86
+
87
+ async function handleDiceJoin(sock, chatId, senderId) {
88
+ try {
89
+ const fake = createFakeContact(senderId);
90
+ const botName = getBotName();
91
+ const game = games[chatId];
92
+
93
+ if (!game || game.state !== 'WAITING') {
94
+ await sock.sendMessage(chatId, {
95
+ text: `✦ *${botName}*\nNo game waiting. Start with .dice`
96
+ }, { quoted: fake });
97
+ return;
98
+ }
99
+
100
+ if (!game.addPlayer(senderId)) {
101
+ await sock.sendMessage(chatId, {
102
+ text: `✦ *${botName}*\nYou're already in!`
103
+ }, { quoted: fake });
104
+ return;
105
+ }
106
+
107
+ const players = game.players.map(p => `@${getPlayerName(p)}`).join(', ');
108
+ await sock.sendMessage(chatId, {
109
+ text: `✦ *${botName}* Dice\n\n@${getPlayerName(senderId)} joined!\nPlayers (${game.players.length}): ${players}\n\n.dicebegin to start`,
110
+ mentions: game.players
111
+ }, { quoted: fake });
112
+ } catch (err) {
113
+ console.error('Dice join error:', err);
114
+ }
115
+ }
116
+
117
+ async function handleDiceBegin(sock, chatId, senderId) {
118
+ try {
119
+ const fake = createFakeContact(senderId);
120
+ const botName = getBotName();
121
+ const game = games[chatId];
122
+
123
+ if (!game || game.state !== 'WAITING') {
124
+ await sock.sendMessage(chatId, {
125
+ text: `✦ *${botName}*\nNo game to start`
126
+ }, { quoted: fake });
127
+ return;
128
+ }
129
+
130
+ if (senderId !== game.host) {
131
+ await sock.sendMessage(chatId, {
132
+ text: `✦ *${botName}*\nOnly host can start`
133
+ }, { quoted: fake });
134
+ return;
135
+ }
136
+
137
+ if (!game.start()) {
138
+ await sock.sendMessage(chatId, {
139
+ text: `✦ *${botName}*\nNeed at least 2 players`
140
+ }, { quoted: fake });
141
+ return;
142
+ }
143
+
144
+ clearDiceTimeout(chatId);
145
+
146
+ const players = game.players.map(p => `@${getPlayerName(p)}`).join(', ');
147
+ await sock.sendMessage(chatId, {
148
+ text: `✦ *${botName}* Game Started\n\nPlayers: ${players}\nRounds: ${game.maxRounds}\n\n@${getPlayerName(game.currentPlayer)}'s turn! .roll`,
149
+ mentions: game.players
150
+ }, { quoted: fake });
151
+ } catch (err) {
152
+ console.error('Dice begin error:', err);
153
+ }
154
+ }
155
+
156
+ async function handleDiceRoll(sock, chatId, senderId) {
157
+ try {
158
+ const fake = createFakeContact(senderId);
159
+ const botName = getBotName();
160
+ const game = games[chatId];
161
+ const botJid = 'bot@s.whatsapp.net';
162
+
163
+ if (!game || game.state !== 'PLAYING') {
164
+ await sock.sendMessage(chatId, {
165
+ text: `✦ *${botName}*\nNo active game. Start with .dice`
166
+ }, { quoted: fake });
167
+ return;
168
+ }
169
+
170
+ const result = game.roll(senderId);
171
+ if (!result.ok) {
172
+ await sock.sendMessage(chatId, {
173
+ text: `✦ *${botName}*\n${result.reason}`
174
+ }, { quoted: fake });
175
+ return;
176
+ }
177
+
178
+ let msg = `✦ *${botName}* Dice\n\n` +
179
+ `@${getPlayerName(senderId)} rolled:\n` +
180
+ `[ ${result.dice1} ] + [ ${result.dice2} ] = *${result.total}*\n`;
181
+
182
+ if (result.gameOver) {
183
+ const winner = game.winner;
184
+ msg += `\n*GAME OVER*\n\n${game.getScoreboard()}\n\n` +
185
+ `Winner: @${getPlayerName(winner)}!`;
186
+ delete games[chatId];
187
+ clearDiceTimeout(chatId);
188
+ await sock.sendMessage(chatId, {
189
+ text: msg,
190
+ mentions: game.players
191
+ }, { quoted: fake });
192
+ } else if (result.roundComplete) {
193
+ msg += `\n*Round ${result.round} complete*\n\n${game.getScoreboard()}\n\n` +
194
+ `Round ${game.round}/${game.maxRounds} - @${getPlayerName(result.nextPlayer)}'s turn! .roll`;
195
+
196
+ if (result.nextPlayer === botJid) {
197
+ await sock.sendMessage(chatId, { text: msg, mentions: game.players }, { quoted: fake });
198
+ await new Promise(r => setTimeout(r, 1500));
199
+ await handleBotDiceRoll(sock, chatId, game, botJid);
200
+ } else {
201
+ await sock.sendMessage(chatId, { text: msg, mentions: game.players }, { quoted: fake });
202
+ }
203
+ } else {
204
+ if (result.nextPlayer === botJid) {
205
+ msg += `\nBot's turn...`;
206
+ await sock.sendMessage(chatId, { text: msg, mentions: [senderId] }, { quoted: fake });
207
+ await new Promise(r => setTimeout(r, 1500));
208
+ await handleBotDiceRoll(sock, chatId, game, botJid);
209
+ } else {
210
+ msg += `\n@${getPlayerName(result.nextPlayer)}'s turn! .roll`;
211
+ await sock.sendMessage(chatId, { text: msg, mentions: [senderId, result.nextPlayer] }, { quoted: fake });
212
+ }
213
+ }
214
+ } catch (err) {
215
+ console.error('Dice roll error:', err);
216
+ }
217
+ }
218
+
219
+ async function handleBotDiceRoll(sock, chatId, game, botJid) {
220
+ const botName = getBotName();
221
+ const result = game.roll(botJid);
222
+ if (!result.ok) return;
223
+
224
+ let msg = `✦ *${botName}* Bot Roll\n\n` +
225
+ `Bot rolled:\n[ ${result.dice1} ] + [ ${result.dice2} ] = *${result.total}*\n`;
226
+
227
+ if (result.gameOver) {
228
+ const winner = game.winner;
229
+ msg += `\n*GAME OVER*\n\n${game.getScoreboard()}\n\n` +
230
+ `Winner: ${winner === botJid ? 'Bot' : `@${getPlayerName(winner)}`}!`;
231
+ delete games[chatId];
232
+ clearDiceTimeout(chatId);
233
+ await sock.sendMessage(chatId, { text: msg, mentions: game.players });
234
+ } else if (result.roundComplete) {
235
+ msg += `\n*Round ${result.round} complete*\n\n${game.getScoreboard()}\n\n` +
236
+ `Round ${game.round}/${game.maxRounds} - @${getPlayerName(result.nextPlayer)}'s turn! .roll`;
237
+ await sock.sendMessage(chatId, { text: msg, mentions: game.players });
238
+ } else {
239
+ msg += `\n@${getPlayerName(result.nextPlayer)}'s turn! .roll`;
240
+ await sock.sendMessage(chatId, { text: msg, mentions: [result.nextPlayer] });
241
+ }
242
+ }
243
+
244
+ async function diceEndCommand(sock, chatId, senderId) {
245
+ try {
246
+ const fake = createFakeContact(senderId);
247
+ const botName = getBotName();
248
+ const game = games[chatId];
249
+
250
+ if (!game) {
251
+ await sock.sendMessage(chatId, {
252
+ text: `✦ *${botName}*\nNo active game`
253
+ }, { quoted: fake });
254
+ return;
255
+ }
256
+
257
+ let msg = `✦ *${botName}*\nGame ended by @${getPlayerName(senderId)}.`;
258
+ if (game.state === 'PLAYING') {
259
+ msg += `\n\n${game.getScoreboard()}`;
260
+ }
261
+
262
+ delete games[chatId];
263
+ clearDiceTimeout(chatId);
264
+
265
+ await sock.sendMessage(chatId, {
266
+ text: msg,
267
+ mentions: game.players
268
+ }, { quoted: fake });
269
+ } catch (err) {
270
+ console.error('Dice end error:', err);
271
+ }
272
+ }
273
+
274
+ function hasDiceGame(chatId) {
275
+ return !!games[chatId] && games[chatId].state !== 'ENDED';
276
+ }
277
+
278
+ module.exports = {
279
+ diceCommand,
280
+ diceAICommand,
281
+ handleDiceJoin,
282
+ handleDiceBegin,
283
+ handleDiceRoll,
284
+ diceEndCommand,
285
+ hasDiceGame,
286
+ };
@@ -0,0 +1,24 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+
3
+ const eightBallResponses = [
4
+ "Yes, definitely!",
5
+ "No way!",
6
+ "Ask again later.",
7
+ "It is certain.",
8
+ "Very doubtful.",
9
+ "Without a doubt.",
10
+ "My reply is no.",
11
+ "Signs point to yes."
12
+ ];
13
+
14
+ async function eightBallCommand(sock, chatId, question) {
15
+ if (!question) {
16
+ await sock.sendMessage(chatId, { text: 'Please ask a question!' });
17
+ return;
18
+ }
19
+
20
+ const randomResponse = eightBallResponses[Math.floor(Math.random() * eightBallResponses.length)];
21
+ await sock.sendMessage(chatId, { text: `🎱 ${randomResponse}` });
22
+ }
23
+
24
+ module.exports = { eightBallCommand };
@@ -0,0 +1,60 @@
1
+ const fs = require('fs');
2
+
3
+ const words = ['javascript', 'bot', 'hangman', 'whatsapp', 'nodejs'];
4
+ let hangmanGames = {};
5
+
6
+ function startHangman(sock, chatId) {
7
+ const word = words[Math.floor(Math.random() * words.length)];
8
+ const maskedWord = '_ '.repeat(word.length).trim();
9
+
10
+ hangmanGames[chatId] = {
11
+ word,
12
+ maskedWord: maskedWord.split(' '),
13
+ guessedLetters: [],
14
+ wrongGuesses: 0,
15
+ maxWrongGuesses: 6,
16
+ };
17
+
18
+ sock.sendMessage(chatId, { text: `Game started! The word is: ${maskedWord}` });
19
+ }
20
+
21
+ function guessLetter(sock, chatId, letter) {
22
+ if (!hangmanGames[chatId]) {
23
+ sock.sendMessage(chatId, { text: 'No game in progress. Start a new game with .hangman' });
24
+ return;
25
+ }
26
+
27
+ const game = hangmanGames[chatId];
28
+ const { word, guessedLetters, maskedWord, maxWrongGuesses } = game;
29
+
30
+ if (guessedLetters.includes(letter)) {
31
+ sock.sendMessage(chatId, { text: `You already guessed "${letter}". Try another letter.` });
32
+ return;
33
+ }
34
+
35
+ guessedLetters.push(letter);
36
+
37
+ if (word.includes(letter)) {
38
+ for (let i = 0; i < word.length; i++) {
39
+ if (word[i] === letter) {
40
+ maskedWord[i] = letter;
41
+ }
42
+ }
43
+ sock.sendMessage(chatId, { text: `Good guess! ${maskedWord.join(' ')}` });
44
+
45
+ if (!maskedWord.includes('_')) {
46
+ sock.sendMessage(chatId, { text: `Congratulations! You guessed the word: ${word}` });
47
+ delete hangmanGames[chatId];
48
+ }
49
+ } else {
50
+ game.wrongGuesses += 1;
51
+ sock.sendMessage(chatId, { text: `Wrong guess! You have ${maxWrongGuesses - game.wrongGuesses} tries left.` });
52
+
53
+ if (game.wrongGuesses >= maxWrongGuesses) {
54
+ sock.sendMessage(chatId, { text: `Game over! The word was: ${word}` });
55
+ delete hangmanGames[chatId];
56
+ }
57
+ }
58
+ }
59
+
60
+ module.exports = { startHangman, guessLetter };
@@ -0,0 +1,25 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+
3
+ function rpsCommand(sock, chatId, message, args) {
4
+ const fakeContact = createFakeContact(message);
5
+ const botName = getBotName();
6
+ const choices = ['rock', 'paper', 'scissors'];
7
+ const emojis = { rock: '🪨', paper: '📄', scissors: '✂️' };
8
+
9
+ const userChoice = (args[0] || '').toLowerCase();
10
+ if (!choices.includes(userChoice)) {
11
+ return sock.sendMessage(chatId, { text: `*${botName} RPS*\n\nUsage: .rps <rock|paper|scissors>\nExample: .rps rock` }, { quoted: fakeContact });
12
+ }
13
+
14
+ const botChoice = choices[Math.floor(Math.random() * 3)];
15
+
16
+ let result;
17
+ if (userChoice === botChoice) result = "It's a TIE!";
18
+ else if ((userChoice === 'rock' && botChoice === 'scissors') || (userChoice === 'paper' && botChoice === 'rock') || (userChoice === 'scissors' && botChoice === 'paper')) result = 'You WIN!';
19
+ else result = 'You LOSE!';
20
+
21
+ const text = `*${botName} RPS*\n\nYou: ${emojis[userChoice]} ${userChoice}\nBot: ${emojis[botChoice]} ${botChoice}\n\n*${result}*`;
22
+ return sock.sendMessage(chatId, { text }, { quoted: fakeContact });
23
+ }
24
+
25
+ module.exports = rpsCommand;
@@ -0,0 +1,36 @@
1
+ const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
2
+
3
+ async function shipCommand(sock, chatId, msg, groupMetadata) {
4
+ try {
5
+ const fakeContact = createFakeContact(msg);
6
+ // Get all participants from the group
7
+ const participants = await sock.groupMetadata(chatId);
8
+ const ps = participants.participants.map(v => v.id);
9
+
10
+ // Get two random participants
11
+ let firstUser, secondUser;
12
+
13
+ // Select first random user
14
+ firstUser = ps[Math.floor(Math.random() * ps.length)];
15
+
16
+ // Select second random user (different from first)
17
+ do {
18
+ secondUser = ps[Math.floor(Math.random() * ps.length)];
19
+ } while (secondUser === firstUser);
20
+
21
+ // Format the mentions
22
+ const formatMention = id => '@' + id.split('@')[0];
23
+
24
+ // Create and send the ship message
25
+ await sock.sendMessage(chatId, {
26
+ text: `${formatMention(firstUser)} ❤️ ${formatMention(secondUser)}\nCongratulations 💖🍻`,
27
+ mentions: [firstUser, secondUser]
28
+ }, { quoted: fakeContact });
29
+
30
+ } catch (error) {
31
+ console.error('Error in ship command:', error);
32
+ await sock.sendMessage(chatId, { text: '❌ Failed to ship! Make sure this is a group.' }, { quoted: fakeContact });
33
+ }
34
+ }
35
+
36
+ module.exports = shipCommand;