Closed 0xCA closed 4 years ago
This ability is not responsibility of this library. Whereas, the native function process.exit()
is able to terminate any process regardless of what is keeping it active
try to use it this way:
const telegram = require('telegram-bot-api');
const api = new telegram({
token: ''
});
api.sendPhoto({
chat_id,
photo: './img.jpg',
}).then(()=>process.exit())
More information: https://stackoverflow.com/questions/5266152/how-to-exit-in-node-js
In case you don't need to receive updates. Another even simpler way is:
var api = new telegram({
token: '',
updates: {
enabled: false
}
});
The process will end after executing all the api-calls in the script
Stop functionality for getUpdates and webhook will be available in 2.0 which is under development
Fixed in 2.0
Once the bot is created it runs forever and there is no way to stop it. Please add this ability.