some changes
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
func RegisterAdmin(b *laniakea.Bot) {
|
||||
p := laniakea.NewPlugin("Admin")
|
||||
p.Command(uploadPhoto, "uploadPhoto")
|
||||
p.Command(emojiId, "emojiId")
|
||||
p.Command(test, "test")
|
||||
|
||||
p.Middleware(AdminMiddleware())
|
||||
@@ -31,6 +32,17 @@ func AdminMiddleware() *laniakea.PluginMiddleware {
|
||||
func test(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
|
||||
ctx.Answer("Ok")
|
||||
}
|
||||
func emojiId(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
|
||||
var id string
|
||||
for _, e := range ctx.Msg.Entities {
|
||||
if e.Type != laniakea.MessageEntityCustomEmoji {
|
||||
continue
|
||||
}
|
||||
id = e.CustomEmojiID
|
||||
break
|
||||
}
|
||||
ctx.Answer(id)
|
||||
}
|
||||
func uploadPhoto(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
|
||||
ctx.SendAction(laniakea.ChatActionUploadPhoto)
|
||||
photoId := ctx.Msg.Photo.Last().FileID
|
||||
@@ -40,6 +52,7 @@ func uploadPhoto(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
|
||||
return
|
||||
}
|
||||
u := laniakea.NewUploader(ctx.Api)
|
||||
defer u.Close()
|
||||
content, err := ctx.Bot.GetFileByLink(f.FilePath)
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user