summary refs log tree commit diff
path: root/main.go
blob: f0f40a24029b54ac52499677eb255606dd13834a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/nicklaw5/helix/v2"

	"golang.org/x/oauth2/clientcredentials"
)

const DEBUG bool = false
const USERNAME string = "venomade98" // TODO: Make configurable

var (
	dataDir = fmt.Sprintf("%s/.local/share/lifesigns", os.Getenv("HOME"))
	clientSecrets = Secrets(fmt.Sprintf("%s/secrets", dataDir))
	// Fix Hardcodes
	oauth2Config *clientcredentials.Config
)

func main() {
	userTokens := Auth(fmt.Sprintf("%s/auth", dataDir));
	
	client, err := helix.NewClient(&helix.Options{
		ClientID: clientSecrets.ClientID,
		ClientSecret: clientSecrets.ClientSecret,
		AppAccessToken: GetAppToken(),
		UserAccessToken: userTokens.AccessToken,
		RefreshToken: userTokens.RefreshToken,
	})
	if err != nil {
		panic(err)
	}

	resp, err := client.GetFollowedStream(&helix.FollowedStreamsParams{
		UserID: GetUserID(client),
	})

	var output strings.Builder
	
	for _, channel := range resp.Data.Streams {
		output.WriteString(fmt.Sprintf("%s ", channel.UserName))
	}

	fmt.Println(fmt.Sprintf("  %s", strings.TrimSpace(output.String())))
}

func GetUserID(client *helix.Client) string{
	resp, err := client.GetUsers(&helix.UsersParams {
		Logins: []string{"venomade98"},
	})
		
	if err != nil {
		panic(err)
	}

	if DEBUG {
		fmt.Printf("Status code: %d\n", resp.StatusCode)
		fmt.Printf("Error: %s\n", resp.ErrorMessage)
		fmt.Printf("Rate limit: %d\n", resp.GetRateLimit())
		fmt.Printf("Rate limit remaining: %d\n", resp.GetRateLimitRemaining())
		fmt.Printf("Rate limit reset: %d\n\n", resp.GetRateLimitReset())
	}

	var uid string;
	
	for _, user := range resp.Data.Users {
		uid = string(user.ID)
	}

	return uid
}