diff options
| author | 2026-02-27 01:24:57 +0000 | |
|---|---|---|
| committer | 2026-02-27 01:45:40 +0000 | |
| commit | ff18ee420e229a34b874a1a03ae302fdf60fe149 (patch) | |
| tree | 8cabc848ea796dc03fd2e616588f1a451aad2106 /include/command.h | |
| parent | Merge branch 'insp4' into master. (diff) | |
Implement support for per-command maximum targets.
Closes #2157.
Diffstat (limited to 'include/command.h')
| -rw-r--r-- | include/command.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/include/command.h b/include/command.h index 8ba900b82..f0572723c 100644 --- a/include/command.h +++ b/include/command.h @@ -223,6 +223,13 @@ public: class CoreExport Command : public CommandBase { +private: + /** The maximum number of targets for a multi-target command (e.g. KICK). */ + size_t max_targets = 0; + + /** The time at which max_targets was last checked. */ + time_t max_targets_checked = 0; + protected: /** Initializes a new instance of the Command class. * @param me The module which created this instance. @@ -236,6 +243,9 @@ public: /** Unregisters this command from the command parser. */ ~Command() override; + /** Whether this command accepts multiple targets. */ + bool accepts_multiple_targets = false; + /** Who can access this command? */ CmdAccess access_needed = CmdAccess::NORMAL; @@ -254,6 +264,9 @@ public: /** Whether the command can be issued before registering. */ bool works_before_reg = false; + /** Retrieves the maximum number of targets this command can accept. */ + size_t GetMaxTargets(); + /** Handle the command from a user. * @param user The user who issued the command. * @param parameters The parameters for the command. @@ -374,7 +387,7 @@ public: * If there is only one list and there are duplicates in it, then the command handler is only called for * unique items. Entries are compared using "irc comparison". * If the usemax parameter is true (the default) the function only parses until it reaches - * ServerInstance->Config->MaxTargets number of targets, to stop abuse via spam. + * <maxtargets> number of targets, to stop abuse via spam. * * The OnPostCommand hook is executed for each item after it has been processed by the handler, with the * original line parameter being empty (to indicate that the command in that form was created by this function). @@ -392,7 +405,7 @@ public: * @param parameters Parameter list as a vector of strings * @param splithere The first parameter index to split as a comma separated list * @param extra The second parameter index to split as a comma separated list, or -1 (the default) if there is only one list - * @param usemax True to limit the command to MaxTargets targets (default), or false to process all tokens + * @param usemax True to limit the command to <maxtargets> targets (default), or false to process all tokens * @return This function returns true when it identified a list in the given parameter and finished calling the * command handler for each entry on the list. When this occurs, the caller should return without doing anything, * otherwise it should continue into its main section of code. |
