From 744be8fffda676653475d3034786e8ee246de609 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 9 Jun 2021 08:06:17 +0200 Subject: Partial revert: reintroduce rbot-remote It now interfaces with the webservice 'dispatch' feature instead of the previous remotectl plugin, but the external API remains the same, for compatibility with existing users. --- Rakefile | 2 +- bin/rbot-remote | 74 ++++++++++++++++++ man/rbot-remote.xml | 217 ++++++++++++++++++++++++++++++++++++++++++++++++++++ rbot.gemspec | 3 +- 4 files changed, 294 insertions(+), 2 deletions(-) create mode 100755 bin/rbot-remote create mode 100644 man/rbot-remote.xml diff --git a/Rakefile b/Rakefile index 1bd782ea..8e8d9d68 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,7 @@ rule '.1' => ['.xml'] do |t| sh "xsltproc -nonet -o #{t.name} /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl #{t.source}" end -task :manpages => ['man/rbot.1'] +task :manpages => ['man/rbot.1', 'man/rbot-remote.1'] SPECFILE = 'rbot.gemspec' # The Rakefile is also used after installing the gem, to build diff --git a/bin/rbot-remote b/bin/rbot-remote new file mode 100755 index 00000000..0c1cd578 --- /dev/null +++ b/bin/rbot-remote @@ -0,0 +1,74 @@ +#! /usr/bin/ruby + +require 'uri' +require 'net/http' +require 'optparse' + +#++ +# +# :title: webserver dispatch example script +# +# Author:: jsn (dmitry kim) +# Copyright:: (C) 2007 dmitry kim +# License:: in public domain +# Modified by:: Giuseppe "Oblomov" Bilotta +# Copyright:: (C) 2020 Giuseppe Bilotta + +user = nil +pw = nil +dst = nil +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('-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| + puts < user create rmuser rmpw + created botuser remote + + 2) # add a permission to say for your newly created remote user: + + allow rmuser to do say #channel message + okies! + + 3) # run the #{$0} and type something. the message should + # show up on your channel / arrive as an irc private message. + + [you@yourhost ~]$ ./bin/rbot-remote -u rmuser -p rmpw -d '#your-channel' + hello, world! + + [you@yourhost ~]$ +EOF + exit 0 +} +opts.parse! + +if !pw || !user || !dst + puts opts.to_s + exit 0 +end + +uri = URI(uri) +uri.user = user +uri.password = pw + +loop { + s = gets or break + s.chomp! + resp = Net::HTTP.post_form(uri, 'command' => ['say', dst, s].join(' ')) + puts [resp.code, resp.message, resp.body].join("\t") +} + diff --git a/man/rbot-remote.xml b/man/rbot-remote.xml new file mode 100644 index 00000000..b68b4ef0 --- /dev/null +++ b/man/rbot-remote.xml @@ -0,0 +1,217 @@ + +.
will be generated. You may view the +manual page with: nroff -man .
| less'. A +typical entry in a Makefile or Makefile.am is: + +DB2MAN=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/\ +manpages/docbook.xsl +XP=xsltproc -''-nonet + +manpage.1: manpage.dbk + $(XP) $(DB2MAN) $< + +The xsltproc binary is found in the xsltproc package. The +XSL files are in docbook-xsl. Please remember that if you +create the nroff version in one of the debian/rules file +targets (such as build), you will need to include xsltproc +and docbook-xsl in your Build-Depends control field. + +--> + + + Marc"> + Dequènes"> + Giuseppe"> + Bilotta"> + + 20100701"> + + 1"> + Duck@DuckCorp.org"> + giuseppe.bilotta@gmail.com"> + + + RBOT-REMOTE"> + + + + + Debian"> + GNU"> + GPL"> +]> + + + + + &dhapp; + + + &dhfirstname; + &dhsurname; + &dhemail; + &debian; package maintainer + + + &gbgname; + &gbfname; + &gbemail; + &dhapp; maintainer + + + + 2004-2009 + &dhusername; + + + 2010 + &gbusername; + + &dhdate; + + + + &dhucapp; + &dhsection; + &dhapp; man page + &dhpackage; + &dhpackageversion; + + + + &dhapp; + + IRC bot written in ruby + + + + + &dhapp; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DESCRIPTION + + &dhapp; is a proof-of-concept example for + rbot druby-based api. This program reads lines of text from the standard + input and sends them to a specified irc channel or user via rbot. + + + Make sure you have the remotectl plugin loaded and assigned the needed + rights to the user before use. + + + + + OPTIONS + + This program follow the usual &gnu; command line syntax, + with long options starting with two dashes (`-'). A summary of + options is included below. + + + + + + + Remote user. + + + + + + + + Remote user password. + + + + + + + + Destination for message (user or channel). + + + + + + + + Rbot url. + + + + + + + + Show summary of options. + + + + + + + + Tell what it's all about. + + + + + + VERSION + + This manual page was written by &dhusername; &dhemail; for + the &debian; system (but may be used by others). Permission is + granted to copy, distribute and/or modify this document under + the terms of the &gnu; General Public License, Version 3 or + any later version published by the Free Software Foundation. + + + On Debian systems, the complete text of the GNU General Public + License can be found in /usr/share/common-licenses/GPL. + + + + + diff --git a/rbot.gemspec b/rbot.gemspec index 7792c3dd..f5ee4d3f 100644 --- a/rbot.gemspec +++ b/rbot.gemspec @@ -27,6 +27,7 @@ Gem::Specification.new do |s| 'INSTALL', 'Usage_en.txt', 'man/rbot.xml', + 'man/rbot-remote.xml', 'setup.rb', 'launch_here.rb', 'po/*.pot', @@ -34,7 +35,7 @@ Gem::Specification.new do |s| ] s.bindir = 'bin' - s.executables = ['rbot', 'rbotdb'] + s.executables = ['rbot', 'rbotdb', 'rbot-remote'] s.extensions = 'Rakefile' s.rdoc_options = ['--exclude', 'post-install.rb', -- cgit v1.2.3