Skip to content

Instantly share code, notes, and snippets.

@omnidan
Last active May 29, 2016 14:15
Show Gist options
  • Save omnidan/55c059287597416b3ef986799e028bb0 to your computer and use it in GitHub Desktop.
Save omnidan/55c059287597416b3ef986799e028bb0 to your computer and use it in GitHub Desktop.
coffea-starter with hashtag detection
import dude from 'debug-dude'
const { /*debug,*/ log, info /*, warn, error*/ } = dude('bot')
import { version } from '../package.json'
info(`coffea-starter bot v${version} starting`)
import config from '../config.json'
import { connect, message } from 'coffea'
const networks = connect(config)
// --
networks.on('command', (evt, reply) => {
log('Received command event: %o', evt)
switch (evt.cmd) {
case 'say':
reply(message(evt.channel, evt.args.join(' ')))
break
// TODO: add more commands here
}
})
networks.on('message', (evt, reply) => {
log('Received message event: %o', evt)
let hashtag = evt.text.match(/#([a-zA-Z]+)/)
switch (hashtag[1]) {
case 'test':
reply(message(evt.channel, '#test detected!'))
break
// TODO: add more hashtags here
}
})
// TODO: write more code here or adjust code above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment