-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
119 lines (105 loc) · 4.39 KB
/
app.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Node requirements
const path = require('path');
// Bot setup
const Botmaster = require('botmaster');
const TwitterBot = require('botmaster-twitter-dm');
const twitterSettings = require(path.resolve(__dirname, 'config'));
// where to find the config file which gives the access details to plug into the API
const botmaster = new Botmaster();
const twitterBot = new TwitterBot(twitterSettings);
botmaster.addBot(twitterBot);
// Own requirements: controllers, messages
const messages = require(path.resolve(__dirname, 'messages', 'index'));
let myIncomingMiddlewareController = (bot, update) => {
if (update.message.text === 'hi' ||
update.message.text === 'Hi' ||
update.message.text === 'hello' ||
update.message.text === 'Hello' ||
update.message.text === 'yo' ||
update.message.text === 'Hey' ||
update.message.text === 'hey') {
bot.sendTextCascadeTo(messages.tutorial, update.sender.id);
}
else if (update.message.text === 'yes' ||
update.message.text === 'Yes' ||
update.message.text === 'YES' ||
update.message.text === 'y') {
bot.sendTextCascadeTo(messages.yes, update.sender.id);
}
else if (update.message.text === 'no' ||
update.message.text === 'No' ||
update.message.text === 'NO' ||
update.message.text === 'n' ||
update.message.text === 'nah'
) {
bot.sendTextCascadeTo(messages.no, update.sender.id);
}
else if (update.message.text === 'sad' ||
update.message.text === 'Sad' ||
update.message.text === 'unhappy' ||
update.message.text === 'Unhappy' ||
update.message.text === 'angry' ||
update.message.text === 'Angry' ||
update.message.text === 'depressed' ||
update.message.text === 'Depressed' ||
update.message.text === 'crap' ||
update.message.text === 'Crap' ||
update.message.text === 'crappy' ||
update.message.text === 'Crappy' ||
update.message.text === 'tired' ||
update.message.text === 'Tired' ||
update.message.text === 'humiliated' ||
update.message.text === 'Humiliated' ||
update.message.text === 'rejected' ||
update.message.text === 'Rejected' ||
update.message.text === 'upset' ||
update.message.text === 'Upset' ||
update.message.text === 'anxious' ||
update.message.text === 'Anxious' ||
update.message.text === 'scared' ||
update.message.text === 'Scared'
) {
bot.sendTextCascadeTo(messages.negative, update.sender.id);
}
else if (update.message.text === 'happy' ||
update.message.text === 'Happy' ||
update.message.text === 'joyful' ||
update.message.text === 'Joyful' ||
update.message.text === 'hopeful' ||
update.message.text === 'Hopeful' ||
update.message.text === 'cheerful' ||
update.message.text === 'Cheerful' ||
update.message.text === 'euphoric' ||
update.message.text === 'Euphoric' ||
update.message.text === 'satisfied' ||
update.message.text === 'Satisfied' ||
update.message.text === 'inspired' ||
update.message.text === 'Inspired' ||
update.message.text === 'energetic' ||
update.message.text === 'Energetic' ||
update.message.text === 'positive' ||
update.message.text === 'Positive' ||
update.message.text === 'lucky' ||
update.message.text === 'Lucky' ||
update.message.text === 'awesome' ||
update.message.text === 'Awesome'
) {
bot.sendTextCascadeTo(messages.positive, update.sender.id);
}
else if (update.message.text === 'Y' )
{
bot.sendTextCascadeTo(messages.reflectionyes, update.sender.id);
}
else if (update.message.text === 'N' )
{
bot.sendTextCascadeTo(messages.reflectionno, update.sender.id);
}
else {
bot.sendTextCascadeTo(messages.reflection, update.sender.id);
}
};
botmaster.use({
type: 'incoming',
name: 'My incoming middleware',
controller: myIncomingMiddlewareController,
});