diff --git a/go.mod b/go.mod index 5ebe7da..492d0f1 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( ) require ( + github.com/TencentCloud/wemeet-openapi-sdk-go v1.0.2 // indirect github.com/emersion/go-imap v1.2.1 // indirect github.com/emersion/go-message v0.15.0 // indirect github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 // indirect diff --git a/go.sum b/go.sum index 61196c6..e022e66 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY= +github.com/TencentCloud/wemeet-openapi-sdk-go v1.0.2 h1:OjB5cfSHq/lrAhdovqbHXGj3xZbEZx/ihOJ0WPpLnhU= +github.com/TencentCloud/wemeet-openapi-sdk-go v1.0.2/go.mod h1:qxY19B8zTyoAdiq7Ctz2uP1R8HYVTQtUzggOt9OzZzs= github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= github.com/bgould/http v0.0.0-20190627042742-d268792bdee7/go.mod h1:BTqvVegvwifopl4KTEDth6Zezs9eR+lCWhvGKvkxJHE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/src/guanlixitong/conference.go b/src/guanlixitong/conference.go index cc09736..e7ada59 100644 --- a/src/guanlixitong/conference.go +++ b/src/guanlixitong/conference.go @@ -1,14 +1,69 @@ package guanlixitong -import "shylinux.com/x/ice" +import ( + "math/rand" + "strconv" + "strings" + "time" + + wemeet "github.com/TencentCloud/wemeet-openapi-sdk-go/wemeet_openapi" + wemeetcore "github.com/TencentCloud/wemeet-openapi-sdk-go/wemeet_openapi/core" + meetings "github.com/TencentCloud/wemeet-openapi-sdk-go/wemeet_openapi/service/meetings" + "shylinux.com/x/ice" + kit "shylinux.com/x/toolkits" +) type conference struct { Table fields string `data:"title,content,user_uid"` create string `name:"create title* content*" role:"leader"` remove string `name:"remove" role:"leader"` + join string `name:"join" help:"入会" style:"notice" role:"void"` } -func (s conference) List(m *ice.Message, arg ...string) { s.ValueList(m, arg) } +func (s conference) List(m *ice.Message, arg ...string) { + s.V1MeetingsGet(m, "admin1731860473", "1") + m.PushAction(s.Join) + m.Display("") +} +func (s conference) Join(m *ice.Message, arg ...string) { + m.ProcessOpen(m.Option("join_url")) +} func init() { ice.TeamCtxCmd(conference{}) } + +func (s conference) V1MeetingsGet(m *ice.Message, arg ...string) { + client, authenticator := s.newClient(m) + response, err := client.MeetingsApi.V1MeetingsGet(m, &meetings.ApiV1MeetingsGetRequest{ + Userid: &arg[0], Instanceid: &arg[1], + }, wemeetcore.WithJWTAuth(authenticator)) + s.resTable(m, response.Data, err, "meeting_info_list", + "subject", "meeting_code", "start_time", "end_time", "join_url", + ) +} +func (s conference) resTable(m *ice.Message, data ice.Any, err error, key string, arg ...string) { + if err != nil { + m.Echo(kit.Formats(err)) + } else { + data := kit.UnMarshal(kit.Formats(data)) + kit.For(kit.Value(data, key), func(value ice.Map) { + kit.For(arg, func(key string) { + if strings.HasSuffix(key, "_time") { + t := time.Unix(kit.Int64(value[key]), 0) + m.Push(key, strings.TrimSuffix(t.Format(ice.MOD_TIME), ":00.000")) + } else { + m.Push(key, value[key]) + } + }) + }) + } +} +func (s conference) newClient(m *ice.Message, arg ...string) (*wemeet.Client, *wemeetcore.JWTAuthenticator) { + client := wemeet.NewClient(wemeet.WithAppId("234460469"), wemeet.WithSdkId("27510111425"), + wemeet.WithSecret("i4MYQuEzVtd0Jb5qbecDMXgSLD2AhQh0", "mYkEPBtGPYjcu0a5gvlK2HNGU0ZRDaG5AAssB29Dvp2A3FB6")) + rn := rand.New(rand.NewSource(time.Now().UnixNano())) + nonce := uint64(100000 + rn.Intn(900000)) + curTs := strconv.Itoa(int(time.Now().Unix())) + authenticator := &wemeetcore.JWTAuthenticator{Nonce: nonce, Timestamp: curTs} + return client, authenticator +} diff --git a/src/guanlixitong/conference.js b/src/guanlixitong/conference.js new file mode 100644 index 0000000..7708311 --- /dev/null +++ b/src/guanlixitong/conference.js @@ -0,0 +1,8 @@ +Volcanos(chat.ONIMPORT, { + _init: function(can, msg) { + can.onimport.myView(can, msg, function(value) { return [ + {view: html.TITLE, list: [value.subject, can.onimport.titleAction(can, value)]}, + {view: html.STATUS, list: [value.start_time, "~", value.end_time.split(" ")[1]]}, + ] }) + }, +}) \ No newline at end of file diff --git a/src/guanlixitong/conference.shy b/src/guanlixitong/conference.shy new file mode 100644 index 0000000..5a0e10f --- /dev/null +++ b/src/guanlixitong/conference.shy @@ -0,0 +1,7 @@ +chapter "腾讯会议" +refer ` +后台 https://meeting.tencent.com/user-center/work-bench +应用 https://meeting.tencent.com/marketplace/corp-created +文档 https://cloud.tencent.com/document/product/1095/83658 +调试 https://meeting.tencent.com/marketplace/restApiTool.html?type=jwt&interface_id=dTRvM3FoUXJWaDlGZndGWTJpR3J0RkNy&replica_id=NE9GdEsx +` \ No newline at end of file