many fixes
This commit is contained in:
@@ -2,6 +2,7 @@ package plugins
|
||||
|
||||
import (
|
||||
"kurumibot/database/psql"
|
||||
"log"
|
||||
|
||||
"git.nix13.pw/scuroneko/laniakea"
|
||||
)
|
||||
@@ -12,17 +13,36 @@ func RegisterAdmin(b *laniakea.Bot) {
|
||||
b.AddPlugins(p.Build())
|
||||
}
|
||||
|
||||
func uploadPhoto(msgContext *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
func uploadPhoto(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
rep := psql.NewUserRepository(db)
|
||||
user, err := rep.GetOrCreate(msgContext.FromID, msgContext.Msg.From.FirstName)
|
||||
user, err := rep.GetOrCreate(ctx.FromID, ctx.Msg.From.FirstName)
|
||||
if err != nil {
|
||||
msgContext.Error(err)
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
if !user.Group.IsAdmin {
|
||||
return
|
||||
}
|
||||
|
||||
photoId := msgContext.Msg.Photo[0].FileID
|
||||
msgContext.AnswerPhoto(photoId, photoId)
|
||||
// https://core.telegram.org/bots/api#getfile
|
||||
log.Println(ctx.Msg.Photo[0])
|
||||
photoId := ctx.Msg.Photo[0].FileID
|
||||
f, err := ctx.Bot.GetFile(&laniakea.GetFileP{FileId: photoId})
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
u := laniakea.NewUploader(ctx.Bot)
|
||||
content, err := ctx.Bot.GetFileByLink(f.FilePath)
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
err = u.UploadPhoto(ctx.Msg.Chat.ID, content)
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
log.Println(*f)
|
||||
ctx.AnswerPhoto(photoId, laniakea.EscapeMarkdown(photoId))
|
||||
}
|
||||
|
||||
@@ -119,6 +119,7 @@ func rpInfo(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
|
||||
if ctx.CallbackMsgId > 0 {
|
||||
ctx.EditCallback(strings.Join(out, "\n"), kb)
|
||||
ctx.AnswerCbQuery()
|
||||
} else {
|
||||
ctx.Keyboard(strings.Join(out, "\n"), kb)
|
||||
}
|
||||
@@ -161,6 +162,7 @@ func rpWaifuList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
kb.AddLine()
|
||||
kb.AddCallbackButton("На главную", "rp.info")
|
||||
ctx.EditCallback(strings.Join(out, "\n"), kb)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
func rpWaifuSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
waifuId, err := strconv.Atoi(ctx.Args[0])
|
||||
@@ -183,6 +185,7 @@ func rpWaifuSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
|
||||
kb := laniakea.NewInlineKeyboard(1).AddCallbackButton("На главную", "rp.info")
|
||||
ctx.EditCallbackf("Была выбрана вайфу %s", kb, waifu.Name)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
|
||||
func rpPresetsList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
@@ -204,6 +207,7 @@ func rpPresetsList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
kb.AddLine()
|
||||
kb.AddCallbackButton("Назад", "rp.info")
|
||||
ctx.EditCallback(strings.Join(out, "\n"), kb)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
func rpPresetSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
if len(ctx.Args) == 0 || ctx.Args[0] == "" {
|
||||
@@ -228,6 +232,7 @@ func rpPresetSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
|
||||
kb := laniakea.NewInlineKeyboard(1).AddCallbackButton("На главную", "rp.info")
|
||||
ctx.EditCallbackf("Был выбран пресет %s", kb, preset.Name)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
|
||||
func rpModelList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
@@ -247,6 +252,7 @@ func rpModelList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
kb.AddLine()
|
||||
kb.AddCallbackButton("Назад", "rp.info")
|
||||
ctx.EditCallback(strings.Join(out, "\n"), kb)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
func rpModelSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
rep := psql.NewRPRepository(db)
|
||||
@@ -268,6 +274,7 @@ func rpModelSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
}
|
||||
kb := laniakea.NewInlineKeyboard(1).AddCallbackButton("На главную", "rp.info")
|
||||
ctx.EditCallback(fmt.Sprintf("Была установлена модель %s", model.Name), kb)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
|
||||
func rpScenarioList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
@@ -284,6 +291,7 @@ func rpScenarioList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
}
|
||||
kb.AddCallbackButton("На главную", "rp.info")
|
||||
ctx.EditCallback("Список сценариев\n"+strings.Join(out, "\n"), kb)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
func rpSettingList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
rep := psql.NewRPRepository(db)
|
||||
@@ -300,6 +308,7 @@ func rpSettingList(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
kb := laniakea.NewInlineKeyboard(1)
|
||||
kb.AddCallbackButton("На главную", "rp.info")
|
||||
ctx.EditCallback(strings.Join(out, "\n"), kb)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
|
||||
func chatStat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
@@ -353,6 +362,7 @@ func chatStat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
out = append(out, fmt.Sprintf("*Выбранный сеттинг*: %s (ID: %d)", setting.Name, setting.ID))
|
||||
}
|
||||
ctx.EditCallback(strings.Join(out, "\n"), kb)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
|
||||
func newChatStage1(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
@@ -376,6 +386,7 @@ func newChatStage1(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
kb.AddLine()
|
||||
kb.AddCallbackButton("Назад", "rp.info")
|
||||
ctx.EditCallback(strings.Join(out, "\n"), kb)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
func newChatStage2(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
// Выбор сценария
|
||||
@@ -433,6 +444,13 @@ func newChatStage2(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
kb.AddLine()
|
||||
kb.AddCallbackButton("Назад", "rp.new_chat_s1")
|
||||
ctx.EditCallback(strings.Join(out, "\n"), kb)
|
||||
|
||||
//setting, err := rep.GetSetting(settingId)
|
||||
//if err != nil {
|
||||
// ctx.Error(err)
|
||||
//}
|
||||
//ctx.AnswerCbQueryText(fmt.Sprintf("Ты выбрал сеттинг %s", setting.Name))
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
func newChat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
redisRpRep := red.NewRPRepository(db)
|
||||
@@ -517,6 +535,7 @@ func newChat(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
kb := laniakea.NewInlineKeyboard(2)
|
||||
kb.AddCallbackButton("На главную", "rp.info").AddCallbackButton("Закрыть", "general.close")
|
||||
ctx.EditCallback("Был создан новый чат. Для общения используй `/г промпт`.", kb)
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
|
||||
func rpUserPromptSet(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
@@ -691,7 +710,7 @@ func generate(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
}
|
||||
|
||||
func regenerateResponse(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
m := ctx.Answer("Запущена повторная генерация…")
|
||||
ctx.AnswerCbQueryText("Запущена повторная генерация…")
|
||||
|
||||
redRep := red.NewRPRepository(db)
|
||||
waifuId := redRep.GetSelectedWaifu(ctx.FromID)
|
||||
@@ -752,19 +771,17 @@ func regenerateResponse(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext)
|
||||
return
|
||||
}
|
||||
|
||||
m.Delete()
|
||||
kb := laniakea.NewInlineKeyboard(1)
|
||||
kb.AddCallbackButton("Перегенерировать", "rp.regenerate", count)
|
||||
kb.AddCallbackButton("🔄Перегенерировать", "rp.regenerate", count)
|
||||
ctx.EditCallback(laniakea.EscapeMarkdown(res.Choices[0].Message.Content), kb)
|
||||
}
|
||||
|
||||
func compress(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
m := ctx.EditCallback("Запущено сжатие чата…", nil)
|
||||
ctx.AnswerCbQueryText("Запущено сжатие чата…")
|
||||
_compress(ctx, db)
|
||||
kb := laniakea.NewInlineKeyboard(1)
|
||||
kb = kb.AddCallbackButton("Назад", "rp.chat_stat")
|
||||
kb = kb.AddCallbackButton("На главную", "rp.info")
|
||||
m.Edit("Сжатие завершено")
|
||||
}
|
||||
|
||||
func _compress(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"kurumibot/database/psql"
|
||||
"kurumibot/utils"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -184,10 +185,12 @@ func waifuInfo(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
kb.AddCallbackButton("Мои вайфу", "waifu.my")
|
||||
if len(waifu.Image) > 0 {
|
||||
ctx.CallbackDelete()
|
||||
log.Println(waifu.Image)
|
||||
ctx.AnswerPhotoKeyboard(waifu.Image, strings.Join(out, "\n"), kb)
|
||||
} else {
|
||||
ctx.EditCallback(strings.Join(out, "\n"), kb)
|
||||
}
|
||||
ctx.AnswerCbQuery()
|
||||
}
|
||||
|
||||
func waifuSearch(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
|
||||
Reference in New Issue
Block a user