https://github.com/owenconti/livecodingtv-bot/blob/master/changelog.md
The list of official plugins for the bot can be found on this repo: https://github.com/owenconti/livecodingtv-bot-plugins
Instructions for writing your own plugins can also be found on the repo above.
-
Clone the repo
-
Create a
setup/custom/credentials.js
file andsetup/custom/settings.json
file. -
Find your XMPP password on LCTV page.
- Open your live stream page ( https://www.livecoding.tv/USERNAME )
- Open Dev Tools and switch to the Elements tab
- Search the HTML content for "password".
- The XMPP password will be a long string in an object containing 'jid' and 'password'.
-
Fill in the
setup/custom/credentials.js
file with the following format:
var username = 'LCTV_BOT_USERNAME';
var password = 'XMPP_BOT_PASSWORD'; // Found in step 3
var room = 'LCTV_USER_WHERE_BOT_WILL_BE';
module.exports = {
room: username,
username: username,
jid: username + '@livecoding.tv',
password: password,
roomJid: room + '@chat.livecoding.tv'
};
- Fill
setup/custom/settings.json
with the following JSON data:
{
"plugins": {
"noifications": true,
"api-triggers": true
}
}
-
Run
npm install
-
Run
node index.js
-
Some commands require extra API keys or specific variables. You can use the
credentials.js
file to store these variables.
module.exports = {
// ...
password: password,
roomJid: room + '@chat.livecoding.tv',
githubRepo: 'owenconti/livecodingtv-bot',
youtubeApiKey: 'adfadsfsadfasdf'
};
- The bot should be running and waiting for your commands!
- Github repo must be publicly available
- Attribute in credentials.js:
githubRepo: 'owenconti/livecodingtv-bot'
Help documentation is generated via Gist. Please ensure you have the following variables setup in your credentials file before starting the bot:
{
"gistUsername" : "GIST_USERNAME",
"gistAccessToken" : "GIST_ACCESS_TOKEN"
}
To enable plugins once you've downloaded them, edit the setup/custom/settings.json
file:
{
"plugins": {
"noifications": true,
"api-triggers": true
}
}
The core includes one asset, the doge.png
image file. If you want to include more assets, place the files in the setup/custom/assets
directory. Using the Assets.load( filename.ext )
function, your custom asset will be loaded as base64 encoded string.
Plugins can have their own settings. If a plugin chooses to have its own settings, the plugin folder will contain a settings.json
file. You can edit any of the available settings inside that settings.json
file.
Where can I find plugins? Take a look at https://github.com/owenconti/livecodingtv-bot-plugins
What you need for getting Plugins to work:
- Download the plugin to the folder "plugins"
- Add it to your settings.json in "setup/custom/" like that:
"plugins" : {
"PLUGIN-NAME": true
}
- Restart the bot
Plugins can be composed of multiple commands. Commands can have four attributes:
{
types: ['message'],
regex: /^test$/,
help: 'Returns a confirmation if the `test` message was received.'
action: function( chat, stanza ) {
chat.sendMessage( 'Test received!' );
}
}
- types
- Types must be an array, and can contain multiple types.
- Valid types are:
message
presence
startup
websocket
message
types are parsed when an incoming chat message is receivedpresence
types are parsed when an incoming presence (user joined/left) is receivedstartup
types are parsed and ran during start upwebsocket
types are parsed when an incoming websocket message is received
- regex
- The
regex
attribute is used to determine the incoming stanza matches the command. - If a matched is determined, the action attribute of the command will be run.
regex
must be a valid RegExp object (https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions)
- The
- help
- The
help
attribute is used generate documentation for the!help
command. - If no
help
attribute is set, no documentation will be generated for the command.
- The
- action
- The
action
attribute is a function that is called if theregex
for the command matches. - The logic for the command should reside inside the
action
attribute. action
is passed 2 parameters:chat
- an instance of the Client objectstanza
- the parsed stanza containing:
{ user: User object, message: message string, type: type of stanza (message or presence) rateLimited: boolean to determine if the user is rateLimited }
- The
stanza
parameter is not passed tostartup
commands.
- The
See the examples directory for an example of creating a plugin.