MCPcopy Index your code
hub / github.com/FloatTech/ZeroBot-Plugin / getChatRank

Method getChatRank

plugin/chatcount/model.go:156–182  ·  view source on GitHub ↗

getChatRank 获得水群排名,时间单位为秒

(gid int64)

Source from the content-addressed store, hash-verified

154
155// getChatRank 获得水群排名,时间单位为秒
156func (ctdb *chattimedb) getChatRank(gid int64) (chatTimeList []chatTime) {
157 ctdb.chatmu.Lock()
158 defer ctdb.chatmu.Unlock()
159 chatTimeList = make([]chatTime, 0, 100)
160 keyList := make([]string, 0, 100)
161 ctdb.userTimestampMap.Range(func(key string, value int64) bool {
162 t := time.Unix(value, 0)
163 if strings.Contains(key, strconv.FormatInt(gid, 10)) && t.YearDay() == time.Now().YearDay() {
164 keyList = append(keyList, key)
165 }
166 return true
167 })
168 for _, v := range keyList {
169 _, a, _ := strings.Cut(v, "_")
170 uid, _ := strconv.ParseInt(a, 10, 64)
171 todayTime, _ := ctdb.userTodayTimeMap.Load(v)
172 todayMessage, _ := ctdb.userTodayMessageMap.Load(v)
173 chatTimeList = append(chatTimeList, chatTime{
174 GroupID: gid,
175 UserID: uid,
176 TodayTime: todayTime,
177 TodayMessage: todayMessage,
178 })
179 }
180 sort.Sort(sortChatTime(chatTimeList))
181 return
182}
183
184// leveler 结构体,包含一个 levelArray 字段
185type leveler struct {

Callers 1

initFunction · 0.80

Calls 2

sortChatTimeTypeAlias · 0.85
SortMethod · 0.80

Tested by

no test coverage detected