Skip to content

Commit

Permalink
Split event command positionals
Browse files Browse the repository at this point in the history
  • Loading branch information
th3-z committed Oct 15, 2019
1 parent 283db45 commit d621e30
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ the `!op` command.
- Example: `!password on` Enables the game password defined in the config
- Example: `!password off` Disables the game password
- Example: `!password --set somePass` Sets a specific password
* `!start_jc <command>` - Start a command that runs every time a player joins
* `!start_jc -- <command>` - Start a command that runs every time a player joins
- Example: `!start_jc say Welcome %PLR` - Greets a player on join
- Available tokens: `%PLR` - username, `%KLL` - total kills, `%DSH` -
total dosh; `%PLR` - username, `%BCK` - "back" if sessions > 1, `%DRK` -
Expand All @@ -149,14 +149,14 @@ the `!op` command.
- `-w` Can be negative to count backwards from the boss wave
- Example: `!start_wc -1 say Welcome to the boss wave`
* `!stop_wc` - Stops all wave commands
* `!start_tc [-r, -t <seconds>] <command>` - Start a command that runs after
* `!start_tc [-r, -t <seconds>] -- <command>` - Start a command that runs after
`<seconds>` seconds
- Option `-r`: Add to have the command run repeatedly
- Option `-t`: Required, the number of seconds before the command runs
- Example: `!start_tc -rt 600 say Join our Steam group!\n
http://steam.group/`
* `!stop_tc` - Stops all timed commands
* `!start_trc [-w <wave>] <command>` - Start a commands that runs when the trader opens
* `!start_trc [-w <wave>] -- <command>` - Start a commands that runs when the trader opens
- `-w` Wave to run the command on, can be omitted to have the command
run every wave
- `-w` Can be negative to count backwards from the boss wave
Expand Down
30 changes: 15 additions & 15 deletions docs/steam_guide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,32 +167,32 @@ Commands that can be ran by server administrators, and users authorized with the
- Example: '[b]!password off[/b]' Disables the game password
- Example: '[b]!password --set superSekritPass[/b]' Sets a specific password

[*] '[b]!start_jc <command>[/b]' - Start a command that runs every time a player joins
- Example: '[b]!start_jc say Welcome %PLR[/b]' - Greets a player on join
[*] '[b]!start_jc -- <command>[/b]' - Start a command that runs every time a player joins
- Example: '[b]!start_jc -- say Welcome %PLR[/b]' - Greets a player on join
- Available tokens: '[b]%PLR[/b]' - username, '[b]%KLL[/b]' - total kills, '[b]%DSH[/b]' - total dosh, '[b]%BCK[/b]' - "back" if sessions > 1, '[b]%DRK[/b]' - dosh rank, '[b]%KRK[/b]' - kill rank, '[b]%TME[/b]' - play time, '[b]%TRK[/b]' - play time rank, '[b]%SES[/b]' - sessions

[*] '[b]!stop_jc[/b]' - Stops all join commands

[*] '[b]!start_wc [-w <wave>] <command>[/b]' - Start a command that runs on wave '<wave>'
[*] '[b]!start_wc [-w <wave>] -- <command>[/b]' - Start a command that runs on wave '<wave>'
- Option '[b]-w[/b]': Wave to run the command on, can be omitted to have the command
run every wave
- Option '[b]-w[/b]': Can be negative to count backwards from the boss wave
- Example: '[b]!start_wc -1 say Welcome to the boss wave[/b]'
- Example: '[b]!start_wc -1 -- say Welcome to the boss wave[/b]'

[*] '[b]!stop_wc[/b]' - Stops all wave commands

[*] '[b]!start_tc [-r, -t <seconds>] <command>[/b]' - Start a command that runs after
[*] '[b]!start_tc [-r, -t <seconds>] -- <command>[/b]' - Start a command that runs after
'<seconds>' seconds
- Option '[b]-r[/b]': Add to have the command run repeatedly
- Option '[b]-t[/b]': Required, the number of seconds before the command runs
- Example: '[b]!start_tc -rt 600 say Join our Steam group!\n http://steam.group/[/b]'
- Example: '[b]!start_tc -rt 600 -- say Join our Steam group!\n http://steam.group/[/b]'

[*] '[b]!stop_tc[/b]' - Stops all timed commands

[*] '[b]!start_trc [-w <wave>] <command>[/b]' - Start a commands that runs when the trader opens
[*] '[b]!start_trc [-w <wave>] -- <command>[/b]' - Start a commands that runs when the trader opens
- Option '[b]-w[/b]': Wave to run the command on, can be omitted to have the command run every wave
- Option '[b]-w[/b]': Can be negative to count backwards from the boss wave
- Example: '[b]!start_trc top_wave_dosh[/b]' - Shows who earned the most dosh every wave when the trader opens
- Example: '[b]!start_trc -- top_wave_dosh[/b]' - Shows who earned the most dosh every wave when the trader opens

[*] '[b]!stop_trc[/b]' - Stop all commands that run on trader open

Expand All @@ -205,10 +205,10 @@ Commands that can be ran by server administrators, and users authorized with the
- Example: '[b]!marquee example[/b]'

[*] '[b]!enforce_dosh <amount>[/b]' - Kicks all players that have more dosh than the specified amount.
- Example: '[b]!start_tc 600 enforce_dosh 60000[/b]'
- Example: '[b]!start_tc 600 -- enforce_dosh 60000[/b]'

[*] '[b]!update_motd <type>[/b]' - Refreshes the welcome screen leaderboard, type is one of: kills, dosh, or time
- Example: '[b]!start_tc 300 update_motd kills[/b]'
- Example: '[b]!start_tc 300 -- update_motd kills[/b]'

[*] '[b]!reload_motd[/b]' - Reloads the server's '[b]*.motd[/b]' file from '[b]conf[/b]'
[/list]
Expand All @@ -232,7 +232,7 @@ Have fun and good luck!
KF2 Magicked Admin will replace '[b]%PLR[/b]' with the player's username, '[b]%SCR[/b]' with the player's total kills or total dosh, '[b]%SRV_K[/b]' with the global server kills, and '[b]%SRV_D[/b]' with the global server dosh.

Once the file is written, use the '[b]!update_motd <type>[/b]' command to refresh the leaderboard. This should be used in combination with '[b]!start_tc <refresh_interval>[/b]' so that it is refreshed automatically.
- Example: '[b]!start_tc 300 update_motd dosh[/b]'
- Example: '[b]!start_tc 300 -- update_motd dosh[/b]'

The metric for '[b]%SCR[/b]' can be either 'kills', 'time', or 'dosh'. This is can be set by changing the '[b]<type>[/b]' parameter when using '[b]!update_motd <type>[/b]'

Expand Down Expand Up @@ -273,14 +273,14 @@ These scripts are formatted much the same as the init script, the commands will
Some commands are particularly useful when used in scripts, these are: '[b]!start_tc[/b]', '[b]!start_trc[/b]', '[b]!start_wc[/b]', '[b]!start_jc[/b]', '[b]!top_wave_kills[/b]', '[b]!top_wave_dosh[/b]', '[b]!enforce_dosh[/b]', '[b]!say[/b]'.

'[b]conf/scripts/server_one.init[/b]' - [i]Show who earned the most dosh each wave when the trader opens, and update the welcome screen leaderboard every 5 minutes[/i]
[code] start_trc top_wave_dosh
start_tc 300 update_motd dosh[/code]
[code] start_trc -- top_wave_dosh
start_tc 300 -- update_motd dosh[/code]

'[b]conf/scripts/server_one.init[/b]' - [i]Advertise your Steam group when the boss wave is reached[/i]
[code] start_wc -w -1 say Join our steam group: http://our.steam/group[/code]
[code] start_wc -w -1 -- say Join our steam group: http://our.steam/group[/code]

'[b]conf/scripts/server_one.init[/b]' - [i]Provide basic bot usage guidance to players[/i]
[code] start_tc -rt 800 say I'm a bot, type !commands to see available commands[/code]
[code] start_tc -rt 800 -- say I'm a bot, type !commands to see available commands[/code]

'[b]conf/scripts/priv_game[/b]' - [i]Setup a private lobby with a single command[/i]
[code]silent -q
Expand Down
4 changes: 2 additions & 2 deletions magicked_admin/chatbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
silent --quiet
; start_wc --wave -1 say If I wasn't commented you'd see this on the boss wave
start_trc top_wave_dosh
start_trc -- top_wave_dosh
; Start the default greeter script `conf/scripts/greeter`
run greeter
; Update the motd scoreboard every 5 minutes
start_tc --repeat --time 300 update_motd -q dosh
start_tc --repeat --time 300 -- update_motd -q dosh
; Re-enable chat output
silent --quiet
Expand Down
15 changes: 14 additions & 1 deletion magicked_admin/chatbot/commands/event_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
CommandOnTrader, CommandOnWave)
from . import ALL_WAVES
from .command import Command
from utils import warning

_ = gettext.gettext

Expand All @@ -22,6 +23,9 @@ def __init__(self, server, scheduler):
self.run_delay = 5

def execute(self, username, args, user_flags):
if "--" not in args:
warning(_("Ambiguous event command, please use ' -- ' to separate "
"commands"))
args, err = self.parse_args(username, args, user_flags)
if err:
return err
Expand All @@ -34,7 +38,7 @@ def execute(self, username, args, user_flags):
)

delayed_command = [
"start_tc", "-qt", str(self.run_delay), *args.command
"start_tc", "-qt", str(self.run_delay), "--", *args.command
]

command = CommandOnJoin(self.server, " ".join(delayed_command))
Expand Down Expand Up @@ -77,6 +81,9 @@ def __init__(self, server, scheduler):
self.parser.add_argument("command", nargs="*")

def execute(self, username, args, user_flags):
if "--" not in args:
warning(_("Ambiguous event command, please use ' -- ' to separate "
"commands"))
args, err = self.parse_args(username, args, user_flags)
if err:
return err
Expand Down Expand Up @@ -142,6 +149,9 @@ def __init__(self, server, scheduler):
self.parser.add_argument("command", nargs="*")

def execute(self, username, args, user_flags):
if "--" not in args:
warning(_("Ambiguous event command, please use ' -- ' to separate "
"commands"))
args, err = self.parse_args(username, args, user_flags)
if err:
return err
Expand Down Expand Up @@ -212,6 +222,9 @@ def __init__(self, server, scheduler):
self.parser.add_argument("command", nargs="*")

def execute(self, username, args, user_flags):
if "--" not in args:
warning(_("Ambiguous event command, please use ' -- ' to separate "
"commands"))
args, err = self.parse_args(username, args, user_flags)
if err:
return err
Expand Down
2 changes: 1 addition & 1 deletion magicked_admin/conf/scripts/greeter
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
; %TME - Play time
; %TRK - Play time rank
; %SES - Sessions
start_jc -q say \nWelcome %BCK %PLR.\nYou've killed %KLL ZEDs, (#%KRK)\nearned £%DSH (#%DRK) and\nplayed for %TME over %SES sessions.
start_jc -q -- say \nWelcome %BCK %PLR.\nYou've killed %KLL ZEDs, (#%KRK)\nearned £%DSH (#%DRK) and\nplayed for %TME over %SES sessions.
say Greeter started

0 comments on commit d621e30

Please sign in to comment.