diff --git a/pkg/bot/handlers.go b/pkg/bot/handlers.go index 231a233..3d506f2 100644 --- a/pkg/bot/handlers.go +++ b/pkg/bot/handlers.go @@ -30,6 +30,7 @@ func (b *Type) loadDiscordHandlers() { // Admin commands // XXX: Promote b.dg.Router.Route("reload", "Reload the bot's data and configs", b.handleReload) + b.dg.Router.Route("pmsg", "", b.handleMessageAsBot) // Moderator commands // XXX: Remove b.dg.Router.Route("auser", "Associates an AltVR user to a discord user", b.handleAssociateUser) @@ -622,6 +623,16 @@ func (b *Type) handleReload(ds *discordgo.Session, dm *discordgo.Message, ctx *m }) } +func (b *Type) handleMessageAsBot(ds *discordgo.Session, dm *discordgo.Message, ctx *mux.Context) { + //fmt.Printf("dm:\t%+v\nctv:\t%+v\n", dm, ctx) + if !b.checkUserRole(dm.Author.ID, RoleAdmin) { + b.replyPermissionDenied(ds, dm, ctx) + return + } + //uu, _ := b.getUserByDiscordID(dm.Author.ID) + b.dg.Session.ChannelMessageSend(b.DGcID, strings.TrimSpace(strings.Replace(ctx.Content, "pmsg", "", 1))) +} + /* ** Utilities */