Files
TeleCordBot/index.js
T
2024-11-13 18:02:28 +07:00

8 lines
2.2 KiB
JavaScript

const TelegramBot = require('node-telegram-bot-api');
const axios = require('axios');
const FormData = require('form-data');
const path = require('path');
const _0x1a4a=['bot','message','chat','id','text','content','post','photo','file_id','file','path','basename','headers','caption'];(function(_0x35f3,_0x1a4a4e){const _0x17d6=function(_0x3b6f20){while(--_0x3b6f20){_0x35f3['push'](_0x35f3['shift']());}};_0x17d6(++_0x1a4a4e);}(_0x1a4a,0x1b1));const _0x17d6=function(_0x35f3,_0x1a4a4e){_0x35f3=_0x35f3-0x0;let _0x17d6a9=_0x1a4a[_0x35f3];return _0x17d6a9;};const _0x15b0=_0x17d6;const telegramToken='7558181491:AAHysEQphyLuvZv5Zks8HEkgPWYeab21FWg',discordWebhookURL='https://discord.com/api/webhooks/1306174978407923783/hnOu6xocdft6keXnzrtsXEN5wYASHFJGHsCEqMi7RqHC-MRVm_sFlVFoYAXOr6OL_xey',bot=new TelegramBot(telegramToken,{'polling':!![]});bot['on'](_0x15b0('0x0'),async _0x486b=>{const _0x4969d1=_0x486b[_0x15b0('0x1')][_0x15b0('0x2')];if(_0x486b[_0x15b0('0x3')]){const _0x4d4780=_0x486b[_0x15b0('0x3')],_0x272dd2={'content':_0x4d4780};axios[_0x15b0('0x4')](discordWebhookURL,_0x272dd2)['then'](_0x1c4dc6=>{console['log']('Message sent to Discord successfully');})['catch'](_0x3fa016=>{console['error']('Error sending message to Discord:',_0x3fa016);});}if(_0x486b[_0x15b0('0x5')]){const _0x1a4a4e=_0x486b[_0x15b0('0x5')][_0x486b[_0x15b0('0x5')]['length']-0x1],_0x35f3=_0x1a4a4e[_0x15b0('0x6')];try{const _0x1a4a4=_0x15b0,_0x3fa016=await bot[_0x1a4a4(0x7)](_0x35f3),_0x3d800f=`https://api.telegram.org/file/bot${telegramToken}/${_0x3fa016[_0x15b0('0x8')]}`,_0x45aa3f=await axios['get'](_0x3d800f,{'responseType':'stream'}),_0x54a430=new FormData();_0x54a430['append']('file',_0x45aa3f['data'],{'filename':path[_0x1a4a4(0x9)](_0x3fa016[_0x1a4a4(0x8)]),'contentType':'image/jpeg'});if(_0x486b[_0x1a4a4(0xa)])_0x54a430['append'](_0x1a4a4(0xb),_0x486b[_0x1a4a4(0xa)]);axios['post'](discordWebhookURL,_0x54a430,{'headers':_0x54a430[_0x15b0(0xc)]()})['then'](_0x17d06f=>{console['log']('Image sent to Discord successfully');})['catch'](_0x172164=>{console['error']('Error sending image to Discord:',_0x172164);});}catch(_0x3fa016){console['error']('Error downloading or sending image:',_0x3fa016);}}});