-
Notifications
You must be signed in to change notification settings - Fork 59
Commands
All commands are prefixed with a /
. So if you want to execute the command foo
, you must write:
!!/foo
Where the !!
is the Invocation Pattern (see main, subject to change by bot handler. In this wiki, !!
is assumed). The general form being:
!!/commandName [arg0 [arg1 [...]]]
Some commands require special privilege to use (as in, you must be a room owner or a moderator). Having said that, there are...
In those privileged commands, there's a small subset that while normally requiring special privilege, will be triggered once enough (usually 2) users invoke them within a span of time. At the time of writing, these are
ban
die
-
summon
andunsummon
The reason being the community should have the power to prevent spam in case something goes wrong with the bot, or a user is abusing it.
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.
- help
- listen
- eval
- live
- die
- refresh
- forget
- ban
- unban
- info
- jquery
- choose
- user
- listcommands
- norris
- urban
- parse
- tell
- mdn
- awsm
- convert
- define
- get
- hang
- inhistory
- learn
- mustache
- nudge
- spec
- stat
- summon
- unsummon
- timer
- todo
- undo
- weather
!!/help [cmdName]
When called with no arguments, it returns with a link to the main wiki page.
When called with an argument, a cmdName
, it displays a help message for the specific commands (or a default message if no help message exists for that command.)
!!/help
@Dave https://github.com/Zirak/SO-ChatBot/wiki/Interacting-with-the-bot
!!/help spec
@Dave spec: Find a section in the ES5 spec
!!/help get
@Dave get: No info is available
!!/help unexisto
@Dave Command unexisto does not exist.
!!/listen give me a lick
@Zirak Mmmm! you taste just like raisin
//is equivalent to
!!give me a lick
!!/eval javascript-code
Forwards to javascript code eval, as if instead of being called with the command-prefix /
, it was called with the eval-prefix >
.
!!/eval 4+6
:42 10
!!> []+[]
:42 ""
!!/live
(Special permission needed to use) Resurrects the bot if it's dead.
assuming the bot is dead:
@Dave And on this day, you shall paint eggs for a giant bunny.
assuming the bot is alive:
@Dave I'm not dead! Honest!
!!/die
(Special permission needed to use) Murders the bot. Since it's dead, it can't respond.
## refresh!!/refresh
(Special permission needed to use) Refreshes (basically reloads) the bot.
## forget!!/forget cmdName
Have the bot forget cmdName
. You may have to have permission to forget certain commands. Once a command is forgotten, it cannot be un-forgotten (unless, of course, it is /learn
ed.)
assuming you have permission:
!!/forget hang
@Dave Command hang forgotten.
if you do not have permission:
!!/forget hang
@Dave You are not authorized to delete the command hang
!!/ban [list-of-userids-or-usernames]
(Special permission required to use) Have the bot not respond to any query a specified user sends. Note, that a username will only map to a userid if that user is in the same room as the bot (error message given if it could not be mapped.) Lacking arguments, prints the banlist.
Assuming a user called Yarbal (userid=400), and another user with an id of 890 not present in the room:
!!/ban 890
@Dave User 890 added to mindjail.
!!/ban Yarbal
@Dave User Yarbal added to mindjail.
!!/ban
@Dave 890 (?), 400 (Yarbal)
!!/ban unexisto
@Dave Cannot find user unexisto.
!!/unban [lists-of-userids-or-usernames]
(Special permission required to use) Remove specified user(s) from the banlist. Same username=>userid mapping rules apply as in /ban
and /user
!!/info [commandName]
Provides some info on the current bot instance or the specified command. Spits out as much information as it has.
!!/info
@foobar I awoke on Wed, 12 Dec 2012 20:54:20 GMT (that's about 1 hour ago), and got invoked 2 times
assuming foo is a command taught by Dave:
!!/info foo
@foobar Command foo, created by Dave, invoked Y times
!!/jquery arg0 [, arg1[, arg2...]
Give a series of links to the specified jquery properties, after trying to guess what you really meant by each one. If it can't guess what you meant, it sends a link to the jquery search page.
There is a detailed explanation on the mapping done in the jquery command source code (at the time of writing, it's in /source/commands.js
, search for function jquery
).
!!/choose option0 [, option1 [, option2 [,...]]]
Make the bot choose an option for you. Superseded by the Winded Weasel listener (see listeners wiki).
!!/choose "go to sleep" "eat food" "do work"
will result in one of the following, semi-randomly:
go to sleep
eat food
do work
!!/user [usrid|username=yourUsrid]
Links to the user profile. Defaults to your own userid. The bot tries to map a username to a userid by inspecting the main chatroom it's in. It prints an error message if no pairing is found.
!!/user
:42 http://stackoverflow.com/users/5318008
!!/user 1337
:42 http://stackoverflow.com/users/1337
assuming he is in the room
!!/user Dave
:42 http://stackoverflow.com/users/5318008
!!/user unexisto
@Dave Can't find user unexisto in this chatroom.
!!/norris
Tells you a Chuck Norris joke. Uses the Internet Chuck Norris Database.
one answer might be:
!!/norris
@Dave No one has ever pair-programmed with Chuck Norris and lived to tell about it.
!!/urban something
Fetches the urban dictionary definition of something
.
!!/urban toast
@awesomesauce [toast](toast.urbanup.com/256104): Destroyed, terminated, ceased functioning, ended abruptedly by external forces
TODO: Do a better job. Show examples or shit.
Functions defined by the bot.
-
$who
The name of the user who sent the message -
$someone
The name of a random, recently active user -
$digit
A random digit between 0-9 -
$encode(string)
Encodesstring
to be fit for use in URIs -
$rand(min=0, max=100)
Generates a random variable betweenmin
andmax
. If given only one argument, it is assumed to bemax
.
Objects used by SO when passing messages around.
-
content
Message content -
event_type
Speaks for itself - will be 1 (new message) or 2 (edited message) -
id
? -
message_id
Number identifying a single message -
room_id
Room id -
room_name
Room name -
time_stamp
Do I have to explain these? -
user_id
I mean, they're so obvious, -
user_name
aren't they?
The command internally accepts more macros (for instance, in /learn
.) Can't document those in here.
!!/tell usrName|msgid cmdName [commandArg0, [commandArg1, [...]]]
Executes the command cmdName
, and have the output be a reply to either a user or a specific message.
!!/tell Thor listcommands
@Thor @Thor help, listen, eval, live, die, refresh, forget, ban, unban, info, jquery, choose, user, listcommands, norris, urban, parse, tell, mdn, awsm, convert, define, get, google, hang, inhistory, learn, mustache, nudge, spec, stat, timer, todo, undo, weather (page 0/0)
!!/tell 253961 mdn Date.parse
:253961 https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/parse
NOTE: For bot-safety reasons, there are several commands which cannot be executed via tell
. At the time of writing, they are tell
and forget
.
!!/mdn search
@Zirak [search - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/search)
!!/awsm Mary had a little lamb
@Dave Mry hd a lttl lmb
!!/convert <num><unit> [to|in <unit>]
Converts a unit of measurement to its counterparts (e.g. degrees to radians.) Units are case-sensitive (e.g. F
is Farrenheit, f
is feet, and c
does not map to C
(Celsius)). Can also convert most currencies using a rate-exchange API.
!!/convert list
Displays a list of known units. Just the units. No explanations. If you don't know what the units mean, you probably don't need them, or you can experiment and see.
!!/convert 100C
@Dave 212F, 373.15K
!!/convert 1240g to st
@Dave 0.1952st
Money conversions are a bit trickier. This command tries to be lenient, accepting most currency ISO codes in both lowercase and uppercase and mapping some currency symbols (like € to EUR and ₹ to INR), but it'll break if you try to be a smartass (like /convert 10 bucks
). Also note that there must be a target currency: One cannot simply convert one currency into all the rest.
!!/convert 100USD to EUR
@Dave 76.5579EUR
!!/convert 100USD to ₨
@Dave 5413.0128INR
!!/define something
Gives you the definition of something
. Uses the Wiktionary API.
!!/define justice
@Dave [justice](http://en.wiktionary.org/wiki?curid=56878) The state or characteristic of being just or fair.
!!/get getterName [range [userid]]
or, to be more descriptive:
!!/get answer|question [first|last [userid]]
The following provide the same result, assuming your userid is 1337:
!!/get answer
!!/get answer last 1337
!!/get answer 1337
Which is a link to the latest answer by user 1337, at the time of writing:
:msgid http://stackoverflow.com/questions/9360564/is-there-a-good-cpan-module-to-implement-state-machines-when-parsing-text/9364073#9364073
Name of what you wish to get. Valid values are answer
and question
.
The "range" specifier of what you wish to get. Valid values: first
, last
and between
.
If between
is specified, then the next two arguments should be the beginning date, and the end date, as such:
!!/get getterName between "beginning date" "end date" [userid]
Both dates are supposed to be valid strings, which can be parsed by Date.parse
The userid of the user from which you wish to get. Defaults to your own.
## google!!/google query
Returns the first 3 results of googling query
. Note that the query is passed verbatim, so you can go wild on query modifiers (like site:
, inurl:
, quoting, etc.)
!!/hang [guess]
Starts a Hangman game. If there is no game running, calling this command in any form will start a new game. If a game is running, then it accepts a single argument as your guess. Error messages included. You have 6 guesses before you lose.
## inhistory!!/inhistory [MM-DD]
Prints a historical event which occurred in a past year for the given month+day, or (if none given) today. Note that it's full-on MM-DD
, no 0s will be inserted for you. Uses the Wikipedia API.
Taking the date I wrote this in, 2013/04/13:
!!/inhistory
@Dave 1993 – Sri Lankan politician Lalith Athulathmudali is assassinated while addressing a gathering, approximately 4 weeks ahead of the Provincial Council elections for the Western Province.
is the same as:
!!/inhistory 04-13
@Dave 1348 – The founding of the Order of the Garter by King Edward III is announced on St George's Day.
!!/learn commandName outputPattern [inputRegex [description]
!!/learn greet "Hello, $0!" \w+
!!/learn greet 'Hello, $0!' \w+ 'summons the lord'
An alphanumeric, dash - and underscore _ string, self explanatory
A string passed to /parse
(see above for doc), with the matched groups ($0, $1, ...
for the capture-groups in inputRegex
) as the extra variables.
By default, invoking a taught command will reply to the user who invoked it. However, you can prepend your command with a modifier to change how it'll be outputted:
Pattern | Replies to... |
---|---|
<user> |
user (default) |
<msg> |
message |
<> |
nothing (just the output |
Lacking anything, it defaults to <user>
. Examples:
!!/learn messageReply "<msg> this is a message reply"
!!/messageReply
:42 this is a message reply
!!/learn direct "<> this is a direct message"
!!/direct
this is a direct message
A regular expression, which will be matched against the command arguments.
Defaults to .*
Optional. Additional info displayed when the command is /help
ed.
!!/mustache [link|usrid|user name]
!!/nudge interval message
(apologies in advance if I write nudge
as nude
) Registers the bot to send you message
after interval
minutes. This is a very amnesic feature, as it forgets all nudges registered when the refreshes. Yes, I know, it sucks, needs to be fixed or some shit.
Alternative listener syntax:
!!nudge|remind|poke me? in? interval message
!!/spec something
Searches the informal ES5 spec section titles for something
.
!!/spec null
@awesomesauce [4.3.11 null value](http://es5.github.com/#x4.3.11), [4.3.12 Null type](http://es5.github.com/#x4.3.12), [7.8.1 Null Literals](http://es5.github.com/#x7.8.1), [8.2 The Null Type](http://es5.github.com/#x8.2)
!!/spec monkey
@awesomesauce monkey could not be found in spec
!!/stat [usrid=yourOwnUsrid] [extended]
!!/stat
[Amaan Cheval](http://stackoverflow.com/users/401137/amaan-cheval) has 4542 reputation, earned 0 rep today, asked 8 questions, gave 203 answers, for a q:a ratio of 8:203.
!!/stat 401137 extended
[Amaan Cheval](http://stackoverflow.com/users/401137/amaan-cheval) has 4542 reputation, earned 0 rep today, asked 8 questions, gave 203 answers, for a q:a ratio of 8:203.
avg. rep/post: 21.526066350710902, 2 gold badges, 10 silver badges and 27 bronze badges.
Gives useless stats about a user. Omit first argument to get your own, pass a 2nd argument extended
(must be that word) for extended stats. Doing /stat extended
will look for a user called extended
, so if you pass that, include an identifier.
!!/summon roomId
(Special privilege required to use, or 2 unprivileged users) Summons the bot to the specified room.
!!/unsummon roomId
(Special privilege required to use, or 2 unprivileged users) Have the bot leave the specified room. Will not work on the bot's core room (the room the handler invoked it in).
## todo!!/todo get|add|rm item0|[count [, item1 [...]]]
A personal todo list.
!!/todo get [count]
Grab the first two items:
!!/todo get 2
Grab all the items:
!!/todo get
!!/todo add item0 [, item1 [,...]]
Add an item to your todo list:
!!/todo add eat
Make sure to wrap values with spaces in quotes:
!!/todo add "eat apple"
Insert several items at once:
!!/todo add "eat apple" "go to bathroom" floss
!!/todo rm index0 [, index1 [,...]]
(index is 0-based)
Remove the 1st item:
!!/todo rm 0
Remove the 3rd and 4th:
!!/todo rm 2 3
!!/undo [msgid]
(Special privilege required) Removes the last bot message, or the message corresponding to msgid
.
!!/weather (lat, lon)
!!/weather city
Gets current weather. In the first form (the parentheses are important!) by latitude and longitude, in the second form, searches for such a city. Uses the wonderful OpenWeatherMap API.
!!/weather (50.95751, 131.81250)
@Dave [Novobureyskiy](http://openweathermap.org/city/2018964): 3.75C (276.9K), light rain
!!/weather London, UK
@Dave [London](http://openweathermap.org/city/2643743): 13.58C (286.73K), few clouds