owenconti / livecodingtv-bot

30 stars 13 forks source link

livecodingtv-bot

NO LONGER SUPPORTED

BEFORE YOU BEGIN!

This node app uses ES6 features.

Please ensure you are running node v4 or greater!

Changelog

https://github.com/owenconti/livecodingtv-bot/blob/master/changelog.md

Offical Plugins

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.

Setup

1) Clone the repo

2) Create a setup/custom/credentials.js file and setup/custom/settings.json file.

3) Find your XMPP password on LCTV page.

  1. Open your live stream page ( https://www.livecoding.tv/USERNAME )
  2. Open Dev Tools and switch to the Elements tab
  3. Search the HTML content for "password".
  4. The XMPP password will be a long string in an object containing 'jid' and 'password'.

4) 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'
};

5) Fill setup/custom/settings.json with the following JSON data:

{
    "plugins": {
        "noifications": true,
        "api-triggers": true
    }
}

6) Run npm install

7) Run node index.js

8) 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'
};

9) The bot should be running and waiting for your commands!

Custom command credentials

Github repo command

Generating Help documentation

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"
}

Custom settings

To enable plugins once you've downloaded them, edit the setup/custom/settings.json file:

{
    "plugins": {
        "noifications": true,
        "api-triggers": true
    }
}

Custom assets

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.

Plugin settings

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:

1) Download the plugin to the folder "plugins" 2) Add it to your settings.json in "setup/custom/" like that:

"plugins" : {
    "PLUGIN-NAME": true
}

3) Restart the bot

Writing plugins

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!' );
    }
}

See the examples directory for an example of creating a plugin.