Skip to content

Commit

Permalink
😎 Won't redundantly execute
Browse files Browse the repository at this point in the history
  • Loading branch information
HeySreelal committed Apr 15, 2024
1 parent 5e2368a commit f540e67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/src/televerse/bot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ class Bot {
}

if (sub[i].handler == null) continue;
if (sub[i].isExecuted) continue;

_preProcess(sub[i], context);

Expand Down
13 changes: 3 additions & 10 deletions lib/src/televerse/models/handler_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ part of 'models.dart';

/// A Handler Scope is used to define the scope and related information of a handler method.
class HandlerScope {
/// Whether the handler is a special handler.
///
/// True if it's a command handler or a RegExp handler.
///
/// - If it's a command handler, we set `args` to the parameter of the command.
/// - If it's a RegExp handler, we'll set the `MessageContext.matches` to the matches of the RegExp.
final bool special;

/// If it's a command handler, we set `args` to the parameter of the command.
final bool isCommand;

Expand All @@ -20,6 +12,8 @@ class HandlerScope {
final RegExp? pattern;

/// Handler
///
/// Required unless [isConversation] is `true`.
final Handler? handler;

/// The update type
Expand Down Expand Up @@ -52,8 +46,7 @@ class HandlerScope {
this.chatId,
this.options,
this.isExecuted = false,
}) : special = isCommand || isRegExp,
assert(handler != null || isConversation);
}) : assert(handler != null || isConversation);

/// Whether the scope is forked or not.
bool get forked => options?.forked ?? false;
Expand Down

0 comments on commit f540e67

Please sign in to comment.