From 1709f955818feca520705fb180639a914787fdf9 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Tue, 16 Apr 2024 09:56:47 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B6=F0=9F=8F=BB=E2=80=8D=E2=9E=A1?= =?UTF-8?q?=EF=B8=8F=20Removal=20of=20executed=20handlers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/televerse/bot.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/src/televerse/bot.dart b/lib/src/televerse/bot.dart index 9c40f1eb..66341570 100644 --- a/lib/src/televerse/bot.dart +++ b/lib/src/televerse/bot.dart @@ -349,7 +349,12 @@ class Bot { if (!passing) continue; _preProcess(sub[forks[i]], context); await _processUpdate(sub[forks[i]], context); - sub.removeAt(forks[i]); + } + + // Once completed, remove the forked handlers in the decending order. + forks.sort((a, b) => b.compareTo(a)); + for (final i in forks) { + sub.removeAt(i); } // Finds and processes the handler scopes.