summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2021-06-09 11:27:57 +0200
committerMatthias Hecker <36882671+mattzque@users.noreply.github.com>2021-06-09 13:49:34 +0200
commit3ace72d5642284665fce2c33c99dfeb1b931b2c6 (patch)
tree79eed7aa61b6255ce3e34985258e5fa0c46a057c
parent09849eb8adb566b2f17a7ee533cc4a10ac379fe7 (diff)
rbot-remote: allow override of function
-rwxr-xr-xbin/rbot-remote6
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/rbot-remote b/bin/rbot-remote
index 0c1cd578..29005f63 100755
--- a/bin/rbot-remote
+++ b/bin/rbot-remote
@@ -17,12 +17,14 @@ require 'optparse'
user = nil
pw = nil
dst = nil
+function = 'say'
uri = 'http://localhost:7268/dispatch'
opts = OptionParser.new
opts.on('-u', '--user <user>', "remote user (mandatory)") { |v| user = v }
opts.on('-p', '--password <pw>', "remote user password (mandatory)") { |v| pw = v }
-opts.on('-d', '--destination <user or #channel>') { |v| dst = v }
+opts.on('-d', '--destination <user/#channel>', "destination of the action (mandatory)") { |v| dst = v }
+opts.on('-f', '--function <func>', "function to trigger (e.g. say, notify), default: #{function}") { |v| function = v }
opts.on('-r', '--uri <drb uri>', "rbot url (#{uri})") { |v| uri = v }
opts.on('-h', '--help', "this message") { |v| pw = nil } # sorry!
opts.on('-a', '--about', "what it's all about.") { |v|
@@ -68,7 +70,7 @@ uri.password = pw
loop {
s = gets or break
s.chomp!
- resp = Net::HTTP.post_form(uri, 'command' => ['say', dst, s].join(' '))
+ resp = Net::HTTP.post_form(uri, 'command' => [function, dst, s].join(' '))
puts [resp.code, resp.message, resp.body].join("\t")
}