initial commit
This commit is contained in:
28
plugins/admin.go
Normal file
28
plugins/admin.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"kurumibot/database"
|
||||
|
||||
"kurumibot/laniakea"
|
||||
)
|
||||
|
||||
func RegisterAdmin(b *laniakea.Bot) {
|
||||
p := laniakea.NewPlugin("Admin")
|
||||
p = p.Command(uploadPhoto, "uploadPhoto")
|
||||
|
||||
b.AddPlugins(p.Build())
|
||||
}
|
||||
|
||||
func uploadPhoto(ctx *laniakea.MsgContext) {
|
||||
user, err := database.GetOrCreateUser(ctx.FromID, ctx.Msg.From.FirstName)
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
if !user.Group.IsAdmin {
|
||||
return
|
||||
}
|
||||
|
||||
photoId := ctx.Msg.Photo[0].FileID
|
||||
ctx.AnswerPhoto(photoId, photoId)
|
||||
}
|
||||
Reference in New Issue
Block a user