-
Notifications
You must be signed in to change notification settings - Fork 13
/
threesome.stat.js
237 lines (216 loc) · 12.3 KB
/
threesome.stat.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
'use strict';
module.exports = (bot, stats) => {
return {
stat: (msg, player) => {
const statSize = (data) => {
let count = 0;
let max = 0;
let sum = 0;
for (const i in data) {
count += data[i];
max = Math.max(max, i);
sum += i * data[i];
}
const ave = Math.round(sum / count * 100) / 100 || 0;
return {
count: count,
max: max,
ave: ave,
};
};
const statTop = (data, level, symmetry) => {
let count = 0;
let top1 = [0];
let top2 = [0];
let top3 = [0];
const stat = (item) => {
count += item[0];
if (item[0] > top1[0]) {
top3 = top2;
top2 = top1;
top1 = item;
} else if (item[0] > top2[0]) {
top3 = top2;
top2 = item;
} else if (item[0] > top3[0]) {
top3 = item;
}
};
if (level === 3) {
for (const i in data) {
for (const j in data[i]) {
for (const k in data[i][j]) {
stat([data[i][j][k], i, j, k]);
}
}
}
} else if (level === 2) {
for (const i in data) {
for (const j in data[i]) {
if (!symmetry || i < j) {
stat([data[i][j], i, j]);
}
}
}
} else if (level === 1) {
for (const i in data) {
stat([data[i], i]);
}
} else {
// never reach
throw Error();
}
return {
count: count,
top1: top1,
top2: top2,
top3: top3,
};
};
// TODO: reorganize code
if (player) {
const gameStat = stats.game[msg.chat.id] || {
chat: {},
userTotal: {},
user: {},
pair: {},
};
const commandStat = stats.command[msg.chat.id] || {
chat: {},
user: {},
pair: {},
reply: {},
replyPair: {},
};
const inlineStat = stats.inline[player.id] || {};
const gameUserStat = statSize(gameStat.user[player.id]);
const gamePairStat = statTop(gameStat.pair[player.id], 1);
const commandUserStat = statTop(commandStat.user[player.id], 1);
const commandPairStat = statTop(commandStat.pair[player.id], 2);
const commandReplyStat = statTop(commandStat.reply[player.id], 1);
const commandReplyPairStat = statTop(commandStat.replyPair[player.id], 2);
const inlineUserStat = statSize(inlineStat);
return bot.sendMessage(
msg.chat.id,
(stats.name[player.id] || '') + ' 啪啪了 ' + gameUserStat.count + ' 次,其中:\n'
+ '3P 有 ' + ((gameStat.user[player.id] || {})[3] || 0) + ' 次\n'
+ '2P 有 ' + ((gameStat.user[player.id] || {})[2] || 0) + ' 次\n'
+ '撸管 有 ' + ((gameStat.user[player.id] || {})[1] || 0) + ' 次\n'
+ (stats.name[player.id] || '') + ' 最多参与过 ' + gameUserStat.max + 'P\n'
+ '每次啪啪平均 ' + gameUserStat.ave + ' 人\n'
+ '\n'
+ (stats.name[player.id] || '') + ' 最喜欢的性伴侣是:\n'
+ (stats.name[gamePairStat.top1[1]] || '') + '(' + (gamePairStat.top1[0] || 0) + ' 次)\n'
+ (stats.name[gamePairStat.top2[1]] || '') + '(' + (gamePairStat.top2[0] || 0) + ' 次)\n'
+ (stats.name[gamePairStat.top3[1]] || '') + '(' + (gamePairStat.top3[0] || 0) + ' 次)\n'
+ '\n'
+ (stats.name[player.id] || '') + ' 触发过 ' + commandUserStat.count + ' 个 trigger,最多的 trigger 是:\n'
+ (commandUserStat.top1[1] || '') + '(' + (commandUserStat.top1[0] || 0) + ' 次)\n'
+ (commandUserStat.top2[1] || '') + '(' + (commandUserStat.top2[0] || 0) + ' 次)\n'
+ (commandUserStat.top3[1] || '') + '(' + (commandUserStat.top3[0] || 0) + ' 次)\n'
+ '\n'
+ '其中,' + (stats.name[player.id] || '') + ' 经常:\n'
+ (commandPairStat.top1[2] || '') + ' ' + (stats.name[commandPairStat.top1[1]] || '')
+ '(' + (commandPairStat.top1[0] || 0) + ' 次)\n'
+ (commandPairStat.top2[2] || '') + ' ' + (stats.name[commandPairStat.top2[1]] || '')
+ '(' + (commandPairStat.top2[0] || 0) + ' 次)\n'
+ (commandPairStat.top3[2] || '') + ' ' + (stats.name[commandPairStat.top3[1]] || '')
+ '(' + (commandPairStat.top3[0] || 0) + ' 次)\n'
+ '\n'
+ (stats.name[player.id] || '') + ' 接受过 ' + commandReplyStat.count + ' 个 trigger,最多的 trigger 是:\n'
+ (commandReplyStat.top1[1] || '') + '(' + (commandReplyStat.top1[0] || 0) + ' 次)\n'
+ (commandReplyStat.top2[1] || '') + '(' + (commandReplyStat.top2[0] || 0) + ' 次)\n'
+ (commandReplyStat.top3[1] || '') + '(' + (commandReplyStat.top3[0] || 0) + ' 次)\n'
+ '\n'
+ '其中,' + (stats.name[player.id] || '') + ' 经常:\n'
+ '被 ' + (stats.name[commandReplyPairStat.top1[1]] || '') + ' ' + (commandReplyPairStat.top1[2] || '')
+ '(' + (commandReplyPairStat.top1[0] || 0) + ' 次)\n'
+ '被 ' + (stats.name[commandReplyPairStat.top2[1]] || '') + ' ' + (commandReplyPairStat.top2[2] || '')
+ '(' + (commandReplyPairStat.top2[0] || 0) + ' 次)\n'
+ '被 ' + (stats.name[commandReplyPairStat.top3[1]] || '') + ' ' + (commandReplyPairStat.top3[2] || '')
+ '(' + (commandReplyPairStat.top3[0] || 0) + ' 次)\n'
+ '\n'
+ (stats.name[player.id] || '') + ' 呻吟了 ' + inlineUserStat.count + ' 次\n'
+ '最长的呻吟有 ' + inlineUserStat.max + ' 段\n'
+ '平均呻吟长度 ' + inlineUserStat.ave + ' 段',
{
reply_to_message_id: msg.message_id,
}
);
}
const gameStat = stats.game[msg.chat.id] || {
chat: {},
userTotal: {},
user: {},
pair: {},
};
const commandStat = stats.command[msg.chat.id] || {
chat: {},
user: {},
pair: {},
reply: {},
replyPair: {},
};
const gameChatStat = statSize(gameStat.chat);
const gameUserTotalStat = statTop(gameStat.userTotal, 1);
const gamePairStat = statTop(gameStat.pair, 2, true);
const commandChatStat = statTop(commandStat.chat, 1);
const commandUserStat = statTop(commandStat.user, 2);
const commandPairStat = statTop(commandStat.pair, 3);
const commandReplyStat = statTop(commandStat.reply, 2);
return bot.sendMessage(
msg.chat.id,
'本群总共啪啪了 ' + gameChatStat.count + ' 次,其中:\n'
+ '3P 有 ' + (gameStat.chat[3] || 0) + ' 次\n'
+ '2P 有 ' + (gameStat.chat[2] || 0) + ' 次\n'
+ '撸管 有 ' + (gameStat.chat[1] || 0) + ' 次\n'
+ '本群最多发生过 ' + gameChatStat.max + 'P\n'
+ '每次啪啪平均 ' + gameChatStat.ave + ' 人\n'
+ '\n'
+ '本群最勤劳的是:\n'
+ (stats.name[gameUserTotalStat.top1[1]] || '') + '(' + (gameUserTotalStat.top1[0] || 0) + ' 次)\n'
+ (stats.name[gameUserTotalStat.top2[1]] || '') + '(' + (gameUserTotalStat.top2[0] || 0) + ' 次)\n'
+ (stats.name[gameUserTotalStat.top3[1]] || '') + '(' + (gameUserTotalStat.top3[0] || 0) + ' 次)\n'
+ '\n'
+ '本群最缠绵的是:\n'
+ (stats.name[gamePairStat.top1[1]] || '') + ' 和 ' + (stats.name[gamePairStat.top1[2]] || '')
+ '(' + (gamePairStat.top1[0] || 0) + ' 次)\n'
+ (stats.name[gamePairStat.top2[1]] || '') + ' 和 ' + (stats.name[gamePairStat.top2[2]] || '')
+ '(' + (gamePairStat.top2[0] || 0) + ' 次)\n'
+ (stats.name[gamePairStat.top3[1]] || '') + ' 和 ' + (stats.name[gamePairStat.top3[2]] || '')
+ '(' + (gamePairStat.top3[0] || 0) + ' 次)\n'
+ '\n'
+ '所有人总共触发过 ' + commandChatStat.count + ' 个 trigger,最多的 trigger 是:\n'
+ (commandChatStat.top1[1] || '') + '(' + (commandChatStat.top1[0] || 0) + ' 次)\n'
+ (commandChatStat.top2[1] || '') + '(' + (commandChatStat.top2[0] || 0) + ' 次)\n'
+ (commandChatStat.top3[1] || '') + '(' + (commandChatStat.top3[0] || 0) + ' 次)\n'
+ '\n'
+ '本群的日常是:\n'
+ (stats.name[commandUserStat.top1[1]] || '') + ' 喜欢 ' + (commandUserStat.top1[2] || '')
+ '(' + (commandUserStat.top1[0] || 0) + ' 次)\n'
+ (stats.name[commandUserStat.top2[1]] || '') + ' 喜欢 ' + (commandUserStat.top2[2] || '')
+ '(' + (commandUserStat.top2[0] || 0) + ' 次)\n'
+ (stats.name[commandUserStat.top3[1]] || '') + ' 喜欢 ' + (commandUserStat.top3[2] || '')
+ '(' + (commandUserStat.top3[0] || 0) + ' 次)\n'
+ (stats.name[commandPairStat.top1[1]] || '') + ' 经常 '
+ (commandPairStat.top1[3] || '') + ' ' + (stats.name[commandPairStat.top1[2]] || '')
+ '(' + (commandPairStat.top1[0] || 0) + ' 次)\n'
+ (stats.name[commandPairStat.top2[1]] || '') + ' 经常 '
+ (commandPairStat.top2[3] || '') + ' ' + (stats.name[commandPairStat.top2[2]] || '')
+ '(' + (commandPairStat.top2[0] || 0) + ' 次)\n'
+ (stats.name[commandPairStat.top3[1]] || '') + ' 经常 '
+ (commandPairStat.top3[3] || '') + ' ' + (stats.name[commandPairStat.top3[2]] || '')
+ '(' + (commandPairStat.top3[0] || 0) + ' 次)\n'
+ (stats.name[commandReplyStat.top1[1]] || '') + ' 常被 ' + (commandReplyStat.top1[2] || '')
+ '(' + (commandReplyStat.top1[0] || 0) + ' 次)\n'
+ (stats.name[commandReplyStat.top2[1]] || '') + ' 常被 ' + (commandReplyStat.top2[2] || '')
+ '(' + (commandReplyStat.top2[0] || 0) + ' 次)\n'
+ (stats.name[commandReplyStat.top3[1]] || '') + ' 常被 ' + (commandReplyStat.top3[2] || '')
+ '(' + (commandReplyStat.top3[0] || 0) + ' 次)',
{
reply_to_message_id: msg.message_id,
}
);
},
};
};