All Projects → cabal-club → cabal-bot

cabal-club / cabal-bot

Licence: other
Create your own cabal bot

Programming Languages

javascript
184084 projects - #8 most used programming language

cabal-bot

npm install cabal-bot

Example

Echo bot

const req = require('require-yml')
const Bot = require('../')

var argv = require('minimist')(process.argv.slice(2))

if (!argv._[0]) {
  console.error('cabal /path/to/my/cabal/config.yml')
  process.exit(1)
}

let config = req(argv._[0])
console.log(config)

const bot = new Bot({
  config: {
    dbdir: config.dbdir || '/tmp/cabals'
  },
  nickname: config.nickname
})

bot.join(config.keys, (err) => {
  if (err) throw err
})

bot.on('mention', ({ key, channel, author, message }) => {
  if (/ping/.test(message.value.content.text)) {
    var msg = `${author.name}: pong`
    bot.say(key, channel, msg, (err) => {
      if (err) console.error(err)
    })
  }
})

See examples/ for more

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].