/
pidorall.go
33 lines (29 loc) · 1.09 KB
/
pidorall.go
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
package pidor
import (
"golang.org/x/text/language"
"golang.org/x/text/message"
"github.com/NexonSU/telegram-go-chatbot/utils"
tele "gopkg.in/telebot.v3"
)
//Send top 10 pidors of all time on /pidorall
func Pidorall(context tele.Context) error {
// prt will replace fmt package to format text according plurals defined in utils package
// If no plural rule matched it will be ignored and processed as usual formatting
prt := message.NewPrinter(language.Russian)
var i = 0
var username string
var count int64
var pidorall = "Топ-10 пидоров за всё время:\n\n"
result, _ := utils.DB.Select("username, COUNT(*) as count").Table("pidor_stats, pidor_lists").Where("pidor_stats.user_id=pidor_lists.id").Group("user_id").Order("count DESC").Limit(10).Rows()
for result.Next() {
err := result.Scan(&username, &count)
if err != nil {
return err
}
i++
pidorall += prt.Sprintf("%v. %v - %d раз\n", i, username, count)
}
utils.DB.Model(utils.PidorList{}).Count(&count)
pidorall += prt.Sprintf("\nВсего участников — %v", count)
return context.Reply(pidorall)
}