up
This commit is contained in:
6
go.sum
Normal file
6
go.sum
Normal file
@@ -0,0 +1,6 @@
|
||||
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
||||
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
147
main.go
147
main.go
@@ -15,7 +15,6 @@ import (
|
||||
|
||||
var (
|
||||
refresh_Token = "d8bdfb926fec4a32b1e81964cb5b7fba"
|
||||
accessToken string
|
||||
updateAccesssTokenURL = "https://auth.aliyundrive.com/v2/account/token"
|
||||
signinURL = "https://member.aliyundrive.com/v1/activity/sign_in_list"
|
||||
)
|
||||
@@ -25,6 +24,10 @@ type aliyundrive struct {
|
||||
accessToken string
|
||||
}
|
||||
|
||||
func New(refreshToken string) *aliyundrive {
|
||||
return &aliyundrive{refreshToken: refreshToken}
|
||||
}
|
||||
|
||||
func (a *aliyundrive) getAccessToken() {
|
||||
body := map[string]string{
|
||||
"grant_type": "refresh_token",
|
||||
@@ -50,56 +53,53 @@ type refreshToken struct {
|
||||
}
|
||||
|
||||
type Signrsp struct {
|
||||
Success bool `json:"success"`
|
||||
Code interface{} `json:"code"`
|
||||
Message interface{} `json:"message"`
|
||||
TotalCount interface{} `json:"totalCount"`
|
||||
NextToken interface{} `json:"nextToken"`
|
||||
MaxResults interface{} `json:"maxResults"`
|
||||
Result Result `json:"result"`
|
||||
Arguments interface{} `json:"arguments"`
|
||||
}
|
||||
type Result struct {
|
||||
Subject string `json:"subject"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
IsReward bool `json:"isReward"`
|
||||
Blessing string `json:"blessing"`
|
||||
SignInCount int `json:"signInCount"`
|
||||
SignInCover string `json:"signInCover"`
|
||||
SignInRemindCover string `json:"signInRemindCover"`
|
||||
RewardCover string `json:"rewardCover"`
|
||||
SignInLogs []SignInLogs `json:"signInLogs"`
|
||||
Success bool `json:"success,omitempty"`
|
||||
Code string `json:"code,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
TotalCount string `json:"totalCount,omitempty"`
|
||||
NextToken string `json:"nextToken,omitempty"`
|
||||
MaxResults string `json:"maxResults,omitempty"`
|
||||
Result struct {
|
||||
Subject string `json:"subject,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
IsReward bool `json:"isReward,omitempty"`
|
||||
Blessing string `json:"blessing,omitempty"`
|
||||
SignInCount int `json:"signInCount,omitempty"`
|
||||
SignInCover string `json:"signInCover,omitempty"`
|
||||
SignInRemindCover string `json:"signInRemindCover,omitempty"`
|
||||
RewardCover string `json:"rewardCover,omitempty"`
|
||||
SignInLogs []SignInLogs `json:"signInLogs,omitempty"`
|
||||
} `json:"result,omitempty"`
|
||||
Arguments string `json:"arguments,omitempty"`
|
||||
}
|
||||
type SignInLogs struct {
|
||||
Day int `json:"day"`
|
||||
Status string `json:"status"`
|
||||
Icon string `json:"icon"`
|
||||
Notice interface{} `json:"notice"`
|
||||
Type string `json:"type"`
|
||||
Themes string `json:"themes"`
|
||||
CalendarChinese string `json:"calendarChinese"`
|
||||
CalendarDay string `json:"calendarDay"`
|
||||
CalendarMonth string `json:"calendarMonth"`
|
||||
Poster Poster `json:"poster"`
|
||||
Reward Reward `json:"reward"`
|
||||
IsReward bool `json:"isReward"`
|
||||
}
|
||||
type Poster struct {
|
||||
Name string `json:"name"`
|
||||
Reason string `json:"reason"`
|
||||
Background string `json:"background"`
|
||||
Color string `json:"color"`
|
||||
Action string `json:"action"`
|
||||
}
|
||||
type Reward struct {
|
||||
GoodsID int `json:"goodsId"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Background string `json:"background"`
|
||||
Color string `json:"color"`
|
||||
Action string `json:"action"`
|
||||
Notice string `json:"notice"`
|
||||
Day int `json:"day,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Notice string `json:"notice,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Themes string `json:"themes,omitempty"`
|
||||
CalendarChinese string `json:"calendarChinese,omitempty"`
|
||||
CalendarDay string `json:"calendarDay,omitempty"`
|
||||
CalendarMonth string `json:"calendarMonth,omitempty"`
|
||||
Poster struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Background string `json:"background,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
Action string `json:"action,omitempty"`
|
||||
} `json:"poster,omitempty"`
|
||||
Reward struct {
|
||||
GoodsID int `json:"goodsId,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Background string `json:"background,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
Action string `json:"action,omitempty"`
|
||||
Notice string `json:"notice,omitempty"`
|
||||
} `json:"reward,omitempty"`
|
||||
IsReward bool `json:"isReward,omitempty"`
|
||||
}
|
||||
|
||||
func (a aliyundrive) signIn() bool {
|
||||
@@ -127,36 +127,19 @@ func (a aliyundrive) signIn() bool {
|
||||
}
|
||||
|
||||
log.Printf("%#v\n", string(body))
|
||||
return true
|
||||
|
||||
if gjson.GetBytes(body, "success").Bool() == true {
|
||||
count := gjson.GetBytes(body, "result.signInCount").Int()
|
||||
idx := count - 1
|
||||
fmt.Println(gjson.GetBytes(body, "result.signInLogs."))
|
||||
result := gjson.GetBytes(body, fmt.Sprintf("result.signInLogs.%d", count-1))
|
||||
log.Printf("已签到%d天,本月第%d日\n", count, result.Get("calendarDay"))
|
||||
if result.Get("isReward").Bool() {
|
||||
log.Printf("%s\n", result.Get("notice"))
|
||||
}
|
||||
log.Println(result.String())
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
// if _, ok := data["success"]; !ok {
|
||||
// log.Printf("[%s] 签到失败, 错误信息: %v\n", phone, data)
|
||||
// return false
|
||||
// }
|
||||
|
||||
// var currentDay map[string]interface{}
|
||||
// for i, day := range data["result"].(map[string]interface{})["signInLogs"].([]interface{}) {
|
||||
// if day.(map[string]interface{})["status"].(string) == "miss" {
|
||||
// currentDay = data["result"].(map[string]interface{})["signInLogs"].([]interface{})[i-1].(map[string]interface{})
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
|
||||
// reward := "无奖励"
|
||||
// if currentDay != nil && currentDay["isReward"].(bool) {
|
||||
// reward = fmt.Sprintf("获得 %s %s", currentDay["reward"].(map[string]interface{})["name"].(string), currentDay["reward"].(map[string]interface{})["description"].(string))
|
||||
// }
|
||||
|
||||
// log.Printf("[%s] 签到成功, 本月累计签到 %d 天.\n", phone, int(data["result"].(map[string]interface{})["signInCount"].(float64)))
|
||||
// log.Printf("[%s] 本次签到 %s\n", phone, reward)
|
||||
|
||||
// push(config, phone, reward, int(data["result"].(map[string]interface{})["signInCount"].(float64)))
|
||||
|
||||
// return true
|
||||
return true
|
||||
}
|
||||
|
||||
func push(config interface{}, phone string, reward string, signInCount int) {
|
||||
@@ -164,14 +147,12 @@ func push(config interface{}, phone string, reward string, signInCount int) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Example usage:
|
||||
// accessToken := "your-access-token"
|
||||
// phone := "your-phone-number"
|
||||
// config := map[string]interface{}{} // or ConfigObj object
|
||||
// rt := os.Getenv("REFRESH_TOKENS")
|
||||
// if rt == "" {
|
||||
// panic("未配置阿里云盘REFRESH_TOKENS")
|
||||
// }
|
||||
|
||||
// signIn(config, accessToken, phone)
|
||||
|
||||
a := aliyundrive{}
|
||||
a := New(refresh_Token)
|
||||
a.getAccessToken()
|
||||
a.signIn()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user