@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user