first commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package wxrouter
|
||||
|
||||
import (
|
||||
"time"
|
||||
"xiawan/wx/clientsdk"
|
||||
"xiawan/wx/protobuf/wechat"
|
||||
"xiawan/wx/srv/wxcore"
|
||||
"xiawan/wx/srv/wxface"
|
||||
)
|
||||
|
||||
// WXSnsTimeLineRouter 心跳包响应路由
|
||||
type WXSnsTimeLineRouter struct {
|
||||
wxcore.WXBaseRouter
|
||||
}
|
||||
|
||||
// Handle 处理conn业务的方法
|
||||
func (oplog *WXSnsTimeLineRouter) Handle(wxResp wxface.IWXResponse) error {
|
||||
defer wxcore.TryE("WXSnsTimeLineRouter Handle")
|
||||
currentWXConn := wxResp.GetWXConncet()
|
||||
currentWXAccount := currentWXConn.GetWXAccount()
|
||||
currentUserInfo := currentWXAccount.GetUserInfo()
|
||||
currentTaskMgr := currentWXConn.GetWXTaskMgr()
|
||||
taskMgr, _ := currentTaskMgr.(*wxcore.WXTaskMgr)
|
||||
snsTask := taskMgr.GetSnsTask()
|
||||
|
||||
// 解析退出登陆响应包
|
||||
var timeLineResp wechat.SnsTimeLineResponse
|
||||
err := clientsdk.ParseResponseData(currentUserInfo, wxResp.GetPackHeader(), &timeLineResp)
|
||||
if err != nil {
|
||||
// 请求出问题了,判断是否掉线,并重连
|
||||
time.Sleep(1 * time.Second)
|
||||
go currentWXConn.CheckOnLineStatusLogin()
|
||||
return err
|
||||
}
|
||||
|
||||
currentTime := snsTask.GetCurrentCreateTime()
|
||||
tmpObjList := timeLineResp.GetObjectList()
|
||||
tmpCount := len(tmpObjList)
|
||||
// 判断是否有初始化
|
||||
if currentTime == 0 {
|
||||
snsTask.SetCurrentCreateTime(1)
|
||||
if tmpCount > 0 {
|
||||
snsTask.SetCurrentCreateTime(tmpObjList[0].GetCreateTime())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 自动添加评论
|
||||
for index := 0; index < tmpCount; index++ {
|
||||
tmpSnsObj := tmpObjList[index]
|
||||
if tmpSnsObj.GetCreateTime() <= currentTime {
|
||||
break
|
||||
}
|
||||
if snsTask.IsAutoThumbUP() {
|
||||
snsTask.AddCommentItemObj(tmpSnsObj)
|
||||
}
|
||||
if snsTask.IsAutoComment() {
|
||||
snsTask.AddCommentItemObjcomment(tmpSnsObj)
|
||||
}
|
||||
}
|
||||
|
||||
// 设置最新的朋友圈创建时间
|
||||
if tmpCount > 0 {
|
||||
snsTask.SetCurrentCreateTime(tmpObjList[0].GetCreateTime())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user