From 0b0390dbd7811cb7983a9532632c457f666ed6aa Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 23 Apr 2019 18:22:52 -0700 Subject: [PATCH] Spinach: add set/unset commands to modify metadata --- PBot/Plugins/Spinach.pm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/PBot/Plugins/Spinach.pm b/PBot/Plugins/Spinach.pm index 4e04d67d..9ed6d29e 100644 --- a/PBot/Plugins/Spinach.pm +++ b/PBot/Plugins/Spinach.pm @@ -233,7 +233,7 @@ sub spinach_cmd { my ($self, $from, $nick, $user, $host, $arguments) = @_; $arguments =~ s/^\s+|\s+$//g; - my $usage = "Usage: spinach join|exit|ready|unready|choose|lie|reroll|skip|score|show|categories|filter|kick|abort; for more information about a command: spinach help "; + my $usage = "Usage: spinach join|exit|ready|unready|choose|lie|reroll|skip|score|show|categories|filter|set|unset|kick|abort; for more information about a command: spinach help "; my $command; ($command, $arguments) = split / /, $arguments, 2; @@ -312,6 +312,14 @@ sub spinach_cmd { return "Help is coming soon."; } + when ('set') { + return "Help is coming soon."; + } + + when ('unset') { + return "Help is coming soon."; + } + default { if (length $arguments) { return "Spinach has no such command '$arguments'. I can't help you with that."; @@ -862,6 +870,24 @@ sub spinach_cmd { } } + when ('set') { + my ($index, $key, $value) = split /\s+/, $arguments; + + if (not defined $index) { + return "Usage: spinach set [key [value]]"; + } + return $self->{metadata}->set($index, $key, $value); + } + + when ('unset') { + my ($index, $key) = split /\s+/, $arguments; + + if (not defined $index or not defined $key) { + return "Usage: spinach unset "; + } + return $self->{metadata}->unset($index, $key); + } + default { return $usage; }