kyuurzy

Reaction Channel WhatsApp

Dec 7th, 2025
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 3.15 KB | Source Code | 0 0
  1. const axios = require('axios')
  2.  
  3. const tokens = [
  4.     "TOKEN",
  5.     "TOKEN"
  6. ]
  7.  
  8. let currentTokenIndex = 0
  9.  
  10. async function reactToPost(postUrl, emojis) {
  11.     let attempts = 0
  12.     const maxAttempts = tokens.length
  13.  
  14.     while (attempts < maxAttempts) {
  15.         const apiKey = tokens[currentTokenIndex]
  16.        
  17.         try {
  18.             console.log(`🎯 Reacting to: ${postUrl}`)
  19.             console.log(`🎭 With emojis: ${emojis}`)
  20.             console.log(`🔑 Using token index: ${currentTokenIndex}`)
  21.  
  22.             const response = await axios({
  23.                 method: 'POST',
  24.                 url: `https://foreign-marna-sithaunarathnapromax-9a005c2e.koyeb.app/api/channel/react-to-post?apiKey=${apiKey}`,
  25.                 headers: {
  26.                     'authority': 'foreign-marna-sithaunarathnapromax-9a005c2e.koyeb.app',
  27.                     'accept': 'application/json, text/plain, */*',
  28.                     'accept-language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
  29.                     'content-type': 'application/json',
  30.                     'origin': 'https://asitha.top',
  31.                     'referer': 'https://asitha.top/',
  32.                     'sec-ch-ua': '"Chromium";v="139", "Not;A=Brand";v="99"',
  33.                     'sec-ch-ua-mobile': '?1',
  34.                     'sec-ch-ua-platform': '"Android"',
  35.                     'sec-fetch-dest': 'empty',
  36.                     'sec-fetch-mode': 'cors',
  37.                     'sec-fetch-site': 'cross-site',
  38.                     'user-agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Mobile Safari/537.36'
  39.                 },
  40.                 data: {
  41.                     post_link: postUrl,
  42.                     reacts: Array.isArray(emojis) ? emojis : [emojis]
  43.                 }
  44.             })
  45.  
  46.             console.log('✅ Success!')
  47.             return {
  48.                 success: true,
  49.                 data: response.data
  50.             }
  51.  
  52.         } catch (error) {
  53.             console.log(`❌ Token ${currentTokenIndex} failed:`, error.response?.data || error.message)
  54.            
  55.             if (error.response && error.response.status === 402) {
  56.                 currentTokenIndex = (currentTokenIndex + 1) % tokens.length
  57.                 attempts++
  58.                 console.log(`🔄 Switching to token index: ${currentTokenIndex}`)
  59.                 continue
  60.             }
  61.  
  62.             if (error.response?.data?.message?.includes('limit') || error.response?.data?.message?.includes('Limit')) {
  63.                 currentTokenIndex = (currentTokenIndex + 1) % tokens.length
  64.                 attempts++
  65.                 console.log(`🔄 Token limit, switching to index: ${currentTokenIndex}`)
  66.                 continue
  67.             }
  68.  
  69.             console.log('❌ Failed!')
  70.             return {
  71.                 success: false,
  72.                 error: error.response?.data || error.message,
  73.                 status: error.response?.status
  74.             }
  75.         }
  76.     }
  77.  
  78.     console.log('❌ All tokens limited!')
  79.     return {
  80.         success: false,
  81.         error: 'All tokens are limited',
  82.         status: 402
  83.     }
  84. }
  85.  
  86. module.exports = { reactToPost }
Advertisement
Add Comment
Please, Sign In to add comment