From 68e0926b77ae54375c49784c0050ad9481cfdd78 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Wed, 18 Aug 2021 14:21:15 +0800 Subject: [PATCH] x --- models/asset.go | 104 +++++++++++++++++++++++++++++++++++++++++++- models/available.go | 2 +- 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/models/asset.go b/models/asset.go index 3728dc9..7c339bc 100644 --- a/models/asset.go +++ b/models/asset.go @@ -73,8 +73,10 @@ func (ck *JdCookie) Query() string { cookie := fmt.Sprintf("pt_key=%s;pt_pin=%s;", ck.PtKey, ck.PtPin) var rpc = make(chan []RedList) var fruit = make(chan string) + var pet = make(chan string) go redPacket(cookie, rpc) go initFarm(cookie, fruit) + go initPetTown(cookie, pet) today := time.Now().Local().Format("2006-01-02") yestoday := time.Now().Local().Add(-time.Hour * 24).Format("2006-01-02") page := 1 @@ -160,6 +162,7 @@ func (ck *JdCookie) Query() string { msgs = append(msgs, "暂无红包数据🧧") } msgs = append(msgs, fmt.Sprintf("东东农场:%s", <-fruit)) + msgs = append(msgs, fmt.Sprintf("东东萌宠:%s", <-pet)) } else { msgs = append(msgs, []string{ "提醒:该账号已过期,请重新登录", @@ -402,10 +405,109 @@ func initFarm(cookie string, state chan string) { if a.TreeState == 2 || a.TreeState == 3 { rt += "已可领取⏰" } else if a.TreeState == 1 { - rt += "种植中..." + rt += "种植中🍒" } else if a.TreeState == 0 { rt = "您忘了种植新的水果⏰" } } state <- rt } + +func initPetTown(cookie string, state chan string) { + type ResourceList struct { + AdvertID string `json:"advertId"` + ImageURL string `json:"imageUrl"` + Link string `json:"link"` + ShopID string `json:"shopId"` + } + type PetPlaceInfoList struct { + Place int `json:"place"` + Energy int `json:"energy"` + } + type PetInfo struct { + AdvertID string `json:"advertId"` + NickName string `json:"nickName"` + IconURL string `json:"iconUrl"` + ClickIconURL string `json:"clickIconUrl"` + FeedGifURL string `json:"feedGifUrl"` + HomePetImage string `json:"homePetImage"` + CrossBallURL string `json:"crossBallUrl"` + RunURL string `json:"runUrl"` + TickleURL string `json:"tickleUrl"` + } + type GoodsInfo struct { + GoodsName string `json:"goodsName"` + GoodsURL string `json:"goodsUrl"` + GoodsID string `json:"goodsId"` + ExchangeMedalNum int `json:"exchangeMedalNum"` + ActivityID string `json:"activityId"` + ActivityIds string `json:"activityIds"` + } + type Result struct { + ShareCode string `json:"shareCode"` + HisHbFlag bool `json:"hisHbFlag"` + MasterHelpPeoples []interface{} `json:"masterHelpPeoples"` + HelpSwitchOn bool `json:"helpSwitchOn"` + UserStatus int `json:"userStatus"` + TotalEnergy int `json:"totalEnergy"` + MasterInvitePeoples []interface{} `json:"masterInvitePeoples"` + ShareTo string `json:"shareTo"` + PetSportStatus int `json:"petSportStatus"` + UserImage string `json:"userImage"` + MasterHelpReward int `json:"masterHelpReward"` + ShowHongBaoExchangePop bool `json:"showHongBaoExchangePop"` + ShowNeedCollectPop bool `json:"showNeedCollectPop"` + PetSportReward string `json:"petSportReward"` + NewhandBubble bool `json:"newhandBubble"` + ResourceList []ResourceList `json:"resourceList"` + ProjectBubble bool `json:"projectBubble"` + MasterInvitePop bool `json:"masterInvitePop"` + MasterInviteReward int `json:"masterInviteReward"` + MedalNum int `json:"medalNum"` + MasterHelpPop bool `json:"masterHelpPop"` + MeetDays int `json:"meetDays"` + PetPlaceInfoList []PetPlaceInfoList `json:"petPlaceInfoList"` + MedalPercent float64 `json:"medalPercent"` + CharitableSwitchOn bool `json:"charitableSwitchOn"` + PetInfo PetInfo `json:"petInfo"` + NeedCollectEnergy int `json:"needCollectEnergy"` + FoodAmount int `json:"foodAmount"` + InviteCode string `json:"inviteCode"` + RulesURL string `json:"rulesUrl"` + PetStatus int `json:"petStatus"` + GoodsInfo GoodsInfo `json:"goodsInfo"` + } + type AutoGenerated struct { + Code string `json:"code"` + ResultCode string `json:"resultCode"` + Message string `json:"message"` + Result Result `json:"result"` + } + a := AutoGenerated{} + req := httplib.Post(`https://api.m.jd.com/client.action?functionId=initPetTown`) + req.Header("Host", "api.m.jd.com") + req.Header("User-Agent", ua) + req.Header("cookie", cookie) + req.Header("Content-Type", "application/x-www-form-urlencoded") + req.Body(`body={}&appid=wh5&loginWQBiz=pet-town&clientVersion=9.0.4`) + data, _ := req.Bytes() + fmt.Println(data) + json.Unmarshal(data, &a) + rt := "" + if a.Code == "0" && a.ResultCode == "0" && a.Message == "success" { + if a.Result.UserStatus == 0 { + rt = "请手动开启活动⏰" + } else if a.Result.GoodsInfo.GoodsName == "" { + rt = "你忘了选购新的商品⏰" + } else if a.Result.PetStatus == 5 { + rt = a.Result.GoodsInfo.GoodsName + "已可领取⏰" + } else if a.Result.PetStatus == 6 { + rt = a.Result.GoodsInfo.GoodsName + "未继续领养新的物品⏰" + } else { + rt = a.Result.GoodsInfo.GoodsName + "领养中🐶" + } + } else { + rt = "数据异常" + } + state <- rt +} diff --git a/models/available.go b/models/available.go index e9bb5f8..3ac9ee7 100644 --- a/models/available.go +++ b/models/available.go @@ -133,7 +133,7 @@ func initCookie() { } func CookieOK(ck *JdCookie) bool { - // initFarm(fmt.Sprintf("pt_key=%s;pt_pin=%s;", ck.PtKey, ck.PtPin)) + // initPetTown(fmt.Sprintf("pt_key=%s;pt_pin=%s;", ck.PtKey, ck.PtPin)) if ck == nil { return true }