From 86dd0265a979b65ea1053430d470c6b77cb32406 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 28 Jun 2021 19:07:45 -0400 Subject: Document command redirection --- README.redirection.txt | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 README.redirection.txt diff --git a/README.redirection.txt b/README.redirection.txt new file mode 100644 index 0000000..7e8769a --- /dev/null +++ b/README.redirection.txt @@ -0,0 +1,75 @@ +This isn't specific to the plugins in this repo. I just want to +document it somewhere I can find it later. + +Command redirection is a way to get the bot to highlight someone +else, other than the one who ran the command. + +Imaginary conversation: + + How do I print number in C? + !man 3 printf + oldguy: printf(3): formatted output conversion + +oldguy is using the bot to answer newuser's question. What +redirection does is: + + How do I print number in C? + !man 3 printf > newuser + newuser: printf(3): formatted output conversion + +All that's changed is who gets highlighted (the : stuff). The +syntax mimics the shell's I/O redirection, if you're familiar with +that. + +The bits & pieces to make this work already exist in limnoria. The +user 'val' in libera #limnoria put them together (for which I owe much +thanks), I'm just documenting the process here. + +The indented lines are bot commands. Run them in private (a /query or +/msg window). + +First of all, you need these plugins loaded: + + load Utilities + load Conditional + load Format + load MessageParser + +(If you get "already loaded" errors, just ignore them) + +Next, *get rid* of the prefix character: + + config reply.whenaddressedby.chars "" + +And use [] for nesting: + + config supybot.commands.nested.brackets [] + +Now the preparations are complete, and you're ready to cast the +actual spell: + + messageparser add global "^!(.+?)( *> *(\S+)\s*)?$" "cif [ceq \"$3\" [concat $ 3]] \"$1\" \"echo $3: [$1]\"" + +The above is one long line, and it's very sensitive to spacing, so +be cautious when copy/pasting it. In particular, there should be no +spaces after the any of the $ symbols *except* for the 3rd one, the +one that comes right after "concat". + +After that, the !command syntax will work even though you've removed +the reply.whenaddressedby.chars entirely. And "!command > user" will +also work as desired, for all commands (including factoids). Actually +the spaces before and after the > are optional. "!command>user" works +just fine. + +If you're using some other prefix char besides !, change it in the +'messageparser add' command. You could do this on a per-channel basis +by replacing 'global' with your channel (run the command once per +channel). + +If you get message like 'Error: there is no command "> user"', you've +missed a step, or messed up the messageparser add command. + +Note that there's no attempt to verify that the part after the > +is actually a valid IRC nick. You have to spell it correctly or use +nick-completion in your client. Typos don't hurt anything, but they +don't highlight the user, either. -- cgit v1.2.3