Lua Scripting

From ShoutIRC RadioBot Wiki
Jump to navigation Jump to search

RadioBot Lua Commands

Those of you familiar with the Plugin API will notice that many of the Lua commands are ported/simplified versions of API functions.
If you see anything in the Plugin API that you would like to see implemented but isn't here let us know and we'll add it.
However, there are of course some new commands specific to the Lua scripts.

bind_event("event_type", "handler_function")
bind_event("event_type", "handler_function", "match text")
Registers an event handler. Examples: on_pm, on_text, on_join, etc. See Lua Events for more information.
For events with text matching like on_pm and on_text you can include a 3rd parameter (wildcards supported) to match that text.
Returns: no return value
unbind_event("event_type", "handler_function")
unbind_event("event_type", "handler_function", "match text")
Removes a previously registered event handler. Binds are automatically removed when scripts are unloaded, so you won't need to use this 99% of the time.
You must use the same parameters as you used in bind_event for this to work, including if you used match text.
Returns: no return value
ib_print("string")
You should use this instead of print when possible so it will go through RadioBot's output buffering and logging.
Returns: no return value
SetDoSpam(dospam)
Sets the global DoSpam flag (dospam type: boolean)
Returns: no return value
SetDoSpamChannel(dospam, netno, "#channel")
Sets a channel's DoSpam flag (dospam type: boolean)
Returns: no return value
SetDoOnJoin(doonjoin)
Sets the global DoOnJoin flag (doonjoin type: boolean)
Returns: no return value
SetDoOnJoinChannel(doonjoin, netno, "#channel")
Sets a channel's DoOnJoin flag (doonjoin type: boolean)
Returns: no return value
SendPM(netno, "nick/chan", "text")
Sends a PM or channel message. You can also use the aliases msg or privmsg.
Returns: no return value
SendNotice(netno, "nick/chan", "text")
Sends a NOTICE to a nick or channel. You can also use the alias notice.
Returns: no return value
SendAction(netno, "nick/chan", "text")
Sends a ACTION to a person or channel. This is like /me in mIRC.
Returns: no return value
SendIRC(netno, "text")
Sends a raw IRC command.
Returns: no return value
SendIRC2(netno, "text", priority, delay)
Sends a raw IRC command with priority and optional delay. (The PRIORITY_* values are defined in Lua for your convenience. See the plugin API page for details.)
Returns: no return value
GetCurrentNick(netno)
Get's the bot's current nick on network netno, or nil if your netno is out of bounds.
GetDefaultNick(netno)
Get's the bot's default nick on network netno. -1 is the bot's global default nickname.
GetBotVersion()
The bot's version as a unsigned number.
GetBotVersionString()
The bot's version as a string.
GetIP()
Get the detected local IP.
GetBasePath()
Get the bot's working directory.
get_argc()
Returns the argc value of the bot.
get_argv(num)
Returns item num from the argv[] array (as string), or nil if your num is out of bounds.
LoadMessage("message_name", max_length)
Returns a message from ircbot.text, or nil if it does not exist.
max_length is important as it sets the internal text buffer size to use.
LogToChan("string")
Send string to your LogChan (if enabled).
Returns: no return value
Rehash("fn")
Rehash your ircbot.text (make fn "" to rehash the current ircbot.text, or specify a new filename to load a new one instead).
Returns: no return value
IsValidUserName("nick")
Returns true if nick is an existing RadioBot username, false otherwise.
GetUserNameFromHostmask("hostmask")
Returns the bot username associated with hostmask, or nil if no matching user was found.
GetUserFlags("hostmask")
Returns the user flags as an unsigned integer associated with hostmask, will return the Default Flags if no matching user.
GetUserFlagsString("hostmask")
Returns the user flags as a string associated with hostmask, will return the Default Flags if no matching user.

GetConfigSectionValue("section", "name")
Returns string config section value, or nil if item does not exist or isn't a string.

GetConfigSectionLong("section", "name")
Returns integer config section value, or -1 if item does not exist.

IsConfigSectionValue("section", "name")
Returns true if value name is in section, false otherwise

Configuration Demo:
GetConfigSectionLong("AutoDJ/Options", "EnableVoice")
NumNetworks()
Returns the number of IRC networks that are set up.
IsNetworkReady(netno)
Returns true if IRC network netno is connected and logged in, false otherwise.
ProcText("string", max_length)
Returns text processed through the RadioBot variable parser (%dj, %song, %version, other Built-In Variables).
max_length is important as it sets the internal text buffer size to use.
GetStreamInfo()
Returns a table containing information about your radio stream. See the STATS structure in the Plugin API documentation for key names and descriptions.
AreRatingsEanbled()
Returns true if song ratings are enabled, false otherwise.
GetMaxRating()
Returns an integer with the maximum song rating (by default: 5)
GetSongRating("song")
Returns a table with keys 'rating' and 'votes'.
genrand_int32()
Returns an unsigned integer with a random number from 0 to 0xFFFFFFFF from the bot's random number generator.
SendRemoteReply(sock, command, datalen)
SendRemoteReply(sock, command, datalen, data)
Sends a reply to a remote client, you will get sock in your 'remote' event handler. See Remote Commands for protocol details.
No return value.
SendSMS(phone, text)
Sends a SMS text message to the phone number given. (SMS plugin has to be loaded and configured.)
No return value.


RadioBot vde

RadioBot main pages
Main PageInstallationChangelogCommandsPluginsFAQConfigurationCreditsRemote ClientBuilt-In VariablesMulti Sound Server ModeUsername Character Restrictions
Auto DJ Pages
Auto DJ Main PageWebRequest SystemSchedulerMP3 EncoderVoice SupportMySQL Plugin
RadioBot Programming vde

RadioBot Programming
Plugin APIRemote CommandsPlugin InitializationRadioBot DBChanging Command PermissionsShoutIRC Music Database
Lua Scripting
Lua PluginLua ScriptingLua Events