forked from keybase/keybase-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello-world.js
More file actions
executable file
·35 lines (33 loc) · 940 Bytes
/
hello-world.js
File metadata and controls
executable file
·35 lines (33 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env node
const Bot = require('../lib/index.js')
function main() {
const bot = new Bot()
const username = process.env.KB_USERNAME
const paperkey = process.env.KB_PAPERKEY
bot
.init(username, paperkey, {verbose: false})
.then(() => {
console.log(`Your bot is initialized. It is logged in as ${bot.myInfo().username}`)
const channel = {name: 'kbot,' + bot.myInfo().username, public: false, topicType: 'chat'}
const message = {
body: `Hello kbot! This is ${bot.myInfo().username} saying hello from my device ${
bot.myInfo().devicename
}`,
}
bot.chat
.send(channel, message)
.then(() => {
console.log('Message sent!')
bot.deinit()
})
.catch(error => {
console.error(error)
bot.deinit()
})
})
.catch(error => {
console.error(error)
bot.deinit()
})
}
main()