Compare commits
No commits in common. "master" and "feature/bot_split" have entirely different histories.
master
...
feature/bo
2
Makefile
2
Makefile
@ -2,7 +2,7 @@
|
||||
.PHONY: clean build
|
||||
|
||||
build:
|
||||
GO111MODULE=off go get -u github.com/go-bindata/go-bindata/...
|
||||
GO111MODULE=off go get -u github.com/otakukaze/go-bindata/...
|
||||
go-bindata -pkg schema -ignore .git -o module/schema/static.go schema/
|
||||
GOOS=linux go build -o mtfosbot -ldflags "-s -w" .
|
||||
|
||||
|
2
go.mod
2
go.mod
@ -1,7 +1,5 @@
|
||||
module git.trj.tw/golang/mtfosbot
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/DeanThompson/ginpprof v0.0.0-20190408063150-3be636683586
|
||||
github.com/PuerkitoBio/goquery v1.5.0
|
||||
|
7
go.sum
7
go.sum
@ -21,9 +21,11 @@ github.com/gin-gonic/gin v1.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ=
|
||||
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
|
||||
github.com/go-irc/irc v2.1.0+incompatible h1:pg7pMVq5OYQbqTxceByD/EN8VIsba7DtKn49rsCnG8Y=
|
||||
github.com/go-irc/irc v2.1.0+incompatible/go.mod h1:jJILTRy8s/qOvusiKifAEfhQMVwft1ZwQaVJnnzmyX4=
|
||||
github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@ -47,14 +49,17 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983 h1:wL11wNW7dhKIcRCHSm4sHKPWz0tt4mwBsVodG7+Xyqg=
|
||||
github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4=
|
||||
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
|
||||
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
@ -82,6 +87,7 @@ golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f h1:R423Cnkcp5JABoeemiGEPl
|
||||
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a h1:gOpx8G595UYyvj8UK4+OFyY4rx037g3fmfhe5SasG3U=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
@ -96,6 +102,7 @@ golang.org/x/sys v0.0.0-20190528012530-adf421d2caf4/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
google.golang.org/appengine v1.6.0 h1:Tfd7cKwKbFRsI8RMAD3oqqw7JPFRrvFlOsfbgVkjOOw=
|
||||
google.golang.org/appengine v1.6.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
twitchirc "git.trj.tw/golang/mtfosbot/module/twitch-irc"
|
||||
"git.trj.tw/golang/mtfosbot/module/twitch-irc"
|
||||
|
||||
"git.trj.tw/golang/mtfosbot/model"
|
||||
)
|
||||
@ -50,7 +50,7 @@ func getOpayData(ch *model.TwitchChannel) {
|
||||
return
|
||||
}
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/80.0")
|
||||
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
|
@ -2,14 +2,12 @@ package linemsg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
lineobj "git.trj.tw/golang/mtfosbot/module/line-message/line-object"
|
||||
)
|
||||
|
||||
// MessageEvent -
|
||||
func MessageEvent(botid string, e *lineobj.EventObject) {
|
||||
log.Println("proc message evt :: ", botid, *e)
|
||||
if len(botid) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import (
|
||||
)
|
||||
|
||||
func messageType(botid string, e *lineobj.EventObject) {
|
||||
log.Println("proc msg type text :: ", botid)
|
||||
msg := e.Message
|
||||
mtype, ok := msg["type"]
|
||||
if !ok {
|
||||
|
@ -1,13 +1,12 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.trj.tw/golang/mtfosbot/model"
|
||||
"git.trj.tw/golang/mtfosbot/module/apis/twitch"
|
||||
"git.trj.tw/golang/mtfosbot/module/context"
|
||||
twitchirc "git.trj.tw/golang/mtfosbot/module/twitch-irc"
|
||||
"git.trj.tw/golang/mtfosbot/module/twitch-irc"
|
||||
"git.trj.tw/golang/mtfosbot/module/utils"
|
||||
"github.com/gin-gonic/contrib/sessions"
|
||||
)
|
||||
@ -100,12 +99,7 @@ func hasChannel(id string, c *context.Context) *model.TwitchChannel {
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Println("channels :: ", chs)
|
||||
|
||||
for _, v := range chs {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
if v.ID == id {
|
||||
return v
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
"git.trj.tw/golang/mtfosbot/model"
|
||||
"git.trj.tw/golang/mtfosbot/module/context"
|
||||
@ -101,7 +100,6 @@ func GetLineMessage(c *context.Context) {
|
||||
|
||||
if len(events.Events) > 0 {
|
||||
for _, v := range events.Events {
|
||||
log.Println("get line message :: ", v)
|
||||
go linemsg.MessageEvent(botid, v)
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,6 @@ func SetRoutes(r *gin.Engine) {
|
||||
{
|
||||
twitchApis.GET("/login", context.PatchCtx(twitch.OAuthLogin))
|
||||
twitchApis.GET("/oauth", context.PatchCtx(twitch.OAuthProc))
|
||||
twitchApis.POST("/send", context.PatchCtx(twitch.SendToChannel))
|
||||
}
|
||||
|
||||
// set pprof router
|
||||
|
@ -8,7 +8,6 @@ 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"
|
||||
)
|
||||
|
||||
@ -93,26 +92,3 @@ 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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user