add new route
continuous-integration/drone/push Build is passing

This commit is contained in:
Jay
2021-06-21 22:18:13 +08:00
parent 08e0607a88
commit c07a1a8c9f
4 changed files with 27 additions and 12 deletions
+24
View File
@@ -8,6 +8,7 @@ import (
twitchapi "git.trj.tw/golang/mtfosbot/module/apis/twitch"
"git.trj.tw/golang/mtfosbot/module/config"
"git.trj.tw/golang/mtfosbot/module/context"
twitchirc "git.trj.tw/golang/mtfosbot/module/twitch-irc"
"github.com/gin-gonic/contrib/sessions"
)
@@ -92,3 +93,26 @@ func OAuthProc(c *context.Context) {
session.Save()
c.Redirect(301, goURL)
}
func SendToChannel(c *context.Context) {
key := c.GetHeader("x-private-key")
if key == "" || key != "mtfos" {
c.Forbidden(nil)
return
}
ch, ok := c.GetQuery("channel")
if !ok || ch == "" {
c.DataFormat(nil)
return
}
msg, ok := c.GetQuery("message")
if !ok || msg == "" {
c.DataFormat(nil)
return
}
twitchirc.SendMessage(ch, msg)
c.Success(nil)
}