29 lines
598 B
Go
29 lines
598 B
Go
package plugins
|
|
|
|
import (
|
|
"kurumibot/database/psql"
|
|
|
|
"kurumibot/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)
|
|
}
|