Skip to content

Instantly share code, notes, and snippets.

@raws
Created December 28, 2010 03:21
Show Gist options
  • Save raws/756864 to your computer and use it in GitHub Desktop.
Save raws/756864 to your computer and use it in GitHub Desktop.
Deepest, darkest infobot secrets revealed

Factoid arguments

Arguments are referenced as part of the factoid name itself, and get turned into bits of regex when parsed.

<Raws> infobot, no, starspin $1 is <action> swallows $1 in a violent, ethereal whorl of galactic stardust!
<infobot> Raws: okay
<Raws> ~starspin Mr_Rabies
*infobot swallows Mr_Rabies in a violent, ethereal whorl of galactic stardust!

The literal value of the factoid can then be displayed by prefixing the name with cmd: and substituting (.*?) for your dollar-sign argument(s):

<Raws> ~literal cmd: starspin (.*?)
<infobot> "cmd: starspin (.*?)" is "($1): <action> swallows $1 in a violent, ethereal whorl of galactic stardust!"

Join messages

Automatic “on join” messages can be configured using the OnJoin module. For details, use:

<Raws> ~+help onjoin
<infobot>   Desc: get/set OnJoin message (needs chan option +OnJoin)
<infobot>   Usage: onjoin [#chan|_default] [-]<nick> [message]
<infobot> Example: onjoin infobot Hey! It’s another infobot!

To remove a join message, use something like the following:

<Raws> ~onjoin #wowhead -starspun
<Raws> Hi guys, #wowhead’s wondering how to reference arguments in factoids
<Raws> We’ve been poring over Reply.pl, but can’t find anything :P
<Raws> (incidentally, we’ve also been trying to figure this out, on and off, for years)
<TimRiker> reference arguments?
<TimRiker> you mean like this?
<TimRiker> ~whaleslap Raws for asking about arguments
* infobot beats Raws for asking about arguments upside and over the head with a freakishly huge killer whale named Hugh
<Raws> Yes!
<TimRiker> ~listkeys whaleslap
<infobot> Factoid search of ‘whaleslap’ by key (12 of 13): whaleslap chikorita #DEL# ;; whaleslap purl #DEL# ;; cmd: whaleslap (.*?) ;; whaleslap jbdigriz #DEL# ;; whaleslap legolas #DEL# ;; whaleslap spiff #DEL# ;; whaleslap ;; whaleslap kr #DEL# ;; whaleslap learner #DEL# ;; whaleslap bzgirl #DEL# ;; whaleslap quol #DEL# ;; whaleslap bryjen #DEL#.
<TimRiker> ~literal cmd: whaleslap (.*?)
<infobot> “cmd: whaleslap (.*?)” is “($foo): <action> beats $foo upside and over the head with a freakishly huge killer whale named Hugh”
<TimRiker> added by something like this:
<TimRiker> ~fingerpoke $1 is <action> pokes $1 in the eyes stooges style
<infobot> TimRiker: okay
<TimRiker> ~fingerpoke Raws
* infobot pokes Raws in the eyes stooges style
<Raws> Oh my god
<TimRiker> ~literal cmd: fingerpoke (.*?)
<infobot> “cmd: fingerpoke (.*?)” is “($1): <action> pokes $1 in the eyes stooges style”
<Raws> You have no idea how long we’ve been trying to figure that one out
<TimRiker> :)
<TimRiker> listkeys (.*?) for
<TimRiker> ~listkeys (.*?) for
<infobot> Factoid search of ‘(.*?) for’ by key (8): cmd: timeout (.*?) for (.*?) ;; cmd: blame (.*?) for (.*?) ;; cmd: hit (.*?) for (.*?) ;; cmd: samplecommand (.*?) for (.*?) #DEL# ;; cmd: cook (.*?) for (.*?) ;; cmd: pingifry (.*?) for (.*?) ;; cmd: punish (.*?) for (.*?) ;; cmd: fishslap (.*?) for (.*?).
<Raws> Nobody ever thought that the factoid/command name would be prefixed or suffixed with regex or a variable name or something
<TimRiker> entered without it, but stored as cmd:...
<TimRiker> multiples can be entered as well.
<Raws> Hmm, so that’s what that was for in the source
<Raws> Thanks!
<TimRiker> ~cook Raws for dinner
* infobot puts on his apron and fires up the stove. “Your Raws will be ready in a little while, dinner.”
<TimRiker> ~cook Raws for DocScrutinizer
* infobot puts on his apron and fires up the stove. “Your Raws will be ready in a little while, DocScrutinizer.”
<Raws> So you can just use any old regex?
<TimRiker> ~literal cmd: cook (.*?) for (.*?)
<infobot> “cmd: cook (.*?) for (.*?)” is “($1,$2): <action> puts on his apron and fires up the stove. “Your $1 will be ready in a little while, $2.””
<Raws> Oh man, that’s awesome
<TimRiker> that would be entered as ~cook $1 for $2 is <action> blah blag $1 blah blah $2 blah blah
<Raws> Fantastic
<TimRiker> obviously <action> is not required, it could be a reply.
<Raws> Aye
<Raws> Oh, while we’re at it, how do you manage infobot’s user join messages?
<TimRiker> you mean when the bot messages the channel when someone else joins?
<Raws> Yeah
<TimRiker> ~+help onjoin
<infobot> Desc: get/set OnJoin message (needs chan option +OnJoin)
<infobot> Usage: onjoin [#chan|_default] [-]<nick> [message]
<infobot> Example: onjoin infobot Hey! It’s another infobot!
<TimRiker> ~listkeys onjoin
<infobot> Factoid search of ‘onjoin’ by key (2): set onjoin -newsome darl mcbride ;; set onjoin ##essy -matt123.
<TimRiker> hehe. they are stored in a different table.
<Raws> Aha, so ~onjoin #chan -nick would remove the onjoin?
<TimRiker> ~forget set onjoin -newsome darl mcbride
<infobot> i forgot set onjoin -newsome darl mcbride, TimRiker
<TimRiker> ~forget set onjoin ##essy -matt123
<infobot> i forgot set onjoin ##essy -matt123, TimRiker
<Raws> Hmm, okay
<TimRiker> yes.
<Raws> Thanks again :)
<Raws> From #wowhead
<TimRiker> np
<TimRiker> yw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment