forked from BeepBoopHQ/starter-node-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
93 lines (77 loc) · 3.51 KB
/
index.js
File metadata and controls
93 lines (77 loc) · 3.51 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var Botkit = require('botkit')
var messageCreator = require('./messageCreator');
var token = process.env.SLACK_TOKEN
var controller = Botkit.slackbot({
// reconnect to Slack RTM when connection goes bad
retry: Infinity,
debug: false
})
// Assume single team mode if we have a SLACK_TOKEN
if (token) {
console.log('Starting in single-team mode')
controller.spawn({
token: token,
retry: Infinity
}).startRTM(function (err, bot, payload) {
if (err) {
throw new Error(err)
}
console.log('Connected to Slack RTM')
})
// Otherwise assume multi-team mode - setup beep boop resourcer connection
} else {
console.log('Starting in Beep Boop multi-team mode')
require('beepboop-botkit').start(controller, { debug: true })
}
controller.on('bot_channel_join', function (bot, message) {
bot.reply(message, "I'm here!")
})
controller.hears(['wb shitport'], ['ambient,direct_message'], function (bot, message) {
messageCreator.getWeather(bot,message,controller,'Shreveport,LA');
})
controller.hears(['mashed potato','mashed potatoes'], ['direct_mention'], function (bot, message) {
bot.reply(message, ':eyes: :partly_sunny_rain:?')
})
//help ambient
controller.hears(['weatherbot help', 'help weatherbot','wb help'], ['ambient'], function (bot, message) {
bot.reply(message, 'Sup :sunglasses:')
bot.reply(message, 'If you want me to tell you the weather, just say "weatherbot, weather in <city>, <state>", or "weatherbot, <city>, <state> weather".')
})
//help direct message
controller.hears(['help'], ['direct_message'], function (bot, message){
bot.reply(message, 'Sup :sunglasses:')
bot.reply(message, 'If you want me to tell you the weather, just say "weatherbot, weather in <city>, <state>", or "weatherbot, <city>, <state> weather".')
bot.reply(message, 'Or just "wb, <city>, <state>')
})
//hello
controller.hears(['hello', 'hi'], ['direct_message'], function (bot, message) {
bot.reply(message, 'Hello! If you me to tell you my syntax, say help :sunglasses:')
})
//wup
controller.hears(['what up weatherfam?', 'wup', 'bitch tell me da weather'], 'direct_message,direct_mention,mention,ambient', function(bot, message) {
wupArray = ['Shreveport,LA','Edina,MN','Copenhagen,DK','Tokyo,JP','Brussels,BE'];
//messageCreate.getWeather(bot,message,controller,wupArray);
messageCreator.getWeather(bot,message,controller,'Shreveport,LA');
messageCreator.getWeather(bot,message,controller,'Edina,MN');
messageCreator.getWeather(bot,message,controller,'Copenhagen,DK');
messageCreator.getWeather(bot,message,controller,'Tokyo,JP');
messageCreator.getWeather(bot,message,controller,'Brussels,BE');
});
//forecast ambient message
controller.hears(['wb forecast (.*)','wb fc (.*)'], 'ambient,direct_message,direct_mention', function(bot, message) {
messageCreator.getForecast(bot,message,controller,message.match[1]);
});
//weather ambient message
controller.hears(['weatherbot, weather in (.*)','weatherbot, (.*) weather','wb, (.*)','wb (.*)'], 'direct_message,direct_mention,mention,ambient', function(bot, message) {
messageCreator.getWeather(bot,message,controller,message.match[1]);
});
//some change, did it not build right?
//forecast direct message
controller.hears(['fc (.*)','forecast (.*)'], 'direct_message,direct_mention', function (bot, message)
{
messageCreator.getForecast(bot,message,controller,message.match[1]);
});
//weather direct message
controller.hears('(.*)', ['direct_message', 'direct_mention'], function (bot, message) {
messageCreator.getWeather(bot,message,controller,message.match[1]);
})