package main

func (ss *openIDSessionData) serveEvents(in *InWechatMsg) (processed bool) {
	processed = true
	e := in.body.(EventMsg)
	switch e.Event {
	case "subscribe":
		in.replyText("/::D, 来啦")
		onSubscribe(in)
		return
	case "unsubscribe":
		in.replyText("")
		onUnSubscribe(in)
		return
	case "pic_photo_or_album":
		in.replyText("上传图片")
	case "scancode_waitmsg":
		in.replyText("scancode_waitmsg/" + e.EventKey)
	case "SCAN":
		in.replyText("SCAN/" + e.EventKey)
	case "LOCATION":
		in.replyText("")
		onLocation(in)
	case "CLICK":
		onClick(ss, in)
		in.replyText("") //safeguard
	case "VIEW":
		in.replyText("VIEW" + e.EventKey)
	case "TEMPLATESENDJOBFINISH":
		// <xml><ToUserName><![CDATA[gh_f09231355c68]]></ToUserName>
		// <FromUserName><![CDATA[oUN420Wj78vnkNeAJY7RMPXA28oc]]></FromUserName>
		// <CreateTime>1499150186</CreateTime>
		// <MsgType><![CDATA[event]]></MsgType>
		// <Event><![CDATA[TEMPLATESENDJOBFINISH]]></Event>
		// <MsgID>414001772</MsgID>
		// <Status><![CDATA[success]]></Status>
		// </xml>
		//in.replyText("TEMPLATESENDJOBFINISH")
		in.replyText("")
	}
	return
}
