mirror of
https://github.com/Luzifer/twitch-manager.git
synced 2024-12-21 04:11:17 +00:00
Add extra event type for follows
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
6e62d32832
commit
aa20136f63
3 changed files with 17 additions and 0 deletions
1
api.go
1
api.go
|
@ -21,6 +21,7 @@ const (
|
||||||
msgTypeAlert string = "alert"
|
msgTypeAlert string = "alert"
|
||||||
msgTypeBits string = "bits"
|
msgTypeBits string = "bits"
|
||||||
msgTypeCustom string = "custom"
|
msgTypeCustom string = "custom"
|
||||||
|
msgTypeFollow string = "follow"
|
||||||
msgTypeHost string = "host"
|
msgTypeHost string = "host"
|
||||||
msgTypeRaid string = "raid"
|
msgTypeRaid string = "raid"
|
||||||
msgTypeStore string = "store"
|
msgTypeStore string = "store"
|
||||||
|
|
7
demo.go
7
demo.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -24,6 +25,12 @@ func handleDemoAlert(w http.ResponseWriter, r *http.Request) {
|
||||||
"total_amount": 1337,
|
"total_amount": 1337,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case msgTypeFollow:
|
||||||
|
data = map[string]interface{}{
|
||||||
|
"from": demoIssuer,
|
||||||
|
"followed_at": time.Now(),
|
||||||
|
}
|
||||||
|
|
||||||
case msgTypeHost:
|
case msgTypeHost:
|
||||||
data = map[string]interface{}{
|
data = map[string]interface{}{
|
||||||
"from": demoIssuer,
|
"from": demoIssuer,
|
||||||
|
|
|
@ -90,6 +90,15 @@ func handleWebHookPush(w http.ResponseWriter, r *http.Request) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fields := map[string]interface{}{
|
||||||
|
"from": f.FromName,
|
||||||
|
"followed_at": f.FollowedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := subscriptions.SendAllSockets(msgTypeFollow, fields); err != nil {
|
||||||
|
log.WithError(err).Error("Unable to send update to all sockets")
|
||||||
|
}
|
||||||
|
|
||||||
logger.WithField("name", f.FromName).Info("New follower announced")
|
logger.WithField("name", f.FromName).Info("New follower announced")
|
||||||
store.WithModLock(func() error {
|
store.WithModLock(func() error {
|
||||||
store.Followers.Last = &f.FromName
|
store.Followers.Last = &f.FromName
|
||||||
|
|
Loading…
Reference in a new issue