9 # :title: webserver dispatch example script
11 # Author:: jsn (dmitry kim) <dmitry dot kim at gmail dot org>
12 # Copyright:: (C) 2007 dmitry kim
13 # License:: in public domain
14 # Modified by:: Giuseppe "Oblomov" Bilotta <giuseppe dot bilotta at gmail dot com>
15 # Copyright:: (C) 2020 Giuseppe Bilotta
21 uri = 'http://localhost:7268/dispatch'
23 opts = OptionParser.new
24 opts.on('-u', '--user <user>', "remote user (mandatory)") { |v| user = v }
25 opts.on('-p', '--password <pw>', "remote user password (mandatory)") { |v| pw = v }
26 opts.on('-d', '--destination <user/#channel>', "destination of the action (mandatory)") { |v| dst = v }
27 opts.on('-f', '--function <func>', "function to trigger (e.g. say, notify), default: #{function}") { |v| function = v }
28 opts.on('-r', '--uri <drb uri>', "rbot url (#{uri})") { |v| uri = v }
29 opts.on('-h', '--help', "this message") { |v| pw = nil } # sorry!
30 opts.on('-a', '--about', "what it's all about.") { |v|
32 This is just a proof-of-concept example for the rbot webserver dispatch feature.
33 This program reads lines of text from the standard input and sends them to a specified irc
34 channel or user via rbot. Make sure you enable the webservice dispatch feature
37 The necessary setup is:
38 1) # create a new rbot user ("rmuser", in this example) with a password
39 # ("rmpw", in this example). in an open query to rbot:
41 <you> user create rmuser rmpw
42 <rbot> created botuser remote
44 2) # add a permission to say for your newly created remote user:
46 <you> allow rmuser to do say #channel message
49 3) # run the #{$0} and type something. the message should
50 # show up on your channel / arrive as an irc private message.
52 [you@yourhost ~]$ ./bin/rbot-remote -u rmuser -p rmpw -d '#your-channel'
61 if !pw || !user || !dst
73 resp = Net::HTTP.post_form(uri, 'command' => [function, dst, s].join(' '))
74 puts [resp.code, resp.message, resp.body].join("\t")