clear method

Future<void> clear(
  1. ID id
)

Removes all the conversation listeners for the given chat.

Implementation

Future<void> clear(ID id) async {
  _bot._handlerScopes.removeWhere(
    (scope) =>
        scope.isConversation &&
        (scope.name?.startsWith(name) ?? false) &&
        scope.chatId == id,
  );

  final subsToCancel =
      _subscriptionsList.where((sub) => sub.scope.startsWith(name));
  await Future.wait(subsToCancel.map((sub) => sub.cancel()));
  _subscriptionsList.removeWhere((sub) => sub.scope.startsWith(name));
}