Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PAYSAPP for KEYBASE
- const kBot = require('keybase-bot')
- const bot = new kBot()
- const username = process.env.BOTNAME;
- const paperkey = process.env.BOTKEY;
- bot.init(username, paperkey, {verbose: true})
- .then(() => {
- console.log('Paysapp bot initialized')
- const channel = {name: bot.myInfo().username, public: true, topicType: 'chat'}
- const onMessage = message => {
- console.log('> Message', message) // Deaf bot, never seeing any message
- if (message.content.type === 'text') {
- const body = message.content.text.body;
- const words = text.trim().split(/\s+/);
- if(words.length<1) { return }
- const action = words[0]
- console.log('Action',action)
- if (action == 'hello') {
- reply = { body: 'Welcome to Paysapp\nMore actions coming soon...' }
- bot.chat.send(message.channel, reply)
- }
- } else {
- reply = { body: 'Invalid action' }
- bot.chat.send(message.channel, reply)
- console.log('Invalid message')
- }
- }
- const onError = ex => console.error(ex)
- bot.chat.watchChannelForNewMessages(channel, onMessage, onError)
- })
- .catch(error => {
- //console.error("error", error.message)
- console.error(error)
- bot.deinit()
- })
- console.log('Paysapp bot running...');
- // END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement