2
0
mirror of https://github.com/yagop/node-telegram-bot-api synced 2025-08-29 05:17:41 +00:00

feat: add clear listener methods (#834)

- by @daniel0611

Co-authored-by: Mohammed Sohail <sohailsameja@gmail.com>
This commit is contained in:
Daniel Huber 2020-12-10 12:30:09 +01:00 committed by GitHub
parent 3829e727aa
commit ec7e61e041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1681,6 +1681,13 @@ class TelegramBot extends EventEmitter {
return this._textRegexpCallbacks.splice(index, 1)[0];
}
/**
* Remove all listeners registered with `onText()`.
*/
clearTextListeners() {
this._textRegexpCallbacks = [];
}
/**
* Register a reply to wait for a message response.
* @param {Number|String} chatId The chat id where the message cames from.
@ -1717,6 +1724,13 @@ class TelegramBot extends EventEmitter {
return this._replyListeners.splice(index, 1)[0];
}
/**
* Removes all replies that have been prev. registered for a message response.
*/
clearReplyListeners() {
this._replyListeners = [];
}
/**
* Use this method to get up to date information about the chat
* (current name of the user for one-on-one conversations, current