many changes
This commit is contained in:
@@ -2,7 +2,7 @@ package plugins
|
||||
|
||||
import (
|
||||
"kurumibot/database/psql"
|
||||
"log"
|
||||
"path/filepath"
|
||||
|
||||
"git.nix13.pw/scuroneko/laniakea"
|
||||
)
|
||||
@@ -24,9 +24,7 @@ func uploadPhoto(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://core.telegram.org/bots/api#getfile
|
||||
log.Println(ctx.Msg.Photo[0])
|
||||
photoId := ctx.Msg.Photo[0].FileID
|
||||
photoId := ctx.Msg.Photo.Last().FileID
|
||||
f, err := ctx.Bot.GetFile(&laniakea.GetFileP{FileId: photoId})
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
@@ -38,11 +36,14 @@ func uploadPhoto(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
err = u.UploadPhoto(ctx.Msg.Chat.ID, content)
|
||||
filename := filepath.Base(f.FilePath)
|
||||
msg, err := u.UploadPhoto(laniakea.NewUploaderFile(filename, content), laniakea.SendPhotoBaseP{
|
||||
ChatID: ctx.Msg.Chat.ID,
|
||||
Caption: ctx.Msg.Caption,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
log.Println(*f)
|
||||
ctx.AnswerPhoto(photoId, laniakea.EscapeMarkdown(photoId))
|
||||
ctx.Answer(laniakea.EscapeMarkdown(msg.Photo.Last().FileID))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user