lark

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Index = &ctx.Context{Name: "lark", Help: "会议中心",
	Caches: map[string]*ctx.Cache{},
	Configs: map[string]*ctx.Config{
		"lark_msg": &ctx.Config{Name: "lark_msg", Value: []interface{}{}, Help: "聊天记录"},
	},
	Commands: map[string]*ctx.Command{
		"/lark": &ctx.Command{Name: "user", Help: "应用示例", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) {
			r := m.Optionv("request").(*http.Request)
			w := m.Optionv("response").(http.ResponseWriter)

			data := map[string]interface{}{}
			switch r.Header.Get("Content-Type") {
			case "application/json":
				b, e := ioutil.ReadAll(r.Body)
				e = json.Unmarshal(b, &data)
				m.Assert(e)
			}

			if _, ok := data["challenge"]; ok {
				w.Header().Set("Content-Type", "application/javascript")
				fmt.Fprintf(w, "{\"challenge\": \"%s\"}", data["challenge"])
				return
			}
			m.Confv("lark_msg", "-1", data)
		}},
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL