-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.js
68 lines (57 loc) · 2.5 KB
/
bot.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict'
// Add dependencies
const botBuilder = require('claudia-bot-builder')
const telegramTemplate = botBuilder.telegramTemplate
const excuse = require('huh')
function mainMenu() {
return new telegramTemplate.Text(`Here's what I can help with:`)
.addReplyKeyboard([
['I want to talk on the conference'],
['Show Slack link'],
['Show Github link'],
['Show Meetup link']
])
.get()
}
const api = botBuilder(message => {
// Initial message
// `/start start` is something that Telegram sends when someone click on Start button
if (message.text === '/start' || message.text === '/start start')
return [
`Hey ${message.originalRequest.message.from.first_name}!`,
`I am JS Belgrade chatbot!`,
`In case you didn't know, JS Belgrade is JavaScript community from Belgrade Serbia.`,
mainMenu()
]
// Show main menu
if (message.text === '/menu' || message.text === 'Show menu')
return mainMenu()
if (message.text === 'I want to talk on the conference')
return [
`We are developers and GitHub is something that most of us use every day, so we decided to put CFP there.`,
`JS Belgrade Meetups are organized every month. Most of the time they are on Saturday afternoon.`,
new telegramTemplate.Text(`So if you want to talk in one of the next JS Belgrade Meetups, all you need to do is to click on the button below and open an issue :)`)
.addInlineKeyboard([
[{ text: 'Open CFP', url: 'https://github.com/JSBelgrade/cfp' }]
])
.get()
]
if (message.text === 'Show Slack link')
return new telegramTemplate.Text(`We have great community on Slack! Are you already there? If not join us!`)
.addInlineKeyboard([
[{ text: 'Invite me please!', url: 'http://slack.jsbelgrade.org' }],
[{ text: 'I am already on Slack', url: 'https://jsbelgrade.slack.com' }]
])
.get()
if (message.text === 'Show Github link')
return `Here's Github link: https://github.com/JSBelgrade, feel free to contribute to anything :)`
if (message.text === 'Show Meetup link')
return `All of our meetups are here: http://meetup.com/JS-Belgrade-Meetup, see you on one of the next meetups ;)`
// Fallback in case we can't process the message
return [
`Thanks for sending "${message.text}". Unfortunately I can't process your message :(\n*Reason:*\n${excuse.get()}.`,
mainMenu()
]
})
api.addPostDeployConfig('meetupComApiKey', 'Meetup.com API Key:', 'configure-app')
module.exports = api