mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
refactor commands for the new api call
This commit is contained in:
parent
3432c112ac
commit
dd788efb70
5 changed files with 23 additions and 53 deletions
|
@ -2,25 +2,19 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/gempir/go-twitch-irc/v2"
|
||||
"github.com/lyx0/nourybot/pkg/api/aiden"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func BotStatus(channel string, userName string, client *twitch.Client) {
|
||||
resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/api/v1/twitch/botStatus/%s?includeLimits=1", userName))
|
||||
func BotStatus(channel string, name string, client *twitch.Client) {
|
||||
resp, err := aiden.ApiCall(fmt.Sprintf("api/v1/twitch/botStatus/%s?includeLimits=1", name))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
client.Say(channel, "Something went wrong FeelsBadMan")
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
client.Say(channel, resp)
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
client.Say(channel, string(body))
|
||||
}
|
||||
|
|
|
@ -2,25 +2,18 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/gempir/go-twitch-irc/v2"
|
||||
"github.com/lyx0/nourybot/pkg/api/aiden"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func BttvEmotes(channel string, client *twitch.Client) {
|
||||
resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/api/v1/emotes/%s/bttv", channel))
|
||||
resp, err := aiden.ApiCall(fmt.Sprintf("api/v1/emotes/%s/bttv", channel))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
client.Say(channel, "Something went wrong FeelsBadMan")
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
client.Say(channel, string(body))
|
||||
client.Say(channel, string(resp))
|
||||
}
|
||||
|
|
|
@ -1,28 +1,17 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/gempir/go-twitch-irc/v2"
|
||||
"github.com/lyx0/nourybot/pkg/api/aiden"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func EightBall(message twitch.PrivateMessage, client *twitch.Client) {
|
||||
resp, err := http.Get("https://customapi.aidenwallis.co.uk/api/v1/misc/8ball")
|
||||
func EightBall(channel string, client *twitch.Client) {
|
||||
resp, err := aiden.ApiCall("api/v1/misc/8ball")
|
||||
if err != nil {
|
||||
client.Say(message.Channel, "Something went wrong FeelsBadMan")
|
||||
log.Error(err)
|
||||
client.Say(channel, "Something went wrong FeelsBadMan")
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
client.Say(message.Channel, "Something went wrong FeelsBadMan")
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
client.Say(message.Channel, string(body))
|
||||
|
||||
client.Say(channel, string(resp))
|
||||
}
|
||||
|
|
|
@ -2,25 +2,19 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/gempir/go-twitch-irc/v2"
|
||||
"github.com/lyx0/nourybot/pkg/api/aiden"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func FfzEmotes(channel string, client *twitch.Client) {
|
||||
resp, err := http.Get(fmt.Sprintf("https://customapi.aidenwallis.co.uk/api/v1/emotes/%s/ffz", channel))
|
||||
|
||||
resp, err := aiden.ApiCall(fmt.Sprintf("api/v1/emotes/%s/ffz", channel))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
client.Say(channel, "Something went wrong FeelsBadMan")
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
client.Say(channel, string(body))
|
||||
client.Say(channel, string(resp))
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ func HandleCommand(message twitch.PrivateMessage, twitchClient *twitch.Client, u
|
|||
commands.Echo(message.Channel, message.Message[7:len(message.Message)], twitchClient)
|
||||
return
|
||||
case "8ball":
|
||||
commands.EightBall(message, twitchClient)
|
||||
commands.EightBall(message.Channel, twitchClient)
|
||||
return
|
||||
case "ffzemotes":
|
||||
commands.FfzEmotes(message.Channel, twitchClient)
|
||||
|
|
Loading…
Reference in a new issue