mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
idk how that got in here
This commit is contained in:
parent
ed90275045
commit
ee25eeede4
1 changed files with 0 additions and 48 deletions
48
\
48
\
|
@ -1,48 +0,0 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
bot "github.com/lyx0/nourybot-go/bot"
|
||||
)
|
||||
|
||||
// https://api.ivr.fi
|
||||
type followageApiResponse struct {
|
||||
User string `json:"user"`
|
||||
UserID string `json:"userid"`
|
||||
Channel string `json:"channel"`
|
||||
ChannelId string `json:"channelid"`
|
||||
FollowedAt string `json:"followedAt"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
func Followage(streamer string, username string) (string, error) {
|
||||
resp, err := http.Get(fmt.Sprintf("https://api.ivr.fi/twitch/subage/%s/%s", username, streamer))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
var responseObject followageApiResponse
|
||||
json.Unmarshal(body, &responseObject)
|
||||
|
||||
// User or channel was not found
|
||||
if responseObject.Error != "" {
|
||||
return fmt.Sprintf(responseObject.Error+" FeelsBadMan")), nil
|
||||
} else if responseObject.FollowedAt == "" {
|
||||
bot.SendTwitchMessage(channel, fmt.Sprintf(username+" is not following "+streamer), nil
|
||||
} else {
|
||||
d := responseObject.FollowedAt[:10]
|
||||
return fmt.Sprintf(username+" has been following "+streamer+" since "+d+"."), nil
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue