1.0.8 • Published 7 years ago

xmpp-bot v1.0.8

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
7 years ago

xmpp-bot

A bot that handles commands for you

js-standard-style license

Usage

const XMPPBot = require('xmpp-bot');

let bot = new XMPPBot({
  jid: 'juliet@capulet.tld',
  password: 'romeo',
  rooms: [
    {jid: 'coven@chat.shakespeare.lit', nick: 'juliet'}
  ]
})

// register a command
bot.command('name', (answer, args, state, env) => {
  ... // do some work
  answer(...) // answer with results
})

// or just return answer
bot.command('echo', (answer, args) => args.join(' '))

// disconnect when you're done (automatically done on process exit)
bot.disconnect();

Options

Commands

Command functions are passed 4 arguments:

  • answer: function that sends the provided text or XML element
  • answer.broadcast: broadcast message to all rooms
  • args: array of arguments
  • state: an object that is saved for this command (=env[command-name])
  • env: state shared by all commands

Commands are executed when a message sent to the bot starts with their name or when the bot is mentioned with @nick <command> [args] in a MUC (multi-user-chat)

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago