-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
142 lines (109 loc) · 3.67 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
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
var TelegramBot = require('node-telegram-bot-api');
var token = '291482532:AAEkKodHdD8E_tos79TlSbsW1y2ymkkaiek';
var bot = new TelegramBot(token, {polling:{interval:200}});
var http = require("http");
setInterval(function() {
http.get("http://kimmotherbot.herokuapp.com");
}, 30000); // every 5 minutes (300000)
// Kim's reply when you ask who is he
bot.onText(/\/whoiskim/, function (msg, match) {
var fromId = msg.chat.id;
var kimReply = "Hi I am Kim and I have a dig bick.";
bot.sendMessage(fromId, kimReply );
bot.sendPhoto(fromId, 'kimpicture.jpg');
});
bot.onText(/\/kimopen (.+)/, function (msg, match){
var fromId = msg.chat.id;
var dayToSearch = match[1];
var open;
var openingHours;
var closingHours;
var closeMessage = "My Mom's shop does not open on Tuesday? How many times must I tell you? Is it so hard to remember?";
var stupidMessage = null;
var WEEK_OPENING = 10;
var WEEKEND_CLOSING = 19;
var WEEKDAY_CLOSING = 20;
openingHours = WEEK_OPENING;
switch (dayToSearch){
case "monday" :
open = true;
closingHours = WEEKDAY_CLOSING;
break;
case "tuesday" :
open = false;
break;
case "wednesday" :
open = true;
closingHours = WEEKDAY_CLOSING;
break;
case "thursday" :
open = true;
closingHours = WEEKDAY_CLOSING;
break;
case "friday" :
open = true;
closingHours = WEEKDAY_CLOSING;
break;
case "saturday" :
open = true;
closingHours = WEEKEND_CLOSING;
break;
case "sunday" :
open = true;
closingHours = WEEKEND_CLOSING;
break;
default :
stupidMessage = "Wtf you don't know how to type in days?";
}
var openingHourDate = new Date();
openingHourDate.setHours(openingHours);
var closingHourDate = new Date();
closingHourDate.setHours(closingHours);
var openMessage = "The shop is open on " + dayToSearch;
if (stupidMessage != null){
bot.sendMessage(fromId, stupidMessage);
}
else if (open){
bot.sendMessage(fromId, openMessage);
}
else if (!open){
bot.sendMessage(fromId, closeMessage);
}
});
bot.onText(/\/kimopentmr/, function (msg, match){
var fromId = msg.chat.id;
var day = new Date();
var today = day.getDay();
var message;
if(today == 1){
message = "My Mom's shop does not open on Tuesday? How many times must I tell you? Is it so hard to remember?";
}
else {
message = "The shop is open tmr. Come come enjoy.";
}
bot.sendMessage(fromId, message);
});
bot.onText(/\/marcussuspended/, function (msg, match){
var fromId = msg.chat.id;
var message = "That's why he's so free to wish us all the best";
bot.sendMessage(fromId, message);
})
bot.onText(/\/kimopentoday/, function (msg, match){
var fromId = msg.chat.id;
var day = new Date();
var today = day.getDay();
var message;
if (today == 2){
message = "My Mom's shop does not open on Tuesday? How many times must I tell you? Is it so hard to remember?";
}
else {
message = "The shop is open today! Come come enjoy.";
}
bot.sendMessage(fromId, message);
});
bot.onText(/\/kimentertainme/, function(msg,match){
var fromId = msg.chat.id;
var message = ["I have a digger bick than you.", "I do wushu.", "Lemon.", "Merling", "lemonlemonlemonlemonlemongullible"];
var chosenMessage = message[Math.floor(Math.random() * message.length)];
bot.sendMessage(fromId, chosenMessage);
});