Lua Manual
From Aquila Homepage
WARNING: Under Contruction
Lua Manual
How do I write LUA programs?
I would refer you to the book Programming in LUA and the Lua 5.0 or Lua 5.1 Reference Manual.
Lua Commands
Lua command take the form of functions you can call. Below is a list of all functions known to Aquila.
Aquila Lua Command List
User information commands
GetUserIP
Arguments
- usernick
Action
- Return the IP address of the user.
Return Type
- string
Return Value
- IP address of the user.
GetUserShare
Arguments
- usernick
Action
- Returns the share size of the user as a formatted string (For example "1.34Gb")
Return Type
- string
Return Value
- Sharesize of the user as a formatted string.
GetUserShareNum
Arguments
- usernick
Action
- Returns the share size of the user as a number in bytes.
Return Type
- number
Return Value
- Sharesize of the user as a number.
GetUserClient
Arguments
- usernick
Action
- Return the client ID string as seen in the user tag.
Return Type
- string
Return Value
- Client ID string
GetUserClientVersion
Arguments
- usernick
Action
- Return the client version string as seen in the user tag.
Return Type
- string
Return Value
- Client Version string.
GetUserSlots
Arguments
- usernick
Action
- Get the number of slots the user has open.
Return Type
- number
Return Value
- number of slots
GetUserHubs
Arguments
- usernick
Action
- Get the number of hubs the user has open.
Return Type
- number, number, number
Return Value
- number of hubs
GetUserRights
Arguments
- usernick
Action
- Get the rights the user has, returned as a string of right names.
Return Type
- string
Return Value
- A string containing all the names of the rights of the user.
SetUserRights
Arguments
- usernick
- rights
Action
- Set the rights the user has.
Return Type
- string
Return Value
- 1 for success, NIL if user not found.
GetUserGroup
Arguments
- usernick
Action
- Get the users groupname.
Return Type
- string
Return Value
- Group of user, NIL if user not found.
GetUserSupports
Arguments
- usernick
Action
- Set the supports the user has.
Return Type
- string
Return Value
- Group of user, NIL if user not found.
GetUserMyINFO
Arguments
- usernick
Action
- Get the users filtered MyINFO string.
Return Type
- string
Return Value
- Group of user, NIL if user not found.
UserIsOP
Arguments
- usernick
Action
- Is this user an OP (= does he have a key) ?
Return Type
- boolean
Return Value
- If the user is an op (if he has the "key" right).
UserIsOnline
Arguments
- usernick
Action
- Is this user online ?
Return Type
- boolean
Return Value
- If user is online.
UserIsActive
Arguments
- usernick
Action
- Does this user claim to be active?
Return Type
- boolean
Return Value
- If the user is active
UserIsRegistered
Arguments
- usernick
Action
- Does this user have an account?
Return Type
- boolean
Return Value
- If the user has an active account (with password set).
UserIsZombie
Arguments
- usernick
Action
- Has this user been zombified?
Return Type
- boolean
Return Value
- If the user has been zombified.
kick and ban functions
UserKick
Arguments
- usernick, message
Action
- This function kicks the user.
Return Type
- boolean
Return Value
- success or failure
UserDrop
Arguments
- usernick, message
Action
- This function drops the user.
Return Type
- boolean
Return Value
- success or failure
UserBan
Arguments
- usernick, timespec, message
Action
- This bans the user (both nick and IP ban).
Return Type
- boolean
Return Value
- success or failure
UserBanNick
Arguments
- usernick, timespec, message
Action
- This adds a nickban for that usernick
Return Type
- boolean
Return Value
- success or failure
UserBanIP
Arguments
- usernick, timespec, message
Action
- This adds an IP ban for that user.
Return Type
- boolean
Return Value
- success or failure
UserBanIPHard
Arguments
- usernick, message
Action
- This adds a hard IP ban for that user
Return Type
- boolean
Return Value
- success or failure
BanIP
Arguments
- IP, timespec, message
Action
- Bans the IP.
Return Type
- boolean
Return Value
- success or failure
BanIPHard
Arguments
- IP, timespec, message
Action
- Hard Bans the IP.
Return Type
- boolean
Return Value
- success or failure
UnBan
Arguments
- user nick
Action
- Unban the user
Return Type
- boolean
Return Value
- success or failure
UnBanNick
Arguments
- usernick
Action
- Unban a nick
Return Type
- boolean
Return Value
- success or failure
UnBanIP
Arguments
- IP
Action
- Unban an IP
Return Type
- boolean
Return Value
- success or failure
UnBanIPHard
Arguments
- IP
Action
- Unban a hard IP ban.
Return Type
- boolean
Return Value
- success or failure
Zombie
Arguments
- usernick
Action
- Zombify a user. He will see his own chat, but noone else will.
Return Type
- boolean
Return Value
- success or failure
UnZombie
Arguments
- usernick
Action
- Undo a zombify
Return Type
- boolean
Return Value
- success or failure
FindNickBan
Arguments
- usernick
Action
- Check if nick is banned.
Return Type
- string or NIL
Return Value
- ban message or NIL if no ban found
FindIPBan
Arguments
- usernick
Action
- Check if IP is banned.
Return Type
- string or NIL
Return Value
- ban message or NIL if no ban found
Report
Arguments
- message
Action
- Send a report. You can use this to send script error messages.
Return Type
- boolean
Return Value
- success of failure
hub message functions
ChatToAll
Arguments
- nick, message
Action
- Send a chat message in main chat.
- Use NIL or "" as source nick to force it to use the HubSec nick as source.
Return Type
- boolean
Return Value
- succes or failure
ChatToNick
Arguments
- sourcenick, targetnick, message
Action
- Send a chat message in main chat to one user only.
- Use NIL or "" as source nick to force it to use the HubSec nick as source.
Return Type
- boolean
Return Value
- only return failure if target nick doesn't exist or sending failed.
ChatToRights
Arguments
- sourcenick, targetrights, message
Action
- Send a chat message in main chat to all users that have all the rights you supplied and do not have the rights you denied.
- Use NIL or "" as source nick to force it to use the HubSec nick as source.
Return Type
- boolean
Return Value
- only return failure if target nick doesn't exist or sending failed.
PMToAll
Arguments
- sourcenick, message
Action
- Send a private message to all users.
- Use NIL or "" as source nick to force it to use the HubSec nick as source.
Return Type
- boolean
Return Value
PMToNick
Arguments
- sourcenick, targetnick, message
Action
- Send a private message to one user.
- Use NIL or "" as source nick to force it to use the HubSec nick as source.
Return Type
- boolean
Return Value
PMToRights
Arguments
- sourcenick, rights, message
Action
- Send a private message to all users with the asked rights and without the denied rights.
- Use NIL or "" as source nick to force it to use the HubSec nick as source.
Return Type
- boolean
Return Value
RawToNick
Arguments
- usernick, rawcommand
Action
- Send a raw DC command to a user
Return Type
- boolean
Return Value
RawToAll
Arguments
- rawcommand
Action
- Send a raw DC command to all users.
Return Type
- number
Return Value
RawToRights
Arguments
- rights, rawcommand
Action
- Sends a raw DC command to all users with the requested rights and without the denied rights.
Example
- RawToRights("share -key", "<Aquila> You are a vip|");
Return Type
- number
Return Value
account management
GroupCreate
Arguments
- groupname, rights
Action
- Creates a new group.
Return Type
- boolean
Return Value
GroupInUse
Arguments
- groupname
Action
- Checks if the group has any users in it
Return Type
- boolean
Return Value
GroupDelete
Arguments
- groupname
Action
- Deletes a group
Return Type
- boolean
Return Value
- fails if the group still has users in it.
GroupFind
Arguments
- groupname
Action
- Find a group
Return Type
- boolean
Return Value
AccountCreate
Arguments
- usernick, groupname
Action
- Create a user with group.
Return Type
- boolean
Return Value
AccountDelete
Arguments
- usernick
Action
- Delete an account
Return Type
- boolean
Return Value
AccountPasswd
Arguments
- usernick, passwd
Action
- change the password of an account
Return Type
- number
Return Value
AccountPwGen
Arguments
- usernick, passwd length
Action
- Generate a random password of requested length
Return Type
- string
Return Value
- password
AccountFind
Arguments
- usernick
Action
- Find account and return info.
Return Type
- table
Return Value
- nil, if account not found
- otherwise a table with the following fields: "op" (who registered the user), "rights", "registered", "group", "lastlogin", "lastip", "nick"
hubinfo stat related info
GetActualUsersTotal
Arguments
Action
- Returns number of users in the hub.
Return Type
- number
Return Value
- number of users.
getHubVersion
Arguments
Action
- Returns the hub version
Return Type
- 2 strings
Return Value
- hubsoft name and hubsoft version
robot functions
AddBot
Arguments
- usernick, description
Action
- Create a bot user.
Return Type
- boolean
Return Value
DelBot
Arguments
- usernick, description
Action
- remove a bot user
Return Type
- boolean
Return Value
lua created command functions
RegCommand
Arguments
- command, rights, help
Action
- Create a command in the hub. When this command is executed, it will call the lua function with the same name. If the lua function does not exist, the RegCommand will fail.
- Command functions are called with two arguments, the first is the user that called the command, the second is an array with the arguments to the command. The first argument is argument 0 and it is the command name.
- Any command output should be returned as a string. This will return the command output to the user correctly. (Thus, if the user pm'ed the command to the HubSec, it will get the answer in pm from the hubsec.)
Return Type
- boolean
Return Value
DelCommand
Arguments
- command
Action
- remove the command.
Return Type
- boolean
Return Value
config functions
SetConfig
Arguments
- config, value
Set a configuration value
Return Type
- boolean
Return Value
- success or failure
GetConfig
Arguments
- variable
Action
- Get a configuration value.
Return Type
- string
Return Value
- string of the configuration value.
Lua Events
Most events are discardable by returning true. For example, if you return true for an EventChat function, the hub won't broadcast the chat message. Or, if you return true for an EventLogin function, the hub disconnects the user, etc.
Lua Event List
EventLogin
Arguments
- nick, Processed myinfo of user.
Function
- Called whenever a user has successfully logged in.
EventSearch
Arguments
- nick, the search string
Function
- Called whenever a user does a search
EventChat
Arguments
- nick, The chat message
Function
- Called whenever a chat message is received
EventPMOut
Arguments
- nick, The raw PM message
Function
- Called whenever a user sends a PM
EventPMIn
Arguments
- nick, The raw PM message
Function
- Called whenever a user receives a PM
EventLogout
Argument
- nick, None
Function
- Called whenever a user logs out.
EventKick
Argument
- nick, kick message
Function
- called in case a user gets kicked with !kick
EventBan
Argument
- nick, ban message
Function
- Not Implemented yet.
EventInfoUpdate
Argument
- nick, updated myinfo
Function
- Called whenever a user sends a MyINFO to the hub, except the one on login.
EventSearchResult
Argument
- nick, search result
Function
- Called whenever a search result is send by a user
EventUpdate
Argument
- nick, none
Function
- called whenever a users information is updated and has changed.
EventRedirect
Argument
- nick, message
Function
- Called whenever a user is redirected
EventPreLogin
Argument
- nick, raw MyINFO
Function
- This is called just before the user is logged in.
EventCacheFlush
Argument
- none
Function
- This is called every time the cache is flushed. About every second.
EventLoad
Argument
- none
Function
- Called whenever the settings are loaded.
EventSave
Argument
- none
Function
- Called whenever the settings are saved.
EventConfig
Arguments
- nick, setting
Function
- Called whenever a configuration value is set.

