binance-watch
binance-watch copied to clipboard
Telegram Bot API
Hi rainner
I think the Telegram Bot API section is not working Does it need to update the code?
Its and old repo, don't expect a update any time soon. Im trying to run the project and try to use a discord bot api instead
Its and old repo, don't expect a update any time soon. Im trying to run the project and try to use a discord bot api instead
Thanks This part of the code is related to Telegram
https://github.com/rainner/binance-watch/blob/b1f1cff2c624765bcc2c89a30f4fda30a6c5108e/src/modules/messenger.js#L140
/**
* Send queue messages using Telegram API
*/
_telegramSend() {
let { enabled, botkey, userid } = this._options.telegram;
if ( !enabled || !botkey || !userid || !this._ajax ) return;
let content = '';
this._queue.forEach( q => {
let { title, message } = q;
content += `<b>${ title }</b> \n`;
content += `${ message } \n`;
content += `\n`;
});
const fdata = new FormData();
fdata.append( 'chat_id', userid );
fdata.append( 'text', String( content ).trim() );
fdata.append( 'parse_mode', 'html' );
this._ajax.post( 'https://api.telegram.org/bot'+ botkey +'/sendMessage', {
type: 'json',
data: fdata,
done: ( xhr, status, response ) => {
if ( !response || !response.ok ) return console.warn( 'Telegram-API', status, response );
this.emit( 'sent', 'Telegram notifications sent to ('+ userid +').' );
},
});