updates
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"git.nix13.pw/scuroneko/laniakea"
|
||||
"git.nix13.pw/scuroneko/laniakea/tgapi"
|
||||
"git.nix13.pw/scuroneko/laniakea/utils"
|
||||
)
|
||||
|
||||
func RegisterAdmin(b *laniakea.Bot) {
|
||||
@@ -13,7 +15,7 @@ func RegisterAdmin(b *laniakea.Bot) {
|
||||
p.Command(emojiId, "emojiId")
|
||||
p.Command(test, "test")
|
||||
|
||||
p.Middleware(AdminMiddleware())
|
||||
p.AddMiddleware(AdminMiddleware())
|
||||
b.AddPlugins(p.Build())
|
||||
}
|
||||
|
||||
@@ -35,7 +37,7 @@ func test(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
|
||||
func emojiId(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
|
||||
var id string
|
||||
for _, e := range ctx.Msg.Entities {
|
||||
if e.Type != laniakea.MessageEntityCustomEmoji {
|
||||
if e.Type != tgapi.MessageEntityCustomEmoji {
|
||||
continue
|
||||
}
|
||||
id = e.CustomEmojiID
|
||||
@@ -44,14 +46,14 @@ func emojiId(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
|
||||
ctx.Answer(id)
|
||||
}
|
||||
func uploadPhoto(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
|
||||
ctx.SendAction(laniakea.ChatActionUploadPhoto)
|
||||
ctx.SendAction(tgapi.ChatActionUploadPhoto)
|
||||
photoId := ctx.Msg.Photo.Last().FileID
|
||||
f, err := ctx.Api.GetFile(&laniakea.GetFileP{FileId: photoId})
|
||||
f, err := ctx.Api.GetFile(tgapi.GetFileP{FileId: photoId})
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
u := laniakea.NewUploader(ctx.Api)
|
||||
u := tgapi.NewUploader(ctx.Api)
|
||||
defer u.Close()
|
||||
content, err := ctx.Bot.GetFileByLink(f.FilePath)
|
||||
if err != nil {
|
||||
@@ -59,13 +61,13 @@ func uploadPhoto(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
|
||||
return
|
||||
}
|
||||
filename := filepath.Base(f.FilePath)
|
||||
msg, err := u.UploadPhoto(laniakea.NewUploaderFile(filename, content), laniakea.SendPhotoBaseP{
|
||||
msg, err := u.UploadPhoto(tgapi.UploadPhotoP{
|
||||
ChatID: ctx.Msg.Chat.ID,
|
||||
Caption: ctx.Msg.Caption,
|
||||
})
|
||||
}, tgapi.NewUploaderFile(filename, content))
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
ctx.Answer(laniakea.EscapeMarkdown(msg.Photo.Last().FileID))
|
||||
ctx.Answer(utils.EscapeMarkdown(msg.Photo.Last().FileID))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user