✨ Added '/delPack' command support
This command delete whole set from user pack by of getted sticker. Close #4
This commit is contained in:
parent
957bc2b4ac
commit
133a271831
|
@ -17,8 +17,10 @@ func commandCancel(msg *tg.Message) {
|
|||
text = T("cancel_add_sticker")
|
||||
case stateAddPack:
|
||||
text = T("cancel_add_pack")
|
||||
case stateDelete:
|
||||
text = T("cancel_del")
|
||||
case stateDeleteSticker:
|
||||
text = T("cancel_del_sticker")
|
||||
case stateDeletePack:
|
||||
text = T("cancel_del_pack")
|
||||
case stateReset:
|
||||
text = T("cancel_reset")
|
||||
default:
|
||||
|
|
|
@ -17,9 +17,11 @@ func channelPost(post *tg.Message) {
|
|||
errCheck(err)
|
||||
|
||||
for i := range users {
|
||||
bot.ForwardMessage(
|
||||
if _, err = bot.ForwardMessage(
|
||||
tg.NewForwardMessage(post.Chat.ID, int64(users[i]), post.ID),
|
||||
)
|
||||
); err != nil {
|
||||
log.Ln(err.Error())
|
||||
}
|
||||
|
||||
time.Sleep(time.Second / 10) // For avoid spamming
|
||||
}
|
||||
|
|
|
@ -8,13 +8,14 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
cmdAddPack = "addPack"
|
||||
cmdAddSticker = "addSticker"
|
||||
cmdCancel = "cancel"
|
||||
cmdHelp = "help"
|
||||
cmdDelete = "del"
|
||||
cmdReset = "reset"
|
||||
cmdStart = "start"
|
||||
cmdAddPack = "addPack"
|
||||
cmdAddSticker = "addSticker"
|
||||
cmdCancel = "cancel"
|
||||
cmdHelp = "help"
|
||||
cmdDeleteSticker = "delSticker"
|
||||
cmdDeletePack = "delPack"
|
||||
cmdReset = "reset"
|
||||
cmdStart = "start"
|
||||
)
|
||||
|
||||
func commands(msg *tg.Message) {
|
||||
|
@ -28,8 +29,10 @@ func commands(msg *tg.Message) {
|
|||
commandAdd(msg, false)
|
||||
case strings.ToLower(cmdAddPack):
|
||||
commandAdd(msg, true)
|
||||
case strings.ToLower(cmdDelete):
|
||||
commandDelete(msg)
|
||||
case strings.ToLower(cmdDeleteSticker):
|
||||
commandDelete(msg, false)
|
||||
case strings.ToLower(cmdDeletePack):
|
||||
commandDelete(msg, true)
|
||||
case strings.ToLower(cmdReset):
|
||||
commandReset(msg)
|
||||
case strings.ToLower(cmdCancel):
|
||||
|
|
|
@ -10,11 +10,12 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
stateNone = "none"
|
||||
stateAddSticker = "addSticker"
|
||||
stateAddPack = "addPack"
|
||||
stateDelete = "del"
|
||||
stateReset = "reset"
|
||||
stateNone = "none"
|
||||
stateAddSticker = "addSticker"
|
||||
stateAddPack = "addPack"
|
||||
stateDeleteSticker = "delSticker"
|
||||
stateDeletePack = "delPack"
|
||||
stateReset = "reset"
|
||||
|
||||
setUploaded = "?"
|
||||
|
||||
|
@ -46,14 +47,6 @@ func dbInit() {
|
|||
)
|
||||
errCheck(err)
|
||||
|
||||
err = db.Update(func(tx *buntdb.Tx) error {
|
||||
return tx.AscendKeys("user:*:sticker:*", func(key, val string) bool {
|
||||
tx.Delete(key)
|
||||
return true
|
||||
})
|
||||
})
|
||||
errCheck(err)
|
||||
|
||||
select {}
|
||||
}
|
||||
|
||||
|
@ -63,7 +56,6 @@ func dbGetUsers() ([]int, error) {
|
|||
return tx.AscendKeys(
|
||||
"user:*:state",
|
||||
func(key, val string) bool {
|
||||
log.Ln(key, "=", val)
|
||||
subKeys := strings.Split(key, ":")
|
||||
id, err := strconv.Atoi(subKeys[1])
|
||||
if err == nil {
|
||||
|
@ -159,12 +151,49 @@ func dbDeleteSticker(userID int, setName, fileID string) (bool, error) {
|
|||
return false, err
|
||||
}
|
||||
|
||||
func dbDeletePack(userID int, setName string) (bool, error) {
|
||||
log.Ln("Trying to remove all", setName, "sticker from", userID, "user")
|
||||
if setName == "" {
|
||||
setName = setUploaded
|
||||
}
|
||||
|
||||
var fileIDs []string
|
||||
err := db.View(func(tx *buntdb.Tx) error {
|
||||
return tx.AscendKeys(
|
||||
fmt.Sprint("user:", userID, ":set:", setName, ":*"),
|
||||
func(key, val string) bool {
|
||||
keys := strings.Split(key, ":")
|
||||
fileIDs = append(fileIDs, keys[5])
|
||||
return true
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
if len(fileIDs) == 0 {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
for _, fileID := range fileIDs {
|
||||
notExist, err := dbDeleteSticker(userID, setName, fileID)
|
||||
if err != nil {
|
||||
return notExist, err
|
||||
}
|
||||
}
|
||||
|
||||
switch err {
|
||||
case buntdb.ErrNotFound:
|
||||
log.Ln(userID, "not found")
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, err
|
||||
}
|
||||
|
||||
func dbResetUserStickers(userID int) error {
|
||||
log.Ln("Trying reset all stickers of", userID, "user")
|
||||
return db.Update(func(tx *buntdb.Tx) error {
|
||||
var keys []string
|
||||
|
||||
err := tx.AscendKeys(
|
||||
if err := tx.AscendKeys(
|
||||
patternUserSets, // index
|
||||
func(key, val string) bool { // iterator
|
||||
subKeys := strings.Split(key, ":")
|
||||
|
@ -173,19 +202,18 @@ func dbResetUserStickers(userID int) error {
|
|||
}
|
||||
return true
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := range keys {
|
||||
_, err = tx.Delete(keys[i])
|
||||
_, err := tx.Delete(keys[i])
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -199,7 +227,6 @@ func dbGetUserStickers(userID, offset int, query string) ([]string, int, error)
|
|||
return tx.AscendKeys(
|
||||
fmt.Sprint("user:", userID, ":set:*"), // index
|
||||
func(key, val string) bool { // iterator
|
||||
log.Ln(key, "=", val)
|
||||
subKeys := strings.Split(key, ":")
|
||||
if subKeys[1] != strconv.Itoa(userID) {
|
||||
return true
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package main
|
||||
|
||||
import tg "github.com/toby3d/telegram" // My Telegram bindings
|
||||
import (
|
||||
log "github.com/kirillDanshin/dlog" // Insert logs only in debug builds
|
||||
tg "github.com/toby3d/telegram" // My Telegram bindings
|
||||
)
|
||||
|
||||
func commandDelete(msg *tg.Message) {
|
||||
func commandDelete(msg *tg.Message, pack bool) {
|
||||
bot.SendChatAction(msg.Chat.ID, tg.ActionTyping)
|
||||
|
||||
T, err := switchLocale(msg.From.LanguageCode)
|
||||
|
@ -21,9 +24,19 @@ func commandDelete(msg *tg.Message) {
|
|||
return
|
||||
}
|
||||
|
||||
err = dbChangeUserState(msg.From.ID, stateDelete)
|
||||
reply := tg.NewMessage(msg.Chat.ID, T("reply_del_sticker"))
|
||||
reply.ParseMode = tg.ModeMarkdown
|
||||
|
||||
err = dbChangeUserState(msg.From.ID, stateDeleteSticker)
|
||||
errCheck(err)
|
||||
|
||||
if pack {
|
||||
reply.Text = T("reply_del_pack")
|
||||
|
||||
err = dbChangeUserState(msg.From.ID, stateDeletePack)
|
||||
errCheck(err)
|
||||
}
|
||||
|
||||
markup := tg.NewInlineKeyboardMarkup(
|
||||
tg.NewInlineKeyboardRow(
|
||||
tg.NewInlineKeyboardButtonSwitchSelf(
|
||||
|
@ -32,31 +45,37 @@ func commandDelete(msg *tg.Message) {
|
|||
),
|
||||
),
|
||||
)
|
||||
|
||||
reply := tg.NewMessage(msg.Chat.ID, T("reply_del"))
|
||||
reply.ParseMode = tg.ModeMarkdown
|
||||
reply.ReplyMarkup = &markup
|
||||
|
||||
_, err = bot.SendMessage(reply)
|
||||
errCheck(err)
|
||||
}
|
||||
|
||||
func actionDelete(msg *tg.Message) {
|
||||
func actionDelete(msg *tg.Message, pack bool) {
|
||||
bot.SendChatAction(msg.Chat.ID, tg.ActionTyping)
|
||||
|
||||
T, err := switchLocale(msg.From.LanguageCode)
|
||||
errCheck(err)
|
||||
|
||||
notExist, err := dbDeleteSticker(
|
||||
msg.From.ID,
|
||||
msg.Sticker.SetName,
|
||||
msg.Sticker.FileID,
|
||||
)
|
||||
errCheck(err)
|
||||
|
||||
reply := tg.NewMessage(msg.Chat.ID, T("success_del"))
|
||||
reply := tg.NewMessage(msg.Chat.ID, T("success_del_sticker"))
|
||||
reply.ParseMode = tg.ModeMarkdown
|
||||
|
||||
var notExist bool
|
||||
if pack {
|
||||
set, err := bot.GetStickerSet(msg.Sticker.SetName)
|
||||
errCheck(err)
|
||||
|
||||
log.Ln("SetName:", set.Title)
|
||||
reply.Text = T("success_del_pack", map[string]interface{}{
|
||||
"SetTitle": set.Title,
|
||||
})
|
||||
|
||||
notExist, err = dbDeletePack(msg.From.ID, msg.Sticker.SetName)
|
||||
} else {
|
||||
notExist, err = dbDeleteSticker(msg.From.ID, msg.Sticker.SetName, msg.Sticker.FileID)
|
||||
}
|
||||
errCheck(err)
|
||||
|
||||
if notExist {
|
||||
reply.Text = T("error_already_del")
|
||||
}
|
||||
|
|
|
@ -13,21 +13,19 @@ func commandHelp(msg *tg.Message) {
|
|||
|
||||
markup := tg.NewInlineKeyboardMarkup(
|
||||
tg.NewInlineKeyboardRow(
|
||||
tg.NewInlineKeyboardButtonSwitch(
|
||||
T("button_share"),
|
||||
" ",
|
||||
),
|
||||
tg.NewInlineKeyboardButtonSwitch(T("button_share"), " "),
|
||||
),
|
||||
)
|
||||
|
||||
reply := tg.NewMessage(
|
||||
msg.Chat.ID, T("reply_help", map[string]interface{}{
|
||||
"AddStickerCommand": cmdAddSticker,
|
||||
"AddPackCommand": cmdAddPack,
|
||||
"DeleteCommand": cmdDelete,
|
||||
"ResetCommand": cmdReset,
|
||||
"CancelCommand": cmdCancel,
|
||||
"Username": bot.Self.Username,
|
||||
"AddStickerCommand": cmdAddSticker,
|
||||
"AddPackCommand": cmdAddPack,
|
||||
"DeleteStickerCommand": cmdDeleteSticker,
|
||||
"DeletePackCommand": cmdDeletePack,
|
||||
"ResetCommand": cmdReset,
|
||||
"CancelCommand": cmdCancel,
|
||||
"Username": bot.Self.Username,
|
||||
}),
|
||||
)
|
||||
reply.ParseMode = tg.ModeMarkdown
|
||||
|
|
|
@ -10,11 +10,13 @@ button_inline_nothing:
|
|||
button_share:
|
||||
other: Use your stickers pack!
|
||||
cancel_add_pack:
|
||||
other: You cancelled the process of adding a new pack to yours.
|
||||
other: You cancelled the process of adding a new packs to yours.
|
||||
cancel_add_sticker:
|
||||
other: You cancelled the process of adding a new sticker to your pack.
|
||||
cancel_del:
|
||||
other: You cancelled the process of removing a sticker from your pack.
|
||||
other: You cancelled the process of adding a new stickers to your pack.
|
||||
cancel_del_pack:
|
||||
other: You cancelled the process of removing a sticker packs from yours.
|
||||
cancel_del_sticker:
|
||||
other: You cancelled the process of removing a stickers from your pack.
|
||||
cancel_error:
|
||||
other: Nothing to cancel.
|
||||
cancel_reset:
|
||||
|
@ -51,13 +53,16 @@ reply_add_pack:
|
|||
yourself.
|
||||
reply_add_sticker:
|
||||
other: Send an existing stickers from any other packs to add it to yourself.
|
||||
reply_del:
|
||||
reply_del_pack:
|
||||
other: Send an existing stickers from your pack to delete its entire set.
|
||||
reply_del_sticker:
|
||||
other: Send an existing stickers from your pack for removing it.
|
||||
reply_help:
|
||||
other: |-
|
||||
/{{.AddStickerCommand}} - add a single sticker to your pack
|
||||
/{{.AddPackCommand}} - add a full other pack to your pack
|
||||
/{{.DeleteCommand}} - remove a single sticker from your pack
|
||||
/{{.DeleteStickerCommand}} - remove a single sticker from your pack
|
||||
/{{.DeletePackCommand}} - remove a sticker set from your pack
|
||||
/{{.ResetCommand}} - remove all stickers from your pack
|
||||
/{{.CancelCommand}} - cancel the current operation
|
||||
|
||||
|
@ -77,7 +82,9 @@ success_add_pack:
|
|||
other: The sticker pack *{{.SetTitle}}* was successfully added to yours!
|
||||
success_add_sticker:
|
||||
other: The sticker was successfully added to your pack!
|
||||
success_del:
|
||||
success_del_pack:
|
||||
other: The sticker pack *{{.SetTitle}}* was successfully removed from yours!
|
||||
success_del_sticker:
|
||||
other: The sticker was successfully removed from your pack!
|
||||
success_reset:
|
||||
other: The contents of your pack are completely reset!..
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
cancel_add_sticker:
|
||||
other: You cancelled the process of adding a new sticker to your pack.
|
||||
other: You cancelled the process of adding a new stickers to your pack.
|
||||
cancel_add_pack:
|
||||
other: You cancelled the process of adding a new pack to yours.
|
||||
cancel_del:
|
||||
other: You cancelled the process of removing a sticker from your pack.
|
||||
other: You cancelled the process of adding a new packs to yours.
|
||||
cancel_del_sticker:
|
||||
other: You cancelled the process of removing a stickers from your pack.
|
||||
cancel_del_pack:
|
||||
other: You cancelled the process of removing a sticker packs from yours.
|
||||
cancel_reset:
|
||||
other: You cancelled the process of reseting your stickers pack.
|
||||
cancel_error:
|
||||
|
|
|
@ -15,4 +15,4 @@ error_empty_add_pack:
|
|||
error_unknown:
|
||||
other: |
|
||||
I do not know what to do with this sticker.
|
||||
Please run /{{.AddStickerCommand}}, /{{.AddPackCommand}} or /{{.DeleteCommand}} command first.
|
||||
Please run /{{.AddStickerCommand}}, /{{.AddPackCommand}}, /{{.DeleteStickerCommand}} or /{{.DeletePackCommand}} command first.
|
|
@ -7,8 +7,10 @@ reply_add_sticker:
|
|||
other: Send an existing stickers from any other packs to add it to yourself.
|
||||
reply_add_pack:
|
||||
other: Send an existing stickers from any other packs to add the entire packs to yourself.
|
||||
reply_del:
|
||||
reply_del_sticker:
|
||||
other: Send an existing stickers from your pack for removing it.
|
||||
reply_del_pack:
|
||||
other: Send an existing stickers from your pack to delete its entire set.
|
||||
reply_reset:
|
||||
other: |
|
||||
This operation will remove *all* stickers from your pack and *this can't be undone*.
|
||||
|
@ -19,7 +21,8 @@ reply_help:
|
|||
other: |
|
||||
/{{.AddStickerCommand}} - add a single sticker to your pack
|
||||
/{{.AddPackCommand}} - add a full other pack to your pack
|
||||
/{{.DeleteCommand}} - remove a single sticker from your pack
|
||||
/{{.DeleteStickerCommand}} - remove a single sticker from your pack
|
||||
/{{.DeletePackCommand}} - remove a sticker set from your pack
|
||||
/{{.ResetCommand}} - remove all stickers from your pack
|
||||
/{{.CancelCommand}} - cancel the current operation
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ success_add_sticker:
|
|||
other: The sticker was successfully added to your pack!
|
||||
success_add_pack:
|
||||
other: The sticker pack *{{.SetTitle}}* was successfully added to yours!
|
||||
success_del:
|
||||
success_del_sticker:
|
||||
other: The sticker was successfully removed from your pack!
|
||||
success_del_pack:
|
||||
other: The sticker pack *{{.SetTitle}}* was successfully removed from yours!
|
||||
success_reset:
|
||||
other: The contents of your pack are completely reset!..
|
|
@ -12,10 +12,12 @@ button_inline_nothing:
|
|||
button_share:
|
||||
other: Воспользоваться твоим набором!
|
||||
cancel_add_pack:
|
||||
other: Ты отменил процесс добавления нового набора в твой.
|
||||
other: Ты отменил процесс добавления новых наборов в твой.
|
||||
cancel_add_sticker:
|
||||
other: Ты отменил процесс добавления нового стикера в твой набор.
|
||||
cancel_del:
|
||||
other: Ты отменил процесс добавления новых стикеров в твой набор.
|
||||
cancel_del_pack:
|
||||
other: Ты отменил процесс удаления наборов из твоего набора.
|
||||
cancel_del_sticker:
|
||||
other: Ты отменил процесс удаления стикера из твоего набора.
|
||||
cancel_error:
|
||||
other: Нечего отменять.
|
||||
|
@ -38,7 +40,7 @@ error_reset_phrase:
|
|||
error_unknown:
|
||||
other: |-
|
||||
Я понятия не имею что делать с этим стикером.
|
||||
Пожалуйста, сначала примени /{{.AddStickerCommand}}, /{{.AddPackCommand}} или /{{.DeleteCommand}}.
|
||||
Пожалуйста, сначала примени /{{.AddStickerCommand}}, /{{.AddPackCommand}}, /{{.DeleteStickerCommand}} или /{{.DeletePackCommand}}.
|
||||
meta_key_phrase:
|
||||
other: Да, я абсолютно уверен.
|
||||
meta_reset_1:
|
||||
|
@ -52,13 +54,16 @@ reply_add_pack:
|
|||
свой.
|
||||
reply_add_sticker:
|
||||
other: Пришли стикеры из любых других наборов чтобы по-одному добавить их в свой.
|
||||
reply_del:
|
||||
reply_del_pack:
|
||||
other: Пришли стикер из своего набора чтобы удалить весь его набор.
|
||||
reply_del_sticker:
|
||||
other: Пришли стикер из своего набора чтобы удалить его.
|
||||
reply_help:
|
||||
other: |-
|
||||
/{{.AddStickerCommand}} - по-одному добавляет стикеры в твой набор
|
||||
/{{.AddPackCommand}} - добавляет сразу весь набор в твой
|
||||
/{{.DeleteCommand}} - по-одному удаляет стикер из твоего набора
|
||||
/{{.DeleteStickerCommand}} - по-одному удаляет стикер из твоего набора
|
||||
/{{.DeletePackCommand}} - удаляет набор стикеров из твоего набора
|
||||
/{{.ResetCommand}} - удаляет все стикеры из твоего набора
|
||||
/{{.CancelCommand}} - отменяет текущую операцию
|
||||
|
||||
|
@ -78,7 +83,9 @@ success_add_pack:
|
|||
other: Набор *{{.SetTitle}}* успешно добавлен в твой!
|
||||
success_add_sticker:
|
||||
other: Стикер успешно добавлен в твой набор!
|
||||
success_del:
|
||||
success_del_pack:
|
||||
other: Набор *{{.SetTitle}}* успешно удалён из твоего набора!
|
||||
success_del_sticker:
|
||||
other: Стикер успешно удалён из твоего набора!
|
||||
success_reset:
|
||||
other: Сброс твоего набора успешно произведён!..
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
cancel_add_sticker:
|
||||
other: Ты отменил процесс добавления нового стикера в твой набор.
|
||||
other: Ты отменил процесс добавления новых стикеров в твой набор.
|
||||
cancel_add_pack:
|
||||
other: Ты отменил процесс добавления нового набора в твой.
|
||||
cancel_del:
|
||||
other: Ты отменил процесс добавления новых наборов в твой.
|
||||
cancel_del_sticker:
|
||||
other: Ты отменил процесс удаления стикера из твоего набора.
|
||||
cancel_del_pack:
|
||||
other: Ты отменил процесс удаления наборов из твоего набора.
|
||||
cancel_reset:
|
||||
other: Ты отменил процесс сброса твоего набора.
|
||||
cancel_error:
|
||||
|
|
|
@ -15,4 +15,4 @@ error_empty_add_pack:
|
|||
error_unknown:
|
||||
other: |
|
||||
Я понятия не имею что делать с этим стикером.
|
||||
Пожалуйста, сначала примени /{{.AddStickerCommand}}, /{{.AddPackCommand}} или /{{.DeleteCommand}}.
|
||||
Пожалуйста, сначала примени /{{.AddStickerCommand}}, /{{.AddPackCommand}}, /{{.DeleteStickerCommand}} или /{{.DeletePackCommand}}.
|
|
@ -7,8 +7,10 @@ reply_add_sticker:
|
|||
other: Пришли стикеры из любых других наборов чтобы по-одному добавить их в свой.
|
||||
reply_add_pack:
|
||||
other: Пришли стикеры из любых других наборов чтобы целиком добавить их наборы в свой.
|
||||
reply_del:
|
||||
reply_del_sticker:
|
||||
other: Пришли стикер из своего набора чтобы удалить его.
|
||||
reply_del_pack:
|
||||
other: Пришли стикер из своего набора чтобы удалить весь его набор.
|
||||
reply_reset:
|
||||
other: |
|
||||
Эта операция удалит *все* стикеры из твоего набора и *это не может быть отменено*.
|
||||
|
@ -19,7 +21,8 @@ reply_help:
|
|||
other: |
|
||||
/{{.AddStickerCommand}} - по-одному добавляет стикеры в твой набор
|
||||
/{{.AddPackCommand}} - добавляет сразу весь набор в твой
|
||||
/{{.DeleteCommand}} - по-одному удаляет стикер из твоего набора
|
||||
/{{.DeleteStickerCommand}} - по-одному удаляет стикер из твоего набора
|
||||
/{{.DeletePackCommand}} - удаляет набор стикеров из твоего набора
|
||||
/{{.ResetCommand}} - удаляет все стикеры из твоего набора
|
||||
/{{.CancelCommand}} - отменяет текущую операцию
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ success_add_sticker:
|
|||
other: Стикер успешно добавлен в твой набор!
|
||||
success_add_pack:
|
||||
other: Набор *{{.SetTitle}}* успешно добавлен в твой!
|
||||
success_del:
|
||||
success_del_sticker:
|
||||
other: Стикер успешно удалён из твоего набора!
|
||||
success_del_pack:
|
||||
other: Набор *{{.SetTitle}}* успешно удалён из твоего набора!
|
||||
success_reset:
|
||||
other: Сброс твоего набора успешно произведён!..
|
|
@ -37,7 +37,9 @@ func inlineQuery(inline *tg.InlineQuery) {
|
|||
answer.CacheTime = 1
|
||||
answer.IsPersonal = true
|
||||
|
||||
stickers, packSize, err := dbGetUserStickers(inline.From.ID, offset, inline.Query)
|
||||
stickers, packSize, err := dbGetUserStickers(
|
||||
inline.From.ID, offset, inline.Query,
|
||||
)
|
||||
errCheck(err)
|
||||
|
||||
totalStickers := len(stickers)
|
||||
|
@ -46,8 +48,9 @@ func inlineQuery(inline *tg.InlineQuery) {
|
|||
if inline.Query != "" {
|
||||
// If search stickers by emoji return 0 results
|
||||
answer.SwitchPrivateMessageText = T(
|
||||
"button_inline_nothing",
|
||||
map[string]interface{}{"Query": inline.Query},
|
||||
"button_inline_nothing", map[string]interface{}{
|
||||
"Query": inline.Query,
|
||||
},
|
||||
)
|
||||
answer.SwitchPrivateMessageParameter = cmdAddSticker
|
||||
} else {
|
||||
|
@ -72,15 +75,11 @@ func inlineQuery(inline *tg.InlineQuery) {
|
|||
|
||||
var results = make([]interface{}, len(stickers))
|
||||
for i, sticker := range stickers {
|
||||
results[i] = tg.NewInlineQueryResultCachedSticker(
|
||||
sticker, sticker,
|
||||
)
|
||||
results[i] = tg.NewInlineQueryResultCachedSticker(sticker, sticker)
|
||||
}
|
||||
|
||||
answer.SwitchPrivateMessageText = T(
|
||||
"button_inline_add",
|
||||
packSize,
|
||||
map[string]interface{}{
|
||||
"button_inline_add", packSize, map[string]interface{}{
|
||||
"Count": packSize,
|
||||
},
|
||||
)
|
||||
|
|
|
@ -26,9 +26,10 @@ func messages(msg *tg.Message) {
|
|||
reply := tg.NewMessage(
|
||||
msg.Chat.ID,
|
||||
T("error_unknown", map[string]interface{}{
|
||||
"AddStickerCommand": cmdAddSticker,
|
||||
"AddPackCommand": cmdAddPack,
|
||||
"DeleteCommand": cmdDelete,
|
||||
"AddStickerCommand": cmdAddSticker,
|
||||
"AddPackCommand": cmdAddPack,
|
||||
"DeleteStickerCommand": cmdDeleteSticker,
|
||||
"DeletePackCommand": cmdDeletePack,
|
||||
}))
|
||||
reply.ParseMode = tg.ModeMarkdown
|
||||
|
||||
|
@ -55,7 +56,7 @@ func messages(msg *tg.Message) {
|
|||
|
||||
actionAdd(msg, true)
|
||||
return
|
||||
case stateDelete:
|
||||
case stateDeleteSticker:
|
||||
if msg.Sticker == nil {
|
||||
return
|
||||
}
|
||||
|
@ -63,7 +64,17 @@ func messages(msg *tg.Message) {
|
|||
log.D(msg.Sticker)
|
||||
log.D(msg.Sticker.Emoji)
|
||||
|
||||
actionDelete(msg)
|
||||
actionDelete(msg, false)
|
||||
return
|
||||
case stateDeletePack:
|
||||
if msg.Sticker == nil {
|
||||
return
|
||||
}
|
||||
|
||||
log.D(msg.Sticker)
|
||||
log.D(msg.Sticker.Emoji)
|
||||
|
||||
actionDelete(msg, true)
|
||||
return
|
||||
case stateReset:
|
||||
actionReset(msg)
|
||||
|
|
Loading…
Reference in New Issue