Files
YaeMikoBot/plugins/admin.go

29 lines
611 B
Go

package plugins
import (
"kurumibot/database/psql"
"git.nix13.pw/scuroneko/laniakea"
)
func RegisterAdmin(b *laniakea.Bot) {
p := laniakea.NewPlugin("Admin")
p = p.Command(uploadPhoto, "uploadPhoto")
b.AddPlugins(p.Build())
}
func uploadPhoto(msgContext *laniakea.MsgContext, db *laniakea.DatabaseContext) {
rep := psql.NewUserRepository(db)
user, err := rep.GetOrCreate(msgContext.FromID, msgContext.Msg.From.FirstName)
if err != nil {
msgContext.Error(err)
return
}
if !user.Group.IsAdmin {
return
}
photoId := msgContext.Msg.Photo[0].FileID
msgContext.AnswerPhoto(photoId, photoId)
}