Signed-off-by: Martyn Ranyard <m@rtyn.berlin>
This commit is contained in:
Martyn 2020-06-30 17:30:05 +02:00
parent 34403053ac
commit f574863601
2 changed files with 48 additions and 48 deletions

View File

@ -181,6 +181,7 @@ func (bb *KardBot) HandleChat() error {
case "PRIVMSG": case "PRIVMSG":
msg := matches[4] msg := matches[4]
rgb.GPrintf("[%s] %s: %s\n", TimeStamp(), userName, msg) rgb.GPrintf("[%s] %s: %s\n", TimeStamp(), userName, msg)
rgb.GPrintf("[%s] raw line: %s\n", TimeStamp(), line)
// parse commands from user message // parse commands from user message
cmdMatches := CmdRegex.FindStringSubmatch(msg) cmdMatches := CmdRegex.FindStringSubmatch(msg)

View File

@ -7,15 +7,15 @@ import (
"github.com/gorilla/handlers" "github.com/gorilla/handlers"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"encoding/json"
"fmt" "fmt"
"html/template" "html/template"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
"strings" "strings"
"time" "time"
"encoding/json"
"io/ioutil"
) )
//var store = sessions.NewCookieStore(os.Getenv("SESSION_KEY")) //var store = sessions.NewCookieStore(os.Getenv("SESSION_KEY"))
@ -205,7 +205,7 @@ func twitchHTTPClient(call string, bearer string) (string,error) {
func TwitchAdminHandler(response http.ResponseWriter, request *http.Request) { func TwitchAdminHandler(response http.ResponseWriter, request *http.Request) {
vars := mux.Vars(request) vars := mux.Vars(request)
if (vars["code"] != "") { if vars["code"] != "" {
response.Header().Add("Content-type", "text/plain") response.Header().Add("Content-type", "text/plain")
resp, err := http.PostForm( resp, err := http.PostForm(
"https://id.twitch.tv/oauth2/token", "https://id.twitch.tv/oauth2/token",
@ -270,11 +270,10 @@ func TwitchAdminHandler(response http.ResponseWriter, request *http.Request) {
url := "https://" + ircBot.Config.ExternalUrl + "/admin/" + user.Login + "/" + magicCode url := "https://" + ircBot.Config.ExternalUrl + "/admin/" + user.Login + "/" + magicCode
http.Redirect(response, request, url, http.StatusFound) http.Redirect(response, request, url, http.StatusFound)
} else { } else {
fmt.Fprintf(response, "I'm not okay jack! %v \n", vars) fmt.Fprintf(response, "I'm not okay jack! %v \n", vars)
for key, val := range(vars) { for key, val := range vars {
fmt.Fprint(response, "%s = %s\n", key, val) fmt.Fprint(response, "%s = %s\n", key, val)
} }
} }
@ -288,7 +287,7 @@ func TwitchBackendHandler(response http.ResponseWriter, request *http.Request){
// fmt.Fprint(response, "%s = %s\n", key, val) // fmt.Fprint(response, "%s = %s\n", key, val)
// } // }
if (vars["code"] != "") { if vars["code"] != "" {
// https://id.twitch.tv/oauth2/token // https://id.twitch.tv/oauth2/token
// ?client_id=<your client ID> // ?client_id=<your client ID>
// &client_secret=<your client secret> // &client_secret=<your client secret>