-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathweariverse.go
42 lines (38 loc) · 961 Bytes
/
weariverse.go
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
package main
import (
"fmt"
"github.com/wearscript/wearscript-go/wearscript"
)
func WeariverseGistHandle(cm *wearscript.ConnectionManager, userId string, request []interface{}) {
action := request[1].(string)
channelResult := request[2].(string)
fmt.Println("gist action: " + action + " result: " + channelResult)
var dataJS interface{}
var err error
if action == "list" {
dataJS, err = WeariverseGetGists(userId)
} else {
dataJS = "error:action"
}
if err != nil {
fmt.Println(err)
}
cm.Publish(channelResult, dataJS)
}
func WeariverseGetGists(userId string) (interface{}, error) {
//[]string{"9732959", "9423246"}
gists, err := getUserSortedSet("weariverse", "gists")
if err != nil {
return nil, err
}
out := []interface{}{}
for _, value := range gists {
data, err := GithubGetGist(userId, value)
if err != nil {
fmt.Println("weariverse: couldn't get gist")
continue
}
out = append(out, data)
}
return out, nil
}