@@ -22,11 +22,15 @@ import (
22
22
graphql "github.com/hasura/go-graphql-client"
23
23
)
24
24
25
+ type StatusPair struct {
26
+ StatusText string `json:"statusText"`
27
+ Emoji string `json:"emoji"`
28
+ }
29
+
25
30
type AppStatus struct {
26
- Names []string `json:"names"`
27
- StatusText string `json:"statusText"`
28
- Priority int32 `json:"priority"`
29
- Emoji string `json:"emoji"`
31
+ Names []string `json:"names"`
32
+ Vals []StatusPair `json:"vals"`
33
+ Priority int32 `json:"priority"`
30
34
}
31
35
32
36
type AppList struct {
@@ -37,11 +41,10 @@ type AppList struct {
37
41
}
38
42
39
43
type ChangeUserStatusInput struct {
40
- ClientMutationId string `json:"clientMutationId"`
41
- // The emoji to represent your status. Can either be a native Unicode emoji or an emoji name with colons, e.g., :grinning:.
42
- Emoji string `json:"emoji"`
43
- ExpiresAt time.Time `json:"expiresAt"`
44
- Message string `json:"message"`
44
+ ClientMutationId string `json:"clientMutationId"`
45
+ Emoji string `json:"emoji"`
46
+ ExpiresAt time.Time `json:"expiresAt"`
47
+ Message string `json:"message"`
45
48
}
46
49
47
50
type authedTransport struct {
@@ -197,9 +200,10 @@ func getCurrentApp(activeApps map[string]bool, appList []AppStatus, config AppLi
197
200
return config .FallbackStatus , config .FallbackEmoji
198
201
}
199
202
200
- aRandomApp := allListedRunningApps [rand .Intn (len (allListedRunningApps ))]
203
+ appsVals := allListedRunningApps [rand .Intn (len (allListedRunningApps ))].Vals
204
+ aRandomAppStatus := appsVals [rand .Intn (len (appsVals ))]
201
205
202
- return aRandomApp .StatusText , aRandomApp .Emoji
206
+ return aRandomAppStatus .StatusText , aRandomAppStatus .Emoji
203
207
}
204
208
205
209
func manageStatus () {
@@ -224,10 +228,21 @@ func resetOnClose() {
224
228
}
225
229
226
230
func initClient () {
227
- authToken := os .Getenv ("GITHUB_PAT" )
231
+ authTokenEnv := os .Getenv ("GITHUB_PAT" )
232
+
233
+ var authTokenCmd = ""
234
+ if len (os .Args ) > 1 {
235
+ authTokenCmd = os .Args [1 ]
236
+ }
237
+
238
+ if len (authTokenEnv ) < 1 && len (authTokenCmd ) < 1 {
239
+ log .Fatal ("GITHUB_PAT env variable not set & no token passed to app.\n Usage: status <token>" )
240
+ }
241
+
242
+ var authToken = authTokenEnv
228
243
229
- if authToken == "" {
230
- log . Fatal ( "GITHUB_PAT not set" )
244
+ if len ( authTokenCmd ) > 0 {
245
+ authToken = authTokenCmd
231
246
}
232
247
233
248
httpClient := http.Client {
0 commit comments