-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Allow arbitrary RCon commands in chat commands #678
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Florian <florian.schmidt.welzow@t-online.de>
These conditions work in a very same way as conditions in Auto Settings (they are shared between them both). All conditions are available in chat rcon commands, conditions that rely on the player_id metric are only available in chat commands. Using these conditions in auto settings will implicitly default to "condition is met". Two new conditions are available for chat commands (requiring the player_id metric source): - player_flags: A condition that is met, when the player has at least one of the provided flags. A list of flags can be provided, which are combined with OR, meaning that the player requires only one of these flags to meet the condition. - player_id: A condition thgat is met, when the player's ID is in the provided list of static IDs. This ID can either be the player's Steam ID or Windows ID, depending on whatever the player's platform is Allowing the use of the auto settings conditions is a bit redundant, as a single chat command can still be enabled and disabled using the set_chat_command_enabled api, which is also available in auto settings. However, this gives the user freedom to enable/disable the command using auto settings, or by a condition in the command itself, whatever they prefer.
With conditions on chat commands, the main use case to allow autosettings enabling/disabling commands, this is not required anymore.
cemathey
approved these changes
Sep 23, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of things in here I think we should probably tweak but it builds/worked for me and I don't want to be too picky.
…con_chat_commands
Signed-off-by: Florian <florian.schmidt.welzow@t-online.de>
Dorfieeee
pushed a commit
that referenced
this pull request
Nov 26, 2024
* Allow to run arbitrary rcon commands from chat commands * add example for rcon command chat command * Allow autosettings to enable and disable single chat commands * Update api_commands.py Signed-off-by: Florian <florian.schmidt.welzow@t-online.de> * refactor chat commands * Add conditions to chat rcon commands These conditions work in a very same way as conditions in Auto Settings (they are shared between them both). All conditions are available in chat rcon commands, conditions that rely on the player_id metric are only available in chat commands. Using these conditions in auto settings will implicitly default to "condition is met". Two new conditions are available for chat commands (requiring the player_id metric source): - player_flags: A condition that is met, when the player has at least one of the provided flags. A list of flags can be provided, which are combined with OR, meaning that the player requires only one of these flags to meet the condition. - player_id: A condition thgat is met, when the player's ID is in the provided list of static IDs. This ID can either be the player's Steam ID or Windows ID, depending on whatever the player's platform is Allowing the use of the auto settings conditions is a bit redundant, as a single chat command can still be enabled and disabled using the set_chat_command_enabled api, which is also available in auto settings. However, this gives the user freedom to enable/disable the command using auto settings, or by a condition in the command itself, whatever they prefer. * WIP: Arguments in chat rcon commands * Remove api endpoint to enable/disable rcon chat commands With conditions on chat commands, the main use case to allow autosettings enabling/disabling commands, this is not required anymore. * WIP: Move rcon chat commands to a separate config * WIP: Seed default (disabled) rcon chat commands * add missing permissions, endpoints and default * correctly apply default * add redeploy example command * black/isort * command_words need to be on the base class as well --------- Signed-off-by: Florian <florian.schmidt.welzow@t-online.de> Co-authored-by: C. Eric Mathey <emathey@protonmail.com>
Dorfieeee
pushed a commit
that referenced
this pull request
Nov 26, 2024
* Allow to run arbitrary rcon commands from chat commands * add example for rcon command chat command * Allow autosettings to enable and disable single chat commands * Update api_commands.py Signed-off-by: Florian <florian.schmidt.welzow@t-online.de> * refactor chat commands * Add conditions to chat rcon commands These conditions work in a very same way as conditions in Auto Settings (they are shared between them both). All conditions are available in chat rcon commands, conditions that rely on the player_id metric are only available in chat commands. Using these conditions in auto settings will implicitly default to "condition is met". Two new conditions are available for chat commands (requiring the player_id metric source): - player_flags: A condition that is met, when the player has at least one of the provided flags. A list of flags can be provided, which are combined with OR, meaning that the player requires only one of these flags to meet the condition. - player_id: A condition thgat is met, when the player's ID is in the provided list of static IDs. This ID can either be the player's Steam ID or Windows ID, depending on whatever the player's platform is Allowing the use of the auto settings conditions is a bit redundant, as a single chat command can still be enabled and disabled using the set_chat_command_enabled api, which is also available in auto settings. However, this gives the user freedom to enable/disable the command using auto settings, or by a condition in the command itself, whatever they prefer. * WIP: Arguments in chat rcon commands * Remove api endpoint to enable/disable rcon chat commands With conditions on chat commands, the main use case to allow autosettings enabling/disabling commands, this is not required anymore. * WIP: Move rcon chat commands to a separate config * WIP: Seed default (disabled) rcon chat commands * add missing permissions, endpoints and default * correctly apply default * add redeploy example command * black/isort * command_words need to be on the base class as well --------- Signed-off-by: Florian <florian.schmidt.welzow@t-online.de> Co-authored-by: C. Eric Mathey <emathey@protonmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are communities that would like to use chat commands with a more powerful set of actions that can be triggered when a player uses a chat command. Two real-worl example from the "event server for prepping" use case:
Switching player side
Changing a side without needing to redeploy for themself, a command "!switch" is useful. Issuing this command will forward a switch_player_now RCon command with the player_name of the issuing player.
Redeploying with 10 instead of 20 seconds
Redeploying with the
punish
command might be useful when needing to redeploy for multiple times. A command "!redeploy", which issues apunish
command for the issuing player, might be useful here.This feature is implemented with this PR. A chat command can either have a
message
key or acommand
key (message takes precendence). Thecommand
config is an object that has the same signature and functinality as auto-settings commands.This allows for a powerful set of tools, while it also has some risks, as everything can now be executed with a player issuing a specific chat command.
The parameters of the command will replace message parameters same as the message itself, however, only context keys are populated. No other variables are available in commands params.
Example config
Conditions
As seen in the above example, conditions are available for these commands. This allows an admin to define commands which are only executed when the execution context matches certain conditions. These conditions are the same as in AutoSettings.
The PR adds two new conditions, which are only available when the metric source
player_id
is available. This metric source is currently only available in chat commands, not in auto settings. In auto settings, if one of these conditions is configured, it will always default to "condition is met".