Skip to content

Commit

Permalink
rbot-remote: allow override of function
Browse files Browse the repository at this point in the history
  • Loading branch information
Oblomov authored and mattzque committed Jun 9, 2021
1 parent 09849eb commit 3ace72d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bin/rbot-remote
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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")
}

0 comments on commit 3ace72d

Please sign in to comment.