aboutsummaryrefslogtreecommitdiff
path: root/README.redirection.txt
blob: 7e8769a951bc4758848d7ad6eee8d595102d9b06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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:

<newuser> How do I print number in C?
<oldguy> !man 3 printf
<bot> oldguy: printf(3): formatted output conversion

oldguy is using the bot to answer newuser's question. What
redirection does is:

<newuser> How do I print number in C?
<oldguy> !man 3 printf > newuser
<bot> newuser: printf(3): formatted output conversion

All that's changed is who gets highlighted (the <user>: 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.