Listeners - Zirak/SO-ChatBot GitHub Wiki
Listeners are commands only with "looser" syntax; i.e. they are matched against regular expressions. Listeners are invoked by simply omitting the / command prefix:
!!give me a lick
Where the !! is the Invocation Pattern (see main, subject to change by bot handler. In this wiki, !! is assumed). The general form being:
!!text
Easy, right?
Okay, let's move on to listing
The Listeners
This wiki assumes (for demonstration purposes) that your username is Dave, your user-id is 5318008 and the message you sent has an id of 42.
regexp: /^help(?: (\S+))?/
!!help [command]
Fetches documentation for given command, or general help article. Synonym of /help [command]
regexp: /^tell (me (your|the) )?(rule|law)s/
!!tell me your laws
Prints out the laws which the bot must follow.
regexp: /^give (.+?) a lick/
!!give target a lick
Licks target. I have a feeling target will taste like grapes.
regexp: /^what(?:'s|'re)?\s(?:(?:is|are)\s)?(?:(?:an|a)\s)?([\w\s\-]+)\??/
!!what's a subject?
regexp: /^define\s(?:(?:an|a)\s)?([\w\s\-]+)/
!!define subject
Synonym for /define subject.
regexp: /thank(s| you)/
regexp: /sorry/
regexp: /bitch/
regexp: /cow(think|say)\s(?:([eT])=(.{0,2})\s)?(?:([eT])=(.{0,2})\s)?(.+)/
!!cowsay moooo
An implementation of cowsay. Available arguments are e=xx and T=xx for eyes and tongue respectively. Cowthink is also included and accepts the same arguments..
!!cowthink mooo
!!cowsay e=@@ T=UU
!!cowthink mooo?
regexp: /(which |what |give me a )?firefly( episode)?/i
!!give me a firefly
Gives you a Firefly episode to watch. If you did not explicitly tell it to give you an episode, you may also get the movie.
!!which firefly episode
@Dave Episode 11 - Trash
!!which firefly
@Dave Serenity (movie)
regexp: /(?:nudge|remind|poke)\s(?:me\s)?(?:in\s)?(\d+m?)\s?(.*)$/
!!nudge in 20 get the pizza out
Synonym for /nudge interval message.
regexp: /^\s*s(\/|\|)((?:(?:\\\1)|[^\1])*?)\1((?:(?:\\\1)|[^\1])*?)\1(g?i?)/
!!s/pattern/replacement/flags
Performs a substitution on a message matching pattern. The replacement is done with replacement.replace. In case the world burns and mdn goes down, here are the special patterns you can use in replacement (to grab stuff from the capture):
| Pattern | Meaning |
|---|---|
$n |
The nth capturing group ($1, $2, $3, ...) |
| $& | The entire match |
| $` | The substring preceding the match |
| $' | The substring following the match |
| $$ | A literal dollar sign |
foo is the bar
!! s/foo(.*)bar/blorg$1blarg/
@Dave blorg is the blarg
my panties are on fire
!! s/.+/$& and they smell like toast/
@Dave my panties are on fire and they smell like toast
Note: This listener works on the DOM of the bot's window. That means that it'll only work on messages which are on the same main window as the bot's.
regexp: /^\s*(choose|should)?.*\sor\s[^$]/i
!!a or b or c
Beckon the weasel choose an option for you. Options are delimited by the word or. Surprise.
!!should I stay or should I go?
@Dave You should stay
regexp: /\b(am|are|can|could|do|does|is|may|might|shall|should|will|would)\b/i
!!does this dress make me look fat?
Ask the weasel to enlighten your question with a (sort-of) yes/no answer.
!!will I die tomorrow?
@Dave All signs point to yes.