Esempio n. 1
0
File: event.go Progetto: iguiyu/demo
func DefaultEventHandler(ctx *core.Context) {
	log.Printf("收到事件:\n%s\n", ctx.MsgPlaintext)
	event := menu.GetClickEvent(ctx.MixedMsg)
	var desc string
	switch event.EventType {
	case "subscribe":
		subevent := request.GetSubscribeEvent(ctx.MixedMsg)
		desc = "谢谢关注" + subevent.EventKey
	case "unsubscribe":
		desc = "取消关注"
	case "SCAN":
		scanEvent := request.GetScanEvent(ctx.MixedMsg)
		desc = "车位编码:" + scanEvent.EventKey + "\n当前时段:12:00-20:00\n当前时段价格:20元/小时\n当前时段封顶:100元\n停车回复是,否则回复"
	case "scancode_waitmsg":
		scanEvent := request.GetScanEvent(ctx.MixedMsg)
		desc = "车位编码:" + scanEvent.EventKey + "\n当前时段:12:00-20:00\n当前时段价格:20元/小时\n当前时段封顶:100元\n停车回复是,否则回复"
	default:
		desc = "sorry I don't know"

	}
	log.Println(desc)
	resp := response.NewText(event.FromUserName, event.ToUserName, event.CreateTime, desc)

	ctx.RawResponse(resp) // 明文回复
}
Esempio n. 2
0
func menuClickEventHandler(ctx *core.Context) {
	log.Printf("收到菜单 click 事件:\n%s\n", ctx.MsgPlaintext)

	event := menu.GetClickEvent(ctx.MixedMsg)
	resp := response.NewText(event.FromUserName, event.ToUserName, event.CreateTime, "收到 click 类型的事件")
	//ctx.RawResponse(resp) // 明文回复
	ctx.AESResponse(resp, 0, "", nil) // aes密文回复
}
Esempio n. 3
0
File: event.go Progetto: iguiyu/demo
func MenuClickEventHandler(ctx *core.Context) {
	log.Printf("收到菜单 click 事件:\n%s\n", ctx.MsgPlaintext)
	event := menu.GetClickEvent(ctx.MixedMsg)
	var desc string
	switch event.EventKey {
	case "scan":
		desc = "停车"
	case "park":
		desc = "停车"
	default:
		desc = "sorry I don't know"

	}
	resp := response.NewText(event.FromUserName, event.ToUserName, event.CreateTime, "收到 click 类型的事件"+desc)

	ctx.RawResponse(resp) // 明文回复
	// ctx.AESResponse(resp, 0, "", nil) // aes密文回复
}