uninstall method
Uninstalls the plugin from the given bot.
This method should clean up any resources created during installation. The default implementation does nothing, but plugins that create persistent resources (timers, connections, etc.) should override this.
Parameters:
bot
: The bot instance to uninstall the plugin from
Implementation
@override
void uninstall(Bot<CTX> bot) {
_instance = null;
_cleanupTimer?.cancel();
_cleanupTimer = null;
// Clear storage if it's memory storage
if (storage is MemoryConversationStorage) {
(storage as MemoryConversationStorage).clear();
}
// Complete any waiting conversations with an error
for (final waitingConversation in _waitingConversations.values) {
if (!waitingConversation.completer.isCompleted) {
waitingConversation.timeoutTimer?.cancel();
waitingConversation.completer.completeError(
TeleverseException(
'Conversation plugin uninstalled',
type: TeleverseExceptionType.invalidParameter,
),
);
}
}
_waitingConversations.clear();
_conversations.clear();
}