xB: fix up the special IPC command's name

To reflect the new disorder.
This commit is contained in:
Přemysl Eric Janouch 2021-08-06 17:14:13 +02:00
parent 50057d5149
commit 5d285ffb96
Signed by: p
GPG Key ID: A0420B94F92B9493
11 changed files with 30 additions and 28 deletions

4
NEWS
View File

@ -2,7 +2,9 @@
* xC: made nick autocompletion offer recent speakers first * xC: made nick autocompletion offer recent speakers first
* All binaries have been renamed to something even sillier * All binaries have been renamed to something even sillier,
and all references in the source tree have been redacted;
this represents a major incompatible change for all plugins
1.2.0 (2021-07-08) "There Are Other Countries As Well" 1.2.0 (2021-07-08) "There Are Other Countries As Well"

View File

@ -77,7 +77,7 @@
(substring line 0 (- len 1)) line)))) (substring line 0 (- len 1)) line))))
(define (get-config name) (define (get-config name)
(send "ZYKLONB get_config :" name) (send "XB get_config :" name)
(car (message-params (parse-message (get-line-crlf irc-input-port))))) (car (message-params (parse-message (get-line-crlf irc-input-port)))))
(define (extract-nick prefix) (define (extract-nick prefix)
@ -216,7 +216,7 @@
; --- Main loop ---------------------------------------------------------------- ; --- Main loop ----------------------------------------------------------------
(define prefix (get-config "prefix")) (define prefix (get-config "prefix"))
(send "ZYKLONB register") (send "XB register")
(define (process msg) (define (process msg)
(when (string-ci=? (message-command msg) "PRIVMSG") (when (string-ci=? (message-command msg) "PRIVMSG")

View File

@ -37,7 +37,7 @@ proc parse {line} {
proc get_config {key} { proc get_config {key} {
global msg global msg
puts "ZYKLONB get_config :$key" puts "XB get_config :$key"
gets stdin line gets stdin line
parse $line parse $line
return [lindex $msg(param) 0] return [lindex $msg(param) 0]
@ -53,7 +53,7 @@ fconfigure stdin -translation crlf -encoding iso8859-1
fconfigure stdout -translation crlf -encoding iso8859-1 fconfigure stdout -translation crlf -encoding iso8859-1
set prefix [get_config prefix] set prefix [get_config prefix]
puts "ZYKLONB register" puts "XB register"
set eightball [list \ set eightball [list \
"It is certain" \ "It is certain" \

View File

@ -15,7 +15,7 @@ BEGIN \
prefix = get_config("prefix") prefix = get_config("prefix")
print "ZYKLONB register" print "XB register"
fflush("") fflush("")
# All functions have to be in this particular array # All functions have to be in this particular array
@ -258,7 +258,7 @@ function process_end ()
function get_config (key) function get_config (key)
{ {
print "ZYKLONB get_config :" key print "XB get_config :" key
fflush("") fflush("")
getline getline

View File

@ -24,18 +24,18 @@ sub parse ($) {
} }
sub bot_print { sub bot_print {
print "ZYKLONB print :${\shift}"; print "XB print :${\shift}";
} }
# --- Initialization ----------------------------------------------------------- # --- Initialization -----------------------------------------------------------
my %config; my %config;
for my $name (qw(prefix)) { for my $name (qw(prefix)) {
print "ZYKLONB get_config :$name"; print "XB get_config :$name";
$config{$name} = (parse <STDIN>)->{args}->[0]; $config{$name} = (parse <STDIN>)->{args}->[0];
} }
print "ZYKLONB register"; print "XB register";
# --- Database ----------------------------------------------------------------- # --- Database -----------------------------------------------------------------
# Simple map of (factoid_name => [definitions]); all factoids are separated # Simple map of (factoid_name => [definitions]); all factoids are separated

View File

@ -206,7 +206,7 @@ def parse (line)
end end
def bot_print (what) def bot_print (what)
print "ZYKLONB print :#{what}" print "XB print :#{what}"
end end
# --- Initialization ----------------------------------------------------------- # --- Initialization -----------------------------------------------------------
@ -215,12 +215,12 @@ end
# To read it from anywhere else, it has to be done asynchronously # To read it from anywhere else, it has to be done asynchronously
$config = {} $config = {}
[:prefix].each do |name| [:prefix].each do |name|
print "ZYKLONB get_config :#{name}" print "XB get_config :#{name}"
_, _, _, _, args = *parse($stdin.gets.chomp) _, _, _, _, args = *parse($stdin.gets.chomp)
$config[name] = args[0] $config[name] = args[0]
end end
print "ZYKLONB register" print "XB register"
# --- Plugin logic ------------------------------------------------------------- # --- Plugin logic -------------------------------------------------------------

View File

@ -1964,12 +1964,12 @@ read_message (void)
// --- Interfacing with the bot ------------------------------------------------ // --- Interfacing with the bot ------------------------------------------------
#define BOT_PRINT "ZYKLONB print :script: " #define BOT_PRINT "XB print :script: "
static const char * static const char *
get_config (const char *key) get_config (const char *key)
{ {
printf ("ZYKLONB get_config :%s\r\n", key); printf ("XB get_config :%s\r\n", key);
struct message *msg = read_message (); struct message *msg = read_message ();
if (!msg || msg->n_params <= 0) if (!msg || msg->n_params <= 0)
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
@ -2298,7 +2298,7 @@ main (int argc, char *argv[])
printf (BOT_PRINT "%s\r\n", "runtime library initialization failed"); printf (BOT_PRINT "%s\r\n", "runtime library initialization failed");
g_prefix = strdup (get_config ("prefix")); g_prefix = strdup (get_config ("prefix"));
printf ("ZYKLONB register\r\n"); printf ("XB register\r\n");
struct message *msg; struct message *msg;
while ((msg = read_message ())) while ((msg = read_message ()))
process_message (msg); process_message (msg);

View File

@ -26,7 +26,7 @@ function parse (line)
end end
function get_config (name) function get_config (name)
io.write ("ZYKLONB get_config :", name, "\r\n") io.write ("XB get_config :", name, "\r\n")
return parse (io.read ()).params[1] return parse (io.read ()).params[1]
end end
@ -34,7 +34,7 @@ end
io.output ():setvbuf ('line') io.output ():setvbuf ('line')
local prefix = get_config ('prefix') local prefix = get_config ('prefix')
io.write ("ZYKLONB register\r\n") io.write ("XB register\r\n")
local db = {} local db = {}
local db_filename = "seen.db" local db_filename = "seen.db"

View File

@ -27,12 +27,12 @@ class Plugin:
return (nick, user, host, command, args) return (nick, user, host, command, args)
def get_config (self, key): def get_config (self, key):
print ("ZYKLONB get_config :%s" % key) print ("XB get_config :%s" % key)
(_, _, _, _, args) = self.parse (sys.stdin.readline ()) (_, _, _, _, args) = self.parse (sys.stdin.readline ())
return args[0] return args[0]
def bot_print (self, what): def bot_print (self, what):
print ('ZYKLONB print :%s' % what) print ('XB print :%s' % what)
class YouTube (Plugin): class YouTube (Plugin):
re_videos = [re.compile (x) for x in [ re_videos = [re.compile (x) for x in [
@ -98,7 +98,7 @@ class YouTube (Plugin):
if self.youtube_api_key == "": if self.youtube_api_key == "":
self.bot_print ("youtube: missing `youtube_api_key'") self.bot_print ("youtube: missing `youtube_api_key'")
print ("ZYKLONB register") print ("XB register")
for line in sys.stdin: for line in sys.stdin:
self.process_line (line) self.process_line (line)

12
xB.adoc
View File

@ -57,24 +57,24 @@ Plugins
------- -------
Plugins communicate with the bot over their standard input and output streams Plugins communicate with the bot over their standard input and output streams
using the IRC protocol. (Caveat: the standard C library doesn't automatically using the IRC protocol. (Caveat: the standard C library doesn't automatically
flush FILE streams for pipes on newlines.) A special *ZYKLONB* command is flush FILE streams for pipes on newlines.) A special *XB* command is introduced
introduced for RPC, with the following subcommands: for RPC, with the following subcommands:
*ZYKLONB get_config* _key_:: *XB get_config* _key_::
Request the value of the given configuration option. If no such option Request the value of the given configuration option. If no such option
exists, the value will be empty. The response will be delivered in exists, the value will be empty. The response will be delivered in
the following format: the following format:
+ +
``` ```
ZYKLONB :value XB :value
``` ```
+ +
This is particularly useful for retrieving the *prefix* string. This is particularly useful for retrieving the *prefix* string.
*ZYKLONB print* _message_:: *XB print* _message_::
Make the bot print the _message_ on its standard output. Make the bot print the _message_ on its standard output.
*ZYKLONB register*:: *XB register*::
Once a plugin issues this command, it will start receiving all of the bot's Once a plugin issues this command, it will start receiving all of the bot's
incoming IRC traffic, which includes data from the initialization period. incoming IRC traffic, which includes data from the initialization period.

2
xB.c
View File

@ -735,7 +735,7 @@ setup_recovery_handler (struct bot_context *ctx, struct error **e)
// --- Plugins ----------------------------------------------------------------- // --- Plugins -----------------------------------------------------------------
/// The name of the special IRC command for interprocess communication /// The name of the special IRC command for interprocess communication
static const char *plugin_ipc_command = "ZYKLONB"; static const char *plugin_ipc_command = "XB";
static struct plugin * static struct plugin *
plugin_find_by_pid (struct bot_context *ctx, pid_t pid) plugin_find_by_pid (struct bot_context *ctx, pid_t pid)