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密文回复 } }
func TextMsgHandler(ctx *core.Context) { log.Printf("收到文本消息:\n%s\n", ctx.MsgPlaintext) BoradcastMessage(string(ctx.MsgPlaintext)) msg := request.GetText(ctx.MixedMsg) if msg.Content == "是" { re := "小鱼停车感谢您的信任,此次停车从" + time.Now().Format("2016-01-01 12:01:01") + "开始计费" resp := response.NewText(msg.FromUserName, msg.ToUserName, msg.CreateTime, re) ctx.RawResponse(resp) // 明文回复 } else if msg.Content == "否" { re := "小鱼停车会继续努力,虔诚为您服务" resp := response.NewText(msg.FromUserName, msg.ToUserName, msg.CreateTime, re) ctx.RawResponse(resp) // 明文回复 } else { // resp := response.NewText(msg.FromUserName, msg.ToUserName, msg.CreateTime, msg.Content) articles := []response.Article{{Title: "title1", Description: "小鱼祝您生活愉快", PicURL: "https://iguiyu.com/images/car.png", URL: "https://iguiyu.com/"}} resp := response.NewNews(msg.FromUserName, msg.ToUserName, msg.CreateTime, articles) ctx.RawResponse(resp) // 明文回复 // ctx.AESResponse(resp, 0, "", nil) // aes密文回复 } }