Ejemplo n.º 1
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密文回复
}
Ejemplo n.º 2
0
func textMsgHandler(ctx *core.Context) {
	log.Printf("收到文本消息:\n%s\n", ctx.MsgPlaintext)

	msg := request.GetText(ctx.MixedMsg)

	if msg.Content == "抛硬币" {
		ms := "正面"
		if rand.Intn(2) == 0 {
			ms = "反面"
		}
		rs := response.NewText(msg.FromUserName, msg.ToUserName, msg.CreateTime, ms)
		ctx.AESResponse(rs, 0, "", nil)
	} else {

		resp := response.NewText(msg.FromUserName, msg.ToUserName, msg.CreateTime, msg.Content)
		//ctx.RawResponse(resp) // 明文回复
		ctx.AESResponse(resp, 0, "", nil) // aes密文回复
	}

}