-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to filter updates with allowed_updates? #243
Comments
This feature would certainly be useful 👍 First, the current implementation of the TelegramBot#getUpdates() does not allow us to pass the Second, we need a way to provide parameters to be re-used during polling, in our Constructor. For example, const bot = new TelegramBot(token, {
polling: {
// parameters reused in each request during polling
params: {
"allowed_updates": ["message", "edited_channel_post", "callback_query"],
},
},
}); This will also allow us to pass an (DONE — commit) |
@GochoMugo or, instead of allowing users specify which updates they wanna receive, what about building that list based on the updates they listen to? this.allowedUpdates = [];
on(event, callback) {
super(event, callback);
this.addAllowedUpdate(event);
}
addAllowedUpdate(event) {
if (!this.allowedUpdates.includes(event) {
this.allowedUpdates.push(event);
}
}
onText() {
// other stuff
addAllowedUpdate('message');
} |
Feature: Please see the updated API reference for more information on this new option. Side-effects: * `options.timeout` is deprecated! References: * "Feature request": #243
I have just added this enhancement (in commit e75d51ca8fe46059e78a74e1ece7787c881157cb). Please try out the updated master branch's code to see this feature in action. See documentation on @GingerPlusPlus Sorry, I felt your way being too complex. We would have to coordinate when polling starts and when are done scanning for the allowed updates. However, we can discuss more on it, in depth (preferably in an entirely new issue). |
Added: 1. Add constructor options: * (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux) 1. Add methods: * (#74) *TelegramBot#removeReplyListener()* (by @githugger) 1. (#283) Add proper error handling (by @GochoMugo) 1. (#272) Add health-check endpoint (by @mironov) * `options.webHook.healthEndpoint` 1. (#152) Add test for TelegramBot#sendDocument() using 'fileOpts' param (by @evolun) 1. Document `options.webHook.host` (by @GochoMugo) 1. (#264) Add Bot API version to README (by @kamikazechaser) 1. Add examples: - (#271) WebHook on Heroku (by @TheBeastOfCaerbannog) - (#274) WebHook on Zeit Now (by @ferrari) Changed: 1. (#147) Use *String#indexOf()*, instead of *RegExp#test()*, to find token in webhook request (by @AVVS) Fixed: * Fix bug: - (#275, #280) fix es6 syntax error on Node.js v4.x (by @CrazyAbdul) - (#276) promise.warning from `request-promise` (by @GochoMugo, reported-by @preco21) - (#281) fix handling error during polling (by @GochoMugo, reported-by @dimawebmaker) - (#284) fix error during deletion of already-set webhook, during polling (by @GochoMugo, reported-by @dcparga) 1. Fix links in documentation (by @Ni2c2k)
Shipped in v0.27.0. Thanks @sidelux and @GingerPlusPlus for contributing to this feature. |
Feature: Please see the updated API reference for more information on this new option. Side-effects: * `options.timeout` is deprecated! References: * "Feature request": yagop/node-telegram-bot-api#243
Feature: Please see the updated API reference for more information on this new option. Side-effects: * `options.timeout` is deprecated! References: * "Feature request": yagop/node-telegram-bot-api#243
I read days ago new api version where telegram now take possibility to filter incoming update with allowed_updates in getUpdates method.
How can i write this method correctly to receive only text messages and edited messages?
Thanks a lot!
The text was updated successfully, but these errors were encountered: