-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot2.js
284 lines (252 loc) · 7.15 KB
/
bot2.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
var Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(logger.transports.Console, {
colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
token: auth.token,
autorun: true
});
bot.on('ready', function (evt, channelID) {
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.username + ' - (' + bot.id + ')');
});
var on = false;
var question_choice;
bot.on('message', function (user, userID, channelID, message, evt) {
if (message.substring(0, 1) == ';') {
var ans = message.substring(1).toLowerCase(); //Question answer vars
var args = message.substring(1).split(' ');
var cmd = args[0];
args = args.splice(1);
if(on == false){
switch(cmd){
case 'start':
get_Question(channelID);
console.log(question_choice);
return;
break;
}
}
answer_Question(question_choice, channelID, ans);
}//end if (message....)
});// end function
function answer_Question(question_choice, channelID, ans)
{
if(question_choice === 1){
if(ans === 'pony express'){
bot.sendMessage({
to: channelID,
message: "Correct!"
})
on = false;
}
else{
bot.sendMessage({
to: channelID,
message: "Wrong!"
})
on = false;
}
}
else if(question_choice === 2){
if(ans === 'camel'){
bot.sendMessage({
to: channelID,
message: "Correct!"
})
on = false;
}
else{
bot.sendMessage({
to: channelID,
message: "Wrong!"
})
on = false;
}
}
else if(question_choice === 3){
if(ans === 'vincent van gogh'){
bot.sendMessage({
to: channelID,
message: "Correct!"
})
on = false;
}
else{
bot.sendMessage({
to: channelID,
message: "Wrong!"
})
on = false;
}
}
else if(question_choice === 4){
if(ans === '1990'){
bot.sendMessage({
to: channelID,
message: "Correct!"
})
on = false;
}
else{
bot.sendMessage({
to: channelID,
message: "Wrong!"
})
on = false;
}
}
else if(question_choice === 5){
if(ans === 'liquid crystal display'){
bot.sendMessage({
to: channelID,
message: "Correct!"
})
on = false;
}
else{
bot.sendMessage({
to: channelID,
message: "Wrong!"
})
on = false;
}
}
else if(question_choice === 6){
if(ans === 'read only memory'){
bot.sendMessage({
to: channelID,
message: "Correct!"
})
on = false;
}
else{
bot.sendMessage({
to: channelID,
message: "Wrong!"
})
on = false;
}
}
else if(question_choice === 7){
if(ans === 'kodak'){
bot.sendMessage({
to: channelID,
message: "Correct!"
})
on = false;
}
else{
bot.sendMessage({
to: channelID,
message: "Wrong!"
})
on = false;
}
}
else if(question_choice === 8){
if(ans === '1993'){
bot.sendMessage({
to: channelID,
message: "Correct!"
})
on = false;
}
else{
bot.sendMessage({
to: channelID,
message: "Wrong!"
})
on = false;
}
}
else if(question_choice === 9){
if(ans === '1976'){
bot.sendMessage({
to: channelID,
message: "Correct!"
})
on = false;
}
else{
bot.sendMessage({
to: channelID,
message: "Wrong!"
})
on = false;
}
}
}
function get_Question(channelID) {
question_choice = getRandomInt(1,11);
switch(question_choice){
case 1:
bot.sendMessage({
to: channelID,
message: 'What was the name of the U.S. mail service, started in 1860, that used horses and riders?'
});
break;
case 2:
bot.sendMessage({
to: channelID,
message: 'What type of animal is known as the ship of the desert?'
});
break;
case 3:
bot.sendMessage({
to: channelID,
message: 'The Starry Night is an oil on canvas painted by which post-impressionist painter?'
});
break;
case 4:
bot.sendMessage({
to: channelID,
message: 'CERN launched the very first website in what year?'
});
break;
case 5:
bot.sendMessage({
to: channelID,
message: 'When referring to a computer monitor, what does the acronym LCD stand for?'
});
break;
case 6:
bot.sendMessage({
to: channelID,
message: 'When talking about computer memory, what does the acronym ROM stand for?'
});
break;
case 7:
bot.sendMessage({
to: channelID,
message: 'In 1975 an engineer created the first electronic camera while working for what company?'
});
break;
case 8:
bot.sendMessage({
to: channelID,
message: 'The first person shooter video game Doom was first released in what year?'
});
break;
case 9:
bot.sendMessage({
to: channelID,
message: 'In what year was the first Apple computer released?'
});
break;
on = true;
return question_choice;
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}