From 3ace72d5642284665fce2c33c99dfeb1b931b2c6 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 9 Jun 2021 11:27:57 +0200 Subject: rbot-remote: allow override of function --- bin/rbot-remote | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin/rbot-remote') 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 ', "remote user (mandatory)") { |v| user = v } opts.on('-p', '--password ', "remote user password (mandatory)") { |v| pw = v } -opts.on('-d', '--destination ') { |v| dst = v } +opts.on('-d', '--destination ', "destination of the action (mandatory)") { |v| dst = v } +opts.on('-f', '--function ', "function to trigger (e.g. say, notify), default: #{function}") { |v| function = v } opts.on('-r', '--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") } -- cgit v1.2.3