-
Notifications
You must be signed in to change notification settings - Fork 1
RawNotes
Special variables: $inventory $giveitem $item $chan for !op robot.variables.register_special 'inventory', (user, msg) ->
robot.brain.#getuser#.gender %gender_vars - #L127 { verb: { # id = 901 readonly: 1 type: verb, values: ['hug'] }, noun: { readonly: 1 type: "noun", values: [] }, superhero: { readonly: 1, type: "var", values: [] } }
/^remove value (\w+) (.+)$/ $var = msg.match[0] # check for existing msg.reply "Sorry, $who, I don't know of a variable '$var'." return # else check for protected msg.reply "Sorry, $who, you don't have permission to edit '$var'." # else delete from robot brain
/^add value (\w+) (.*)$/, (msg) -> L1192 - exists L1199 - editable L1204 - check for nested value L1211 - check for duplicate msg.send "Okay, $who." update brain
/^create var (\w+)$/ "Sorry, $who, there already exists variable '$var'." update brain, readonly: 1, type: "var" msg.send "Okay, $who."
/^remove var (\w+)\s*(!+)?$/
"Sorry, $who, there isn't a variable '$var'."
"$who, this action cannot be undone. If you want to proceed append a '!'" )
"Okay,
/^var (\w+) type (var|verb|noun)$/
"Sorry, $who, there isn't a variable '$var'."
"Srorry, $who, you don't have permission to edit '$var'."
msg.send "Okay, $who."
/^list var (\w+)$/, (msg) -> @make_list msg, @robot.brain.variables[msg.match[0]]
sub make_list { my @list = @_;
return "" unless @list;
return $list[0] if @list == 1;
return join " and ", @list if @list == 2;
my $last = $list[-1];
return join( ", ", @list[ 0 .. $#list - 1 ] ) . ", and $last";
}