GithubHelp home page GithubHelp logo

livecodingtv-bot's Introduction

livecodingtv-bot

BEFORE YOU BEGIN!

This node app uses ES6 features.

Please ensure you are running node v4 or greater!

Setup

  1. Clone the repo

  2. Create a credentials.js file in the root of the app.

  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 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'
};
  1. Run npm install

  2. Run node index.js

  3. 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'
};
  1. The bot should be running and waiting for your commands!

Custom command credentials

Github repo command

  • Github repo must be publicly available
  • Attribute in credentials.js: githubRepo: 'owenconti/livecodingtv-bot'

Using 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 received
    • presence types are parsed when an incoming presence (user joined/left) is received
    • startup types are parsed and ran during start up
    • websocket types are parsed when an incoming websocket message is received
  • regex
  • 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.
  • action
    • The action attribute is a function that is called if the regex for the command matches.
    • The logic for the command should reside inside the action attribute.
    • action is passed 2 parameters:
      1. chat - an instance of the Client object
      2. stanza - 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 to startup commands.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.