forked from hczhcz/telegram-kuso-bots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththreesome.gather.js
218 lines (182 loc) · 6.76 KB
/
threesome.gather.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
'use strict';
module.exports = (bot, games) => {
const self = {
join: (msg) => {
const game = games[msg.chat.id];
if (!game.users[msg.from.id] && game.usercount < game.modemax) {
game.usercount += 1;
game.users[msg.from.id] = msg.from;
if (game.time > -60) {
game.time = -60;
}
return bot.sendMessage(
msg.chat.id,
msg.from.first_name + ' 加入了' + game.modename + ','
+ game.usercount + ' 名禽兽参加,'
+ '最少 ' + game.modemin + ' 人参加,'
+ '最多 ' + game.modemax + ' 人参加'
).then(() => {
if (game.usercount === game.modemax) {
game.time = 0;
}
});
}
},
flee: (msg) => {
const game = games[msg.chat.id];
if (game.users[msg.from.id]) {
game.usercount -= 1;
delete game.users[msg.from.id];
if (game.time > -30) {
game.time = -30;
}
return bot.sendMessage(
msg.chat.id,
msg.from.first_name + ' 逃离了' + game.modename + ','
+ '不再与大家啪啪\n'
+ '\n'
+ '剩余 ' + game.usercount + ' 人'
);
}
},
invite: (msg, player) => {
const game = games[msg.chat.id];
if (player) {
if (!game.users[player.id] && game.usercount < game.modemax) {
game.usercount += 1;
game.users[player.id] = player;
if (game.time > -60) {
game.time = -60;
}
return bot.sendMessage(
msg.chat.id,
msg.from.first_name + ' 给 '
+ player.first_name + ' 灌下了春药,'
+ game.usercount + ' 名禽兽参加,'
+ '最少 ' + game.modemin + ' 人参加,'
+ '最多 ' + game.modemax + ' 人参加'
).then(() => {
if (game.usercount === game.modemax) {
game.time = 0;
}
});
}
}
},
smite: (msg, player) => {
const game = games[msg.chat.id];
if (player) {
if (game.users[player.id]) {
game.usercount -= 1;
delete game.users[player.id];
if (game.time > -30) {
game.time = -30;
}
return bot.sendMessage(
msg.chat.id,
msg.from.first_name + ' 把 '
+ player.first_name + ' 踢下了床,'
+ '剩余 ' + game.usercount + ' 人'
);
}
} else {
self.flee(msg);
}
},
extend: (msg, time) => {
const game = games[msg.chat.id];
game.time -= time;
if (game.time < -300) {
game.time = -300;
} else if (game.time > 0) {
game.time = 0;
}
return bot.sendMessage(
msg.chat.id,
'续命成功!'
+ '剩余 ' + -game.time + ' 秒 /join'
);
},
start: (msg) => {
const game = games[msg.chat.id];
game.time = 0;
},
fallback: (msg) => {
const game = games[msg.chat.id];
game.time = 0;
if (game.usercount < game.modemin) {
switch (game.usercount) {
case 3:
game.modename = '这场 3P';
game.modemin = 3;
return bot.sendMessage(
msg.chat.id,
'来一发 3P 就不用担心三缺一啦'
);
case 2:
game.modename = '滚床单活动';
game.modemin = 2;
return bot.sendMessage(
msg.chat.id,
'两个人相视一笑,来制造生命的大和谐'
);
case 1:
game.modename = '撸管';
game.modemin = 1;
return bot.sendMessage(
msg.chat.id,
'还是自己撸一发吧'
);
case 0:
break;
default:
game.modename = '这场群P';
game.modemin = 3;
return bot.sendMessage(
msg.chat.id,
'其实,' + game.usercount + 'P 也是可以的嘛'
);
}
}
},
tick: (msg) => {
const game = games[msg.chat.id];
switch (game.time) {
case -60:
return bot.sendMessage(
msg.chat.id,
'剩余一分钟 /join'
);
case -30:
return bot.sendMessage(
msg.chat.id,
'剩余 30 秒 /join'
);
case -10:
return bot.sendMessage(
msg.chat.id,
'剩余 10 秒 /join'
);
case 0:
if (game.usercount >= game.modemin) {
game.total = 120 + game.usercount * 30;
return bot.sendMessage(
msg.chat.id,
'开始啪啪啦!啪啪啪啪啪啪啪啪'
);
}
{
const mode = game.modename;
delete games[msg.chat.id];
return bot.sendMessage(
msg.chat.id,
'禽兽人数不足,已取消' + mode
);
}
default:
// nothing
}
},
};
return self;
};