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
20 uri = 'http://localhost:7268/dispatch'
22 opts = OptionParser.new
23 opts.on('-u', '--user <user>', "remote user (mandatory)") { |v| user = v }
24 opts.on('-p', '--password <pw>', "remote user password (mandatory)") { |v| pw = v }
25 opts.on('-d', '--destination <user or #channel>') { |v| dst = v }
26 opts.on('-r', '--uri <drb uri>', "rbot url (#{uri})") { |v| uri = v }
27 opts.on('-h', '--help', "this message") { |v| pw = nil } # sorry!
28 opts.on('-a', '--about', "what it's all about.") { |v|
30 This is just a proof-of-concept example for the rbot webserver dispatch feature.
31 This program reads lines of text from the standard input and sends them to a specified irc
32 channel or user via rbot. Make sure you enable the webservice dispatch feature
35 The necessary setup is:
36 1) # create a new rbot user ("rmuser", in this example) with a password
37 # ("rmpw", in this example). in an open query to rbot:
39 <you> user create rmuser rmpw
40 <rbot> created botuser remote
42 2) # add a permission to say for your newly created remote user:
44 <you> allow rmuser to do say #channel message
47 3) # run the #{$0} and type something. the message should
48 # show up on your channel / arrive as an irc private message.
50 [you@yourhost ~]$ ./bin/rbot-remote -u rmuser -p rmpw -d '#your-channel'
59 if !pw || !user || !dst
71 resp = Net::HTTP.post_form(uri, 'command' => ['say', dst, s].join(' '))
72 puts [resp.code, resp.message, resp.body].join("\t")