luabot
Due to popular demand, I gave in and wrote this introduction to
luabot.
luabot commands can be extended/added through the MUC, so I won't document many commands here. Instead I will list the built-in commands, which cannot be over-ridden, and cannot (usually) be used in commands added through the MUC.
MUC Administration
!kick <nick>
!ban <nick>
!op [<nick>]
If <nick> is omitted, HAL will make you a moderator
!admin [<nick>]
If <nick> is omitted, HAL will make you an administrator
!demote [<nick>]
If <nick> is omitted, HAL will make make you a normal participant
MUCs
!join <room JID>
Join a room
!leave
Leave the room
!settopic <topic>
Change the room's topic/subject to <topic>
!nick <newnick>
Sets the bot's nickname in the current room. If <nick> is omitted, he will assume his default nick
!invite <JID>
Invite <JID> to the current conference
Reference
!xep <XEP name or number>
Searches for an XEP, given part of its name, or its number
!xmpp-core
!xmpp-im
Links to the XMPP RFCs
!rfc <RFC number>
Return a link to an RFC. For the laziest of the lazy.
!slang <acronym>
Netspeak to English converter. idkh2s indeed! Responses are roughly censored.
Message delivery
!tell <nick> <message>
When <nick> comes online, send them your message. It will be shown in public. If you would like me to change this, let me know :)
!untell <nick>
Tell him to forget anything you wanted him to say to <nick>
Lua execution
!eval <string>
!do <string>
!calc <string>
All do the same thing. See the section below for more on the Lua features.
!save <string>
Run the code, and run it every time the bot restarts
Chatbot
!loadai
Wakes up HAL's AI, he'll get a lot more talkative :)
!nospim
Shuts him up
Miscellaneous
!bofh
For when you really have no answer
Bot-related
!reload
Reload the bot. Used to let code changes take effect, and wake him back up after an uncaught error.
!addadmin
!rmadmin
Super-admins only ;)
!config <setting>[=<value>]
Shows (or if a value is given, sets) the value of a configuration option. These options are per-room.
!version
Version of the bot
Running Lua code
Using the !do command, you can run Lua code from the MUC. Often you will find that you are restricted to evaluating expressions, and calling functions. Creating functions and changing variable requires admin access, or the configuration option "allowfunctions=yes".
If someone types a message beginning with ! in a MUC or PM, luabot will attempt to use the message as a command:
!<command>
It will first check if <command> is a built-in function. If it is, it will
always run that function.
Otherwise, luabot will check the sandbox for a variable named <command>. If that variable doesn't exist, he will remain silent, and ignore the command (if it was one).
If that variable does exist, HAL will check its type. If it is a function, he will execute that function, and show what the function returned to the MUC.
If the variable is a string or number, he will simply show the value of the variable in the MUC.
Some information you can access with code executed with !do:
room
\_ occupants
\_ MrUser
\_ role (string: moderator, participant, etc.)
\_ affiliation (string: admin, owner, etc.)
\_ status (string: available, xa, dnd, etc.)
\_ show (string: Status message)
\_ name (string: The room ID)
\_ server (string: The server the room is on)
\_ jid (string: The bot's room JID)
sender
\_ nick (string: The nickname of the user who is currently executing the code)
A special function count() can be used to find the number of occupants in the room. ie. count(room.occupants). You
cannot iterate over each nick in the room with a for ... loop.
All standard Lua functions are stripped of their table prefix. ie. string.format() becomes just format(), math.random() is random(). Standard functions cannot be over-ridden.
Metatables are disabled by default, just so you can't hide functions in places I won't notice :)