Skip to content

Commit

Permalink
feat: add clear listener methods (#834)
Browse files Browse the repository at this point in the history
- by @daniel0611

Co-authored-by: Mohammed Sohail <sohailsameja@gmail.com>
  • Loading branch information
hlxid and kamikazechaser committed Dec 10, 2020
1 parent 3829e72 commit ec7e61e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ec7e61e

Please sign in to comment.