Sort GP list by amount
This commit is contained in:
parent
eb10fde8f7
commit
52f4898c2b
3 changed files with 9 additions and 9 deletions
|
@ -49,7 +49,7 @@ func help(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
"<code>/help </code><i>Sends this help message</i>" + "\n" +
|
"<code>/help </code><i>Sends this help message</i>" + "\n" +
|
||||||
"<code>/gp </code><i>List Gaypoints for user or group</i>" + "\n" +
|
"<code>/gp </code><i>List Gaypoints for user or group</i>" + "\n" +
|
||||||
"<code>/remindme 2m,5h,7d <message> </code> <i>Send a reminder message in 2 minutes, 5 hours, 7 days</i>" + "\n\n" +
|
"<code>/remindme 2m,5h,7d <message> </code> <i>Send a reminder message in 2 minutes, 5 hours, 7 days</i>" + "\n\n" +
|
||||||
"<b>Admin Commands:</b>" + "\n\n" +
|
"<b>Admin Commands:</b>" + "\n" +
|
||||||
"<code>/addgp <amount> </code> <i>Add Gaypoints to User</i>" + "\n" +
|
"<code>/addgp <amount> </code> <i>Add Gaypoints to User</i>" + "\n" +
|
||||||
"<code>/subtractgp <amount> </code> <i>Add Gaypoints to User</i>" + "\n"
|
"<code>/subtractgp <amount> </code> <i>Add Gaypoints to User</i>" + "\n"
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,13 @@ func GetGP(update tgbotapi.Update, bot *tgbotapi.BotAPI) {
|
||||||
gps := sqlGetAllGP(update.Message.Chat.ID)
|
gps := sqlGetAllGP(update.Message.Chat.ID)
|
||||||
|
|
||||||
var messagetext string
|
var messagetext string
|
||||||
for userid, points := range gps {
|
for _, gaypointInfo := range gps {
|
||||||
currentUser := botIO.GetUserByID(update.Message.Chat.ID, userid, bot)
|
currentUser := botIO.GetUserByID(update.Message.Chat.ID, gaypointInfo.userID, bot)
|
||||||
currentName := currentUser.User.FirstName
|
currentName := currentUser.User.FirstName
|
||||||
if currentUser.User.UserName != "" {
|
if currentUser.User.UserName != "" {
|
||||||
currentName = currentUser.User.UserName
|
currentName = currentUser.User.UserName
|
||||||
}
|
}
|
||||||
text := `<a href="` + `tg://user?id=` + strconv.FormatInt(userid, 10) + `">` + currentName + `</a>` + ` currently has ` + `<b>` + strconv.FormatInt(points, 10) + `</b>` + ` gaypoints` + "\n"
|
text := `<a href="` + `tg://user?id=` + strconv.FormatInt(gaypointInfo.userID, 10) + `">` + currentName + `</a>` + ` currently has ` + `<b>` + strconv.FormatInt(gaypointInfo.gaypoints, 10) + `</b>` + ` gaypoints` + "\n"
|
||||||
|
|
||||||
messagetext = messagetext + text
|
messagetext = messagetext + text
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,21 +13,21 @@ var gpSelectChat *sql.Stmt
|
||||||
|
|
||||||
var gpSet *sql.Stmt
|
var gpSet *sql.Stmt
|
||||||
|
|
||||||
func sqlGetAllGP(chatid int64) (gaypoints map[int64]int64) {
|
func sqlGetAllGP(chatid int64) (gaypoints []gaypointShortDetails) {
|
||||||
rows, err := gpSelectChat.Query(chatid)
|
rows, err := gpSelectChat.Query(chatid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("Failed to query gaypoints: %v\n", err)
|
log.Panicf("Failed to query gaypoints: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
gaypoints = make(map[int64]int64)
|
|
||||||
var c int64
|
var c int64
|
||||||
var b int64
|
var b int64
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
switch err := rows.Scan(&c, &b); err {
|
switch err := rows.Scan(&c, &b); err {
|
||||||
case sql.ErrNoRows:
|
|
||||||
gaypoints[c] = -1
|
|
||||||
case nil:
|
case nil:
|
||||||
gaypoints[c] = b
|
gaypoints = append(gaypoints, gaypointShortDetails{
|
||||||
|
userID: c,
|
||||||
|
gaypoints: b,
|
||||||
|
})
|
||||||
default:
|
default:
|
||||||
log.Panicf("Failed to query gaypoints: %v\n", err)
|
log.Panicf("Failed to query gaypoints: %v\n", err)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue