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 (
|
var (
|
||||||
refresh_Token = "d8bdfb926fec4a32b1e81964cb5b7fba"
|
refresh_Token = "d8bdfb926fec4a32b1e81964cb5b7fba"
|
||||||
accessToken string
|
|
||||||
updateAccesssTokenURL = "https://auth.aliyundrive.com/v2/account/token"
|
updateAccesssTokenURL = "https://auth.aliyundrive.com/v2/account/token"
|
||||||
signinURL = "https://member.aliyundrive.com/v1/activity/sign_in_list"
|
signinURL = "https://member.aliyundrive.com/v1/activity/sign_in_list"
|
||||||
)
|
)
|
||||||
@@ -25,6 +24,10 @@ type aliyundrive struct {
|
|||||||
accessToken string
|
accessToken string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func New(refreshToken string) *aliyundrive {
|
||||||
|
return &aliyundrive{refreshToken: refreshToken}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *aliyundrive) getAccessToken() {
|
func (a *aliyundrive) getAccessToken() {
|
||||||
body := map[string]string{
|
body := map[string]string{
|
||||||
"grant_type": "refresh_token",
|
"grant_type": "refresh_token",
|
||||||
@@ -50,56 +53,53 @@ type refreshToken struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Signrsp struct {
|
type Signrsp struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success,omitempty"`
|
||||||
Code interface{} `json:"code"`
|
Code string `json:"code,omitempty"`
|
||||||
Message interface{} `json:"message"`
|
Message string `json:"message,omitempty"`
|
||||||
TotalCount interface{} `json:"totalCount"`
|
TotalCount string `json:"totalCount,omitempty"`
|
||||||
NextToken interface{} `json:"nextToken"`
|
NextToken string `json:"nextToken,omitempty"`
|
||||||
MaxResults interface{} `json:"maxResults"`
|
MaxResults string `json:"maxResults,omitempty"`
|
||||||
Result Result `json:"result"`
|
Result struct {
|
||||||
Arguments interface{} `json:"arguments"`
|
Subject string `json:"subject,omitempty"`
|
||||||
}
|
Title string `json:"title,omitempty"`
|
||||||
type Result struct {
|
Description string `json:"description,omitempty"`
|
||||||
Subject string `json:"subject"`
|
IsReward bool `json:"isReward,omitempty"`
|
||||||
Title string `json:"title"`
|
Blessing string `json:"blessing,omitempty"`
|
||||||
Description string `json:"description"`
|
SignInCount int `json:"signInCount,omitempty"`
|
||||||
IsReward bool `json:"isReward"`
|
SignInCover string `json:"signInCover,omitempty"`
|
||||||
Blessing string `json:"blessing"`
|
SignInRemindCover string `json:"signInRemindCover,omitempty"`
|
||||||
SignInCount int `json:"signInCount"`
|
RewardCover string `json:"rewardCover,omitempty"`
|
||||||
SignInCover string `json:"signInCover"`
|
SignInLogs []SignInLogs `json:"signInLogs,omitempty"`
|
||||||
SignInRemindCover string `json:"signInRemindCover"`
|
} `json:"result,omitempty"`
|
||||||
RewardCover string `json:"rewardCover"`
|
Arguments string `json:"arguments,omitempty"`
|
||||||
SignInLogs []SignInLogs `json:"signInLogs"`
|
|
||||||
}
|
}
|
||||||
type SignInLogs struct {
|
type SignInLogs struct {
|
||||||
Day int `json:"day"`
|
Day int `json:"day,omitempty"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status,omitempty"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon,omitempty"`
|
||||||
Notice interface{} `json:"notice"`
|
Notice string `json:"notice,omitempty"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type,omitempty"`
|
||||||
Themes string `json:"themes"`
|
Themes string `json:"themes,omitempty"`
|
||||||
CalendarChinese string `json:"calendarChinese"`
|
CalendarChinese string `json:"calendarChinese,omitempty"`
|
||||||
CalendarDay string `json:"calendarDay"`
|
CalendarDay string `json:"calendarDay,omitempty"`
|
||||||
CalendarMonth string `json:"calendarMonth"`
|
CalendarMonth string `json:"calendarMonth,omitempty"`
|
||||||
Poster Poster `json:"poster"`
|
Poster struct {
|
||||||
Reward Reward `json:"reward"`
|
Name string `json:"name,omitempty"`
|
||||||
IsReward bool `json:"isReward"`
|
Reason string `json:"reason,omitempty"`
|
||||||
}
|
Background string `json:"background,omitempty"`
|
||||||
type Poster struct {
|
Color string `json:"color,omitempty"`
|
||||||
Name string `json:"name"`
|
Action string `json:"action,omitempty"`
|
||||||
Reason string `json:"reason"`
|
} `json:"poster,omitempty"`
|
||||||
Background string `json:"background"`
|
Reward struct {
|
||||||
Color string `json:"color"`
|
GoodsID int `json:"goodsId,omitempty"`
|
||||||
Action string `json:"action"`
|
Name string `json:"name,omitempty"`
|
||||||
}
|
Description string `json:"description,omitempty"`
|
||||||
type Reward struct {
|
Background string `json:"background,omitempty"`
|
||||||
GoodsID int `json:"goodsId"`
|
Color string `json:"color,omitempty"`
|
||||||
Name string `json:"name"`
|
Action string `json:"action,omitempty"`
|
||||||
Description string `json:"description"`
|
Notice string `json:"notice,omitempty"`
|
||||||
Background string `json:"background"`
|
} `json:"reward,omitempty"`
|
||||||
Color string `json:"color"`
|
IsReward bool `json:"isReward,omitempty"`
|
||||||
Action string `json:"action"`
|
|
||||||
Notice string `json:"notice"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a aliyundrive) signIn() bool {
|
func (a aliyundrive) signIn() bool {
|
||||||
@@ -127,36 +127,19 @@ func (a aliyundrive) signIn() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("%#v\n", string(body))
|
log.Printf("%#v\n", string(body))
|
||||||
return true
|
|
||||||
if gjson.GetBytes(body, "success").Bool() == true {
|
if gjson.GetBytes(body, "success").Bool() == true {
|
||||||
count := gjson.GetBytes(body, "result.signInCount").Int()
|
count := gjson.GetBytes(body, "result.signInCount").Int()
|
||||||
idx := count - 1
|
result := gjson.GetBytes(body, fmt.Sprintf("result.signInLogs.%d", count-1))
|
||||||
fmt.Println(gjson.GetBytes(body, "result.signInLogs."))
|
log.Printf("已签到%d天,本月第%d日\n", count, result.Get("calendarDay"))
|
||||||
|
if result.Get("isReward").Bool() {
|
||||||
|
log.Printf("%s\n", result.Get("notice"))
|
||||||
}
|
}
|
||||||
// if _, ok := data["success"]; !ok {
|
log.Println(result.String())
|
||||||
// log.Printf("[%s] 签到失败, 错误信息: %v\n", phone, data)
|
} else {
|
||||||
// return false
|
return false
|
||||||
// }
|
}
|
||||||
|
return true
|
||||||
// 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func push(config interface{}, phone string, reward string, signInCount int) {
|
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() {
|
func main() {
|
||||||
// Example usage:
|
// rt := os.Getenv("REFRESH_TOKENS")
|
||||||
// accessToken := "your-access-token"
|
// if rt == "" {
|
||||||
// phone := "your-phone-number"
|
// panic("未配置阿里云盘REFRESH_TOKENS")
|
||||||
// config := map[string]interface{}{} // or ConfigObj object
|
// }
|
||||||
|
|
||||||
// signIn(config, accessToken, phone)
|
a := New(refresh_Token)
|
||||||
|
|
||||||
a := aliyundrive{}
|
|
||||||
a.getAccessToken()
|
a.getAccessToken()
|
||||||
a.signIn()
|
a.signIn()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user