chatbot.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. import { perplexity } from '../lib/scraper.js';
  2. const antiSpam = new Map();
  3. export async function before(m, { conn }) {
  4. let fkontak = {
  5. "key": {
  6. "participants": "[email protected]",
  7. "remoteJid": "status@broadcast",
  8. "fromMe": false,
  9. "id": "Halo"
  10. },
  11. "message": {
  12. "contactMessage": {
  13. "vcard": `BEGIN:VCARD
  14. VERSION:3.0
  15. N:Sy;Bot;;;
  16. FN:y
  17. item1.TEL;waid=${m.sender.split('@')[0]}:${m.sender.split('@')[0]}
  18. item1.X-ABLabel:Ponsel
  19. END:VCARD`
  20. }
  21. },
  22. "participant": "[email protected]"
  23. };
  24. if (
  25. m.id.startsWith('NJX-') ||
  26. (m.id.startsWith('BAE5') && m.id.length === 16) ||
  27. (m.id.startsWith('3EB0') && m.id.length === 12) ||
  28. (m.id.startsWith('3EB0') && (m.id.length === 20 || m.id.length === 22)) ||
  29. (m.id.startsWith('B24E') && m.id.length === 20) ||
  30. m.id.startsWith('FizzxyTheGreat-')
  31. ) return;
  32. let setting = global.db.data.settings[this.user.jid];
  33. let chat = global.db.data.chats[m.chat];
  34. let name = conn.getName(m.sender);
  35. const user = `@${m.sender.split('@')[0]}`;
  36. if (chat.isBanned) return;
  37. if (m.fromMe) return;
  38. if (m.chat === "120363371008200788@newsletter") return;
  39. if (m.chat === "120363371008200788@newsletter") return;
  40. let vn = 'https://qu.ax/eGdW.mp3';
  41. let bot = `${pickRandom([
  42. `*Hola ${user} soy un bot el que puedo ayudar? ๐Ÿ‘‰๐Ÿ‘ˆ*`,
  43. `Aqui estoy`,
  44. `bot tu abuela`,
  45. `que quiere?`,
  46. `No dispoble ๐Ÿซฃ`,
  47. `Hola aqui estoy soy tu botsito sexy el que puedo ayudar uwu`
  48. ])}`.trim();
  49. let txt = `*Pagas una fortuna para streaming.*
  50. > *Tenemos streaming variado. Es muy barato y todos pueden comprar.*
  51. ๐Ÿ’Ž \`\`\`W E B\`\`\`
  52. ๐Ÿ’ป *Pรกgina:*
  53. https://hackstorex.com
  54. ๐Ÿ’ฅ *BUSCAS SCRIPTS YA HECHOS PARA CREAR TUS PรGINAS WEB?*
  55. โšก *WEB*
  56. > https://MexSpin.fun
  57. ๐Ÿ—ฃ๐Ÿ“ฒ *Contacto:*
  58. > 5217121649714`;
  59. // Detectar palabras clave incluyendo Kantu y Kantubot
  60. if (
  61. m.text.includes('bot') ||
  62. m.text.includes('Bot') ||
  63. m.text.includes('simsimi') ||
  64. m.text.includes('simi') ||
  65. m.text.includes('alexa') ||
  66. m.text.includes('kantu') ||
  67. m.text.includes('Kantu') ||
  68. m.text.includes('kantubot') ||
  69. m.text.includes('Kantubot')
  70. ) {
  71. if (
  72. m.text.includes('jadibot') ||
  73. m.text.includes('bots') ||
  74. m.text.includes('serbot') ||
  75. m.text.includes('instalarbot') ||
  76. m.text.includes('infobot')
  77. ) return;
  78. const lastMessageTime = antiSpam.get(m.sender) || 0;
  79. const currentTime = Date.now();
  80. if (currentTime - lastMessageTime < 9000) throw !0;
  81. if (/^ยฟque es un bot\?|Que es un bot\?|que es un bot\?|que es un bot$/i.test(m.text)) {
  82. return conn.reply(
  83. m.chat,
  84. `\`โ˜†::ยฟ${await tr("QUE ES UN BOT DE WHATSAPP?")}::โ˜†\`
  85. > ๐”๐ง ๐๐จ๐ญ ๐ž๐ฌ ๐ฎ๐ง๐š ๐ข๐ง๐ญ๐ž๐ฅ๐ข๐ ๐ž๐ง๐œ๐ข๐š ๐š๐ซ๐ญ๐ข๐Ÿ๐ข๐œ๐ข๐š๐ฅ ๐ช๐ฎ๐ž ๐ซ๐ž๐š๐ฅ๐ข๐ณ๐š ๐ญ๐š๐ซ๐ž๐š๐ฌ ๐ช๐ฎ๐ž ๐ฅ๐ž ๐ข๐ง๐๐ข๐ช๐ฎ๐ž ๐œ๐จ๐ง ๐œ๐จ๐ฆ๐š๐ง๐๐จ๐ฌ, ๐ž๐ง ๐ž๐ฅ ๐œ๐š๐ฌ๐จ ๐๐ž ๐–๐ก๐š๐ญ๐ฌ๐€๐ฉ๐ฉ ๐ฉ๐ฎ๐ž๐๐ž๐ฌ ๐œ๐ซ๐ž๐š๐ซ ๐ฌ๐ญ๐ข๐œ๐ค๐ž๐ซ๐ฌ, ๐๐ž๐ฌ๐œ๐š๐ซ๐ ๐š๐ซ ๐ฆ๐ฎฬ๐ฌ๐ข๐œ๐š, ๐ฏ๐ข๐๐ž๐จ๐ฌ, ๐œ๐ซ๐ž๐š๐ซ ๐ฅ๐จ๐ ๐จ๐ฌ ๐ฉ๐ž๐ซ๐ฌ๐จ๐ง๐š๐ฅ๐ข๐ณ๐š๐๐จ๐ฌ ๐ฒ ๐ฆ๐ฎ๐œ๐ก๐จ ๐ฆ๐š๐ฌ, ๐ž๐ฌ๐ญ๐จ ๐๐ž ๐Ÿ๐จ๐ซ๐ฆ๐š ๐š๐ฎ๐ญ๐จ๐ฆ๐š๐ญ๐ข๐ณ๐š๐๐š, ๐จ ๐ฌ๐ž๐š ๐ช๐ฎ๐ž ๐ฎ๐ง ๐ก๐ฎ๐ฆ๐š๐ง๐จ ๐ง๐จ ๐ข๐ง๐ญ๐ž๐ซ๐Ÿ๐ข๐ž๐ซ๐ž ๐ž๐ง ๐ž๐ฅ ๐ฉ๐ซ๐จ๐œ๐ž๐ฌ๐จ. ๐๐š๐ซ๐š ๐ฏ๐ž๐ซ ๐ž๐ฅ ๐ฆ๐ž๐ง๐ฎฬ ๐๐ž ๐œ๐จ๐ฆ๐š๐ง๐๐จ๐ฌ ๐ฉ๐ฎ๐ž๐๐ž๐ฌ ๐ฎ๐ฌ๐š๐ซ: #menu
  86. >ใ€Œ แด‹แด€ษดแด›แดœ - ส™แดแด› ใ€`,
  87. m
  88. );
  89. }
  90. if (/^Quiero un bot|como obtengo un bot\?|Quiero un bot\?|quiero un bot|solicitรณ bot|solicito bot|Necesito un bot|necesito un bot$/i.test(m.text)) {
  91. return conn.reply(
  92. m.chat,
  93. `\`โšก ยฟ${await tr("Quieres un bot para tu grupo?")}\`
  94. Puedes solicitarlo *GRATIS* escribiendo a mi creador Crxs
  95. \`โšก ยฟEl bot estarรก activo 24/7?\`
  96. > _*Sรญ, nuestro bot estรก alojado en un servidor de pago para mantenerlo activo 24/7.*_
  97. > ใ€Œ แด‹แด€ษดแด›แดœ - ส™แดแด› ใ€`,
  98. m,
  99. {
  100. contextInfo: {
  101. externalAdReply: {
  102. mediaUrl: null,
  103. mediaType: 1,
  104. description: null,
  105. title: `Hola ${name} ๐Ÿ‘‹`,
  106. body: wm,
  107. previewType: 0,
  108. thumbnail: img.getRandom(),
  109. sourceUrl: redes.getRandom()
  110. }
  111. }
  112. }
  113. );
  114. }
  115. try {
  116. let prefixRegex = new RegExp(
  117. '^[' +
  118. setting.prefix.replace(/[|\\{}()[\]^$+*.\-\^]/g, '\\$&') +
  119. ']'
  120. );
  121. let hasPrefixWithKeyword =
  122. prefixRegex.test(m.text) &&
  123. m.text.match(
  124. new RegExp(
  125. '^[' +
  126. setting.prefix.replace(/[|\\{}()[\]^$+*.\-\^]/g, '\\$&') +
  127. '](?:bot|Bot|simsimi|simi|alexa|kantu|Kantu|kantubot|Kantubot)'
  128. )
  129. );
  130. let hasKeywordWithoutPrefix =
  131. (
  132. m.text.includes('bot') ||
  133. m.text.includes('Bot') ||
  134. m.text.includes('simsimi') ||
  135. m.text.includes('simi') ||
  136. m.text.includes('alexa') ||
  137. m.text.includes('kantu') ||
  138. m.text.includes('Kantu') ||
  139. m.text.includes('kantubot') ||
  140. m.text.includes('Kantubot')
  141. ) && !prefixRegex.test(m.text);
  142. if (!hasPrefixWithKeyword && !hasKeywordWithoutPrefix) return;
  143. let query = m.text;
  144. if (hasPrefixWithKeyword) {
  145. query = m.text
  146. .replace(prefixRegex, '')
  147. .replace(
  148. /^(?:bot|Bot|simsimi|simi|alexa|kantu|Kantu|kantubot|Kantubot)/i,
  149. ''
  150. )
  151. .trim();
  152. } else if (hasKeywordWithoutPrefix) {
  153. const keywordRegex = /^(?:bot|Bot|simsimi|simi|alexa|kantu|Kantu|kantubot|Kantubot)\s+/i;
  154. if (keywordRegex.test(m.text)) {
  155. query = m.text.replace(keywordRegex, '').trim();
  156. } else {
  157. query = m.text.trim();
  158. }
  159. }
  160. if (!query) return;
  161. conn.sendPresenceUpdate('composing', m.chat);
  162. antiSpam.set(m.sender, currentTime);
  163. async function luminsesi(q, username, logic) {
  164. try {
  165. const response = await axios.post('https://luminai.my.id', {
  166. content: q,
  167. user: username,
  168. prompt: logic,
  169. webSearchMode: true
  170. });
  171. return response.data.result;
  172. } catch (error) {
  173. console.error(error);
  174. }
  175. }
  176. async function perplexityIA(q, logic) {
  177. try {
  178. let response = await perplexity.chat(
  179. [
  180. { role: 'system', content: logic || syms1 },
  181. { role: 'user', content: q }
  182. ],
  183. 'sonar-pro'
  184. );
  185. if (response.status) {
  186. return response.result.response;
  187. } else {
  188. throw new Error(`Error en Perplexity: ${response.result.error}`);
  189. }
  190. } catch (error) {
  191. console.error('Error en Perplexity:', error);
  192. return null;
  193. }
  194. }
  195. async function SimSimi(text, language = 'es') {
  196. try {
  197. const { data } = await axios.post(
  198. 'https://api.simsimi.vn/v1/simtalk',
  199. new URLSearchParams({ text, lc: language }).toString(),
  200. {
  201. headers: {
  202. 'Content-Type': 'application/x-www-form-urlencoded',
  203. 'User-Agent':
  204. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
  205. }
  206. }
  207. );
  208. return data.message;
  209. } catch (error) {
  210. console.error(error);
  211. return null;
  212. }
  213. }
  214. let username = `${m.pushName}`;
  215. let syms1 = await fetch(
  216. 'https://raw.githubusercontent.com/crxsmods/text2/refs/heads/main/text-chatgpt'
  217. ).then(v => v.text());
  218. let result;
  219. if (!result || result.trim().length === 0) {
  220. result = await perplexityIA(query, syms1);
  221. }
  222. if (!result || result.trim().length === 0) {
  223. result = await SimSimi(query);
  224. }
  225. if (!result || result.trim().length === 0) {
  226. result = await luminsesi(query, username, syms1);
  227. result = result
  228. .replace(
  229. /Maaf, terjadi kesalahan saat memproses permintaan Anda/g,
  230. ''
  231. )
  232. .trim();
  233. result = result
  234. .replace(
  235. /Generated by BLACKBOX\.AI.*?https:\/\/www\.blackbox\.ai/g,
  236. ''
  237. )
  238. .trim();
  239. result = result
  240. .replace(
  241. /and for API requests replace https:\/\/www\.blackbox\.ai with https:\/\/api\.blackbox\.ai/g,
  242. ''
  243. )
  244. .trim();
  245. }
  246. if (result && result.trim().length > 0) {
  247. await conn.reply(m.chat, result, m);
  248. antiSpam.set(m.sender, Date.now());
  249. }
  250. } catch (e) {
  251. try {
  252. let gpt = await fetch(`${apis}/tools/simi?text=${m.text}`);
  253. let res = await gpt.json();
  254. await m.reply(res.data.message);
  255. antiSpam.set(m.sender, Date.now());
  256. } catch (e) {
  257. return m.reply(
  258. [
  259. `Simsimi esta durmiendo no molesta ๐Ÿฅฑ`,
  260. `Callarte`,
  261. `Api simsimi caida`,
  262. `Simsimi esta ocupado cojieron con tu hermana vuelva mas tarde ๐Ÿฅต`,
  263. `NO MOLESTE PUTA`,
  264. `No hay seรฑar`,
  265. `No estoy disponible`
  266. ].getRandom()
  267. );
  268. console.log(e);
  269. }
  270. }
  271. }
  272. if (/^infohost|hosting$/i.test(m.text)) {
  273. await conn.sendMessage(
  274. m.chat,
  275. {
  276. text: txt,
  277. contextInfo: {
  278. forwardingScore: 9999999,
  279. isForwarded: false,
  280. externalAdReply: {
  281. showAdAttribution: true,
  282. containsAutoReply: true,
  283. title: `๐Ÿ’Ž KANTU BOT ๐Ÿ’Ž`,
  284. body: `By CrxsMods`,
  285. previewType: 'PHOTO',
  286. thumbnailUrl:
  287. 'https://cdn.dorratz.com/files/1739136628132.jpg',
  288. sourceUrl: nna
  289. }
  290. }
  291. },
  292. { quoted: m }
  293. );
  294. }
  295. if (/^todo bien$/i.test(m.text)) {
  296. conn.reply(m.chat, `๐‘ฉ๐’Š๐’†๐’ ๐’„๐’‚๐’‘๐’ ๐Ÿ˜Ž ๐’š ๐’•๐’–`, m);
  297. }
  298. if (/^e$/i.test(m.text)) {
  299. conn.reply(
  300. m.chat,
  301. `๐‘ธ๐’–๐’† ๐’ƒ๐’–๐’†๐’๐’ ๐’”๐’‚๐’ƒ๐’†๐’“ ๐’๐’‚ ๐’๐’†๐’•๐’“๐’‚ ๐’†`,
  302. m
  303. );
  304. }
  305. if (/^@5217121649714|CrxsMods$/i.test(m.text)) {
  306. conn.reply(
  307. m.chat,
  308. `*_[ โš  ๏ธ] No etiquetes a mi creador, si tiene alguna consulta o dudas, hablarle al privado_*`,
  309. m
  310. );
  311. }
  312. if (/^reglas$/i.test(m.text)) {
  313. m.reply(
  314. [
  315. `\`๐ŸŒ REGLAS DEL BOT ๐ŸŒ\`\n\n* *No hacer spam de comandos*\n\nUsar los comando cada 5 segundos, de lo contrario el bot se puede satura, o numero del bot puede irse a support por spam.\n\n* *No estar enviando link del grupos al bot para que se una*\n\nHablar con mi creador y el lo une a tu grupo, si apoyar nuestras redes sociales:\n${yt}\n${md}\n\n* *No llamar al bot, ni al creador*\n\nSi lo haces, seras baneado del bot y bloqueado`,
  316. `\`โš ๏ธ ๐™๐™€๐™‚๐™‡๐˜ผ๐™Ž โš ๏ธ\`
  317. * ๐๐ซ๐จ๐ก๐ข๐›๐ข๐๐จ ๐ฅ๐ฅ๐š๐ฆ๐š๐ซ ๐š๐ฅ ๐๐จ๐ญ
  318. * ๐๐ซ๐จ๐ก๐ข๐›๐ข๐๐จ ๐’๐ฉ๐š๐ฆ ๐š๐ฅ ๐๐จ๐ญ
  319. * ๐๐จ ๐š๐ ๐ซ๐ž๐ ๐š๐ซ ๐š๐ฅ ๐๐จ๐ญ
  320. * ๐‘๐ž๐ฌ๐ฉ๐ž๐ญ๐š ๐ฅ๐จ๐ฌ ๐ญ๐ž๐ซ๐ฆ๐ข๐ง๐จ๐ฌ ๐ฒ ๐œ๐จ๐ง๐๐ข๐œ๐ข๐จ๐ง๐ž๐ฌ`
  321. ].getRandom() + `\n\n>ใ€Œ แด‹แด€ษดแด›แดœ - ส™แดแด› ใ€`
  322. );
  323. }
  324. return !0;
  325. }
  326. //export default handler
  327. function pickRandom(list) {
  328. return list[Math.floor(Math.random() * list.length)];
  329. }