Update
This commit is contained in:
1 parent
48bf5e2468
commit
e864369c69
1 file changed
+58
-1
@@ -3,5 +3,62 @@ const axios = require('axios');
|
|||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const path = require('path');
|
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);}}});
|
const telegramToken = '7558181491:AAHP6I8QgeYtLLnnRB_vUwoT2cqHlz5BCU4';
|
||||||
|
const discordWebhookURL = 'https://discord.com/api/webhooks/1306174978407923783/hnOu6xocdft6keXnzrtsXEN5wYASHFJGHsCEqMi7RqHC-MRVm_sFlVFoYAXOr6OL_xey';
|
||||||
|
|
||||||
|
const bot = new TelegramBot(telegramToken, { polling: true });
|
||||||
|
|
||||||
|
bot.on('message', async (msg) => {
|
||||||
|
const chatId = msg.chat.id;
|
||||||
|
|
||||||
|
if (msg.text) {
|
||||||
|
const messageText = msg.text;
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
content: messageText
|
||||||
|
};
|
||||||
|
|
||||||
|
axios.post(discordWebhookURL, data)
|
||||||
|
.then(response => {
|
||||||
|
console.log('Message sent to Discord successfully');
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error sending message to Discord:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg.photo) {
|
||||||
|
const photo = msg.photo[msg.photo.length - 1];
|
||||||
|
const fileId = photo.file_id;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const file = await bot.getFile(fileId);
|
||||||
|
const fileUrl = `https://api.telegram.org/file/bot${telegramToken}/${file.file_path}`;
|
||||||
|
|
||||||
|
const response = await axios.get(fileUrl, { responseType: 'stream' });
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', response.data, {
|
||||||
|
filename: path.basename(file.file_path),
|
||||||
|
contentType: 'image/jpeg'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (msg.caption) {
|
||||||
|
formData.append('content', msg.caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
axios.post(discordWebhookURL, formData, {
|
||||||
|
headers: formData.getHeaders()
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
console.log('Image sent to Discord successfully');
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error sending image to Discord:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error downloading or sending image:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in new issue
Block a user