Plugin:Lua

From ShoutIRC RadioBot Wiki
Revision as of 10:11, 25 October 2013 by Indy (talk | contribs) (Text replacement - "IRCBot" to "RadioBot")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The Lua plugin lets you write custom scripts in the Lua scripting language.
Scripts go in the lua_scripts subfolder in your RadioBot folder.

Once your script is loaded, the bot will call the function 'init' in your script. It should return 1 if the script loaded successfully or 0 if there was an error.
It is OK to not include an 'init' function if you don't need it.

When the bot is shutting down it will call the 'quit' function (again, you can leave it out if you don't need it). The 'quit' function has no return value.

Built-in Functions and Events

Besides the built-in functionality of Lua, the bot adds many commands. You can find a list here.
By binding events you can have your script handle things like custom !triggers, channel joins/parts, etc. A list of the currently supported events is here.

Examples

Here is an example barebones file:

function init()
	ib_print("Script loaded.")
	return 1;
end

function quit()
	ib_print("Goodbye")
end

Sample script implementing a custom PM trigger:

function pm_handler(hostmask, nick, uflags, netno, text)
	SendPM(netno, nick, "Thanks for the PM")
	return 0;
end

function init()
	bind_event("on_pm", "pm_handler", "!test")
	return 1;
end


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