start irc module

This commit is contained in:
Jay
2018-09-12 18:07:49 +08:00
parent f29f982f7f
commit f224c77bac
19 changed files with 1296 additions and 0 deletions
+1
View File
@@ -11,5 +11,6 @@ func SetBackground() {
c = cron.New()
c.AddFunc("0 * * * * *", readFacebookPage)
c.AddFunc("*/20 * * * * *", getStreamStatus)
c.AddFunc("*/5 * * * * *", checkOpay)
c.Start()
}
+21
View File
@@ -0,0 +1,21 @@
package background
import (
"git.trj.tw/golang/mtfosbot/model"
)
func checkOpay() {
channels, err := model.GetAllTwitchChannel()
if err != nil {
return
}
for _, v := range channels {
if len(v.OpayID) > 0 && v.Join {
go getOpayData(v)
}
}
}
func getOpayData(ch *model.TwitchChannel) {
}
+33
View File
@@ -0,0 +1,33 @@
package twitchirc
import (
"fmt"
"net"
"gopkg.in/irc.v2"
"git.trj.tw/golang/mtfosbot/module/config"
)
var client *irc.Client
// InitIRC -
func InitIRC() (err error) {
conf := config.GetConf()
conn, err := net.Dial("tcp", conf.Twitch.ChatHost)
if err != nil {
return
}
config := irc.ClientConfig{
Handler: irc.HandlerFunc(ircHandle),
}
client = irc.NewClient(conn, config)
err = client.Run()
return
}
func ircHandle(c *irc.Client, m *irc.Message) {
fmt.Println(m.String())
}