Skip to content
Wolvan edited this page Feb 9, 2016 · 1 revision

API Object

On loading a plugin, each one receives an API God Object. The API is the primary way of a plugin interacting with both the Picarto Chat as well as the Bot's functions itself.

The API provides the following functions and properties:

##api.Events This serves as the Event Emitter to notify plugins of things happening. This is an instance of Node's EventEmitter.

The Events are listed on their own Wiki Entry

##api.readOnly A variable that reflects the state of the Picarto Connection. If this is true, messages can not be send and the bot only reads incoming messages.

##api.sharedStorage Similar to a plugin's own storage, this storage is global and accessible by every plugin that's loaded.

More about storage on its own Wiki Entry

##api.plugin_manager Gives access to the pluging manager.

api.plugin_manager.load(filename)

Load the plugin with the desired filename

api.plugin_manager.unload(filename)

Unload the plugin with the desired filename

api.plugin_manager.start(filename)

Start the plugin with the desired filename

api.plugin_manager.stop(filename)

Stop the plugin with the desired filename

##api.Messages This is the way to send Messages to Picarto. All functions here do not send the message if it goes past Picarto's 255 character limit. Sending more than 1 message per second results in the message getting lost.

api.Messages.send(message)

Send a message to the Picarto Chat

api.Messages.whisper(to, message)

Whisper to the specified user

##api.setColor(hexColorCode) Set the bot's name color to the specified color code.

##api.channel The channel the bot is currently connected to

##api.name The name which the bot is connected is. Undefined if readOnly mode

##See also Storage - The storage for all plugins

Events - What Events does the API fire

Clone this wiki locally