From 9b3760b13576a326872dc1859856cdfa0a484949 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Mon, 3 Jan 2022 12:44:14 +0800
Subject: [PATCH 01/17] Add go.mod
---
go.mod | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 go.mod
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..afc5003
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,14 @@
+module github.com/XiaoMengXinX/Fuck163MusicTasks/v2
+
+go 1.17
+
+require (
+ github.com/XiaoMengXinX/Music163Api-Go v0.1.17
+ github.com/robfig/cron/v3 v3.0.1
+ github.com/sirupsen/logrus v1.8.1
+)
+
+require (
+ github.com/google/uuid v1.3.0 // indirect
+ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
+)
From 54f29e2dea1e7dfb8d83ff408254bb3bb861dd7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Tue, 1 Mar 2022 00:08:07 +0800
Subject: [PATCH 02/17] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?=
=?UTF-8?q?=E6=97=A0=E6=B3=95=E8=8E=B7=E5=8F=96=E4=BB=BB=E5=8A=A1=E7=9A=84?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
main.go | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/main.go b/main.go
index 5e85c80..c4ca114 100644
--- a/main.go
+++ b/main.go
@@ -235,7 +235,7 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
}
}()
switch autoTasks[i] {
- case 399000:
+ case 749006:
log.Printf("[%s] 执行音乐人签到任务中", userData.Profile.Nickname)
result, err := api.MusicianSign(data)
if err != nil {
@@ -246,14 +246,14 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
} else {
log.Printf("[%s] 音乐人签到失败: %s", userData.Profile.Nickname, result.Message)
}
- case 398000:
+ case 740004:
log.Printf("[%s] 执行发送动态任务中", userData.Profile.Nickname)
err := sendEventTask(userData, data)
if err != nil {
log.Println(err)
}
log.Printf("[%s] 发送动态任务执行完成", userData.Profile.Nickname)
- case 393001:
+ case 732004:
log.Printf("[%s] 执行回复评论任务中", userData.Profile.Nickname)
commentConfig := api.CommentConfig{
ResType: api.ResTypeMusic,
@@ -266,22 +266,22 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
log.Println(err)
}
log.Printf("[%s] 发送回复评论执行完成", userData.Profile.Nickname)
- case 395002:
+ case 755001:
log.Printf("[%s] 执行发送私信任务中", userData.Profile.Nickname)
err := sendMsgTask(userData, config.SendMsgConfig.UserID[processingUser], data)
if err != nil {
log.Println(err)
}
log.Printf("[%s] 发送私信任务执行完成", userData.Profile.Nickname)
- case 135000:
+ case 744005:
log.Printf("[%s] 执行发送 Mlog 任务中", userData.Profile.Nickname)
err := sendMlogTask(userData, data)
if err != nil {
log.Println(err)
}
log.Printf("[%s] 发送 Mlog 任务执行完成", userData.Profile.Nickname)
- case 396002:
- log.Printf("[%s] 执行发主创说任务中", userData.Profile.Nickname)
+ case 396002: // 待修复
+ log.Printf("[%s] 执行发布主创说任务中", userData.Profile.Nickname)
commentConfig := api.CommentConfig{
ResType: api.ResTypeMusic,
ResID: config.CommentConfig.RepliedComment[processingUser].MusicID,
@@ -606,7 +606,7 @@ func checkPathExists(path string) bool {
}
func autoTaskAvail(val int) bool {
- availAutoTasks := []int{135000, 399000, 398000, 393001, 395002, 396002}
+ availAutoTasks := []int{740004,744005,732004,755001,749006} // 待修复
for i := 0; i < len(availAutoTasks); i++ {
if val == availAutoTasks[i] {
return true
From 2a46d445da98d89b72066a5259b1982c82eb21d9 Mon Sep 17 00:00:00 2001
From: xmxx
Date: Sun, 13 Mar 2022 01:11:13 +0800
Subject: [PATCH 03/17] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BB=E5=88=9B?=
=?UTF-8?q?=E8=AF=B4=E4=BB=BB=E5=8A=A1=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=94=AF?=
=?UTF-8?q?=E6=8C=81=E8=AE=BF=E9=97=AE=E4=BA=91=E5=9C=88=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
build_release.sh | 12 +++---
go.mod | 4 +-
go.sum | 7 ++--
main.go | 99 +++++++++++++++++++++++++++++++++++++++---------
4 files changed, 93 insertions(+), 29 deletions(-)
diff --git a/build_release.sh b/build_release.sh
index e23d683..183d310 100644
--- a/build_release.sh
+++ b/build_release.sh
@@ -1,11 +1,9 @@
#!/bin/bash
-VERSION=$(git describe --tags)
-
mkdir out
-bash build.sh linux amd64 -o "./out/Fuck163MusicTasks_${VERSION}_linux_amd64"
-bash build.sh linux arm64 -o "./out/Fuck163MusicTasks_${VERSION}_linux_arm64"
-bash build.sh windows amd64 -o "./out/Fuck163MusicTasks_${VERSION}_windows_amd64.exe"
-bash build.sh darwin amd64 -o "./out/Fuck163MusicTasks_${VERSION}_darwin_amd64"
-bash build.sh darwin arm64 -o "./out/Fuck163MusicTasks_${VERSION}_darwin_arm64"
+bash build.sh linux amd64 -o "./out/Fuck163MusicTasks_linux_amd64"
+bash build.sh linux arm64 -o "./out/Fuck163MusicTasks_linux_arm64"
+bash build.sh windows amd64 -o "./out/Fuck163MusicTasks_windows_amd64.exe"
+bash build.sh darwin amd64 -o "./out/Fuck163MusicTasks_darwin_amd64"
+bash build.sh darwin arm64 -o "./out/Fuck163MusicTasks_darwin_arm64"
diff --git a/go.mod b/go.mod
index afc5003..8423a55 100644
--- a/go.mod
+++ b/go.mod
@@ -3,12 +3,12 @@ module github.com/XiaoMengXinX/Fuck163MusicTasks/v2
go 1.17
require (
- github.com/XiaoMengXinX/Music163Api-Go v0.1.17
+ github.com/XiaoMengXinX/Music163Api-Go v0.1.24
github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.8.1
)
require (
github.com/google/uuid v1.3.0 // indirect
- golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect
+ golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
)
diff --git a/go.sum b/go.sum
index c78cb94..585ced9 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-github.com/XiaoMengXinX/Music163Api-Go v0.1.17 h1:iO4nZeYkyWHSvTH3PnQBNxGcOEZaK9EzK849HfH8y8A=
-github.com/XiaoMengXinX/Music163Api-Go v0.1.17/go.mod h1:4lcWLPwXMsTiwcyM6JBEAHkU7NUvYJOMPtfiUj9X0Jw=
+github.com/XiaoMengXinX/Music163Api-Go v0.1.24 h1:tz4c4R8yVJTi8zVdGA7PsBXXU4YmT9iUE7dQjE53Jy8=
+github.com/XiaoMengXinX/Music163Api-Go v0.1.24/go.mod h1:kLU/CkLxKnEJFCge0URvQ0lHt6ImoG1/2aVeNbgV2RQ=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
@@ -12,5 +12,6 @@ github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
-golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
+golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/main.go b/main.go
index 5e85c80..cab98cd 100644
--- a/main.go
+++ b/main.go
@@ -36,6 +36,7 @@ var eventLag RandomNum
var msgLag RandomNum
var mlogLag RandomNum
var processingUser int
+var circleID string
var configFileName = flag.String("c", "config.json", "Config filename") // 从 cli 参数读取配置文件名
var printVersion = flag.Bool("v", false, "Print version")
var isDEBUG = flag.Bool("d", false, "DEBUG mode")
@@ -201,6 +202,8 @@ func autoTasks(userData types.LoginStatusData, data utils.RequestData) error {
return err
}
if strings.Contains(userDetail.CurrentExpert.RoleName, "网易音乐人") {
+ artistDetail, err := api.GetArtistDetail(data, int64(userDetail.Profile.ArtistId))
+ parseCircleID(artistDetail)
autoTasks, err := checkCloudBean(userData, data)
if err != nil {
return err
@@ -280,8 +283,8 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
log.Println(err)
}
log.Printf("[%s] 发送 Mlog 任务执行完成", userData.Profile.Nickname)
- case 396002:
- log.Printf("[%s] 执行发主创说任务中", userData.Profile.Nickname)
+ case 755000:
+ log.Printf("[%s] 执行发送主创说任务中", userData.Profile.Nickname)
commentConfig := api.CommentConfig{
ResType: api.ResTypeMusic,
ResID: config.CommentConfig.RepliedComment[processingUser].MusicID,
@@ -292,7 +295,27 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
log.Println(err)
}
log.Printf("[%s] 发送主创说任务执行完成", userData.Profile.Nickname)
+ case 740005:
+ log.Printf("[%s] 执行访问云圈任务中", userData.Profile.Nickname)
+ err := getCircleTask(data)
+ if err != nil {
+ log.Println(err)
+ }
+ log.Printf("[%s] 访问云圈任务执行完成", userData.Profile.Nickname)
+ }
+}
+
+func getCircleTask(data utils.RequestData) error {
+ if circleID != "" {
+ result, err := api.GetCircle(data, circleID)
+ if err != nil {
+ return err
+ }
+ if result.Code != 200 {
+ return fmt.Errorf("%s", result.Message)
+ }
}
+ return nil
}
func userSignTask(userData types.LoginStatusData, data utils.RequestData) error {
@@ -320,7 +343,7 @@ func userSignTask(userData types.LoginStatusData, data utils.RequestData) error
func sendEventTask(userData types.LoginStatusData, data utils.RequestData) error {
failedTimes := 0
- for i := 0; i < 3; {
+ for i := 0; i < 1; {
if failedTimes >= 5 {
return fmt.Errorf("[%s] 发送动态累计 %d 次失败, 已自动退出", userData.Profile.Nickname, failedTimes)
}
@@ -364,7 +387,7 @@ func sendEventTask(userData types.LoginStatusData, data utils.RequestData) error
func replyCommentTask(userData types.LoginStatusData, commentConfig api.CommentConfig, data utils.RequestData) error {
replyToID := commentConfig.CommentID
failedTimes := 0
- for i := 0; i < 5; {
+ for i := 0; i < 2; {
if failedTimes >= 5 {
return fmt.Errorf("[%s] 回复评论累计 %d 次失败, 已自动退出", userData.Profile.Nickname, failedTimes)
}
@@ -412,7 +435,7 @@ func replyCommentTask(userData types.LoginStatusData, commentConfig api.CommentC
func sendMsgTask(userData types.LoginStatusData, userIDs []int, data utils.RequestData) error {
failedTimes := 0
- for i := 0; i < 5; {
+ for i := 0; i < 2; {
if failedTimes >= 5 {
return fmt.Errorf("[%s] 发送私信累计 %d 次失败, 已自动退出, 是不是工具人把你拉黑了(", userData.Profile.Nickname, failedTimes)
}
@@ -545,29 +568,54 @@ func checkCloudBean(userData types.LoginStatusData, data utils.RequestData) ([]i
}
log.Printf("[%s] 账号当前云豆数: %d", userData.Profile.Nickname, cloudBeanData.Data.CloudBean)
log.Printf("[%s] 获取音乐人任务中...", userData.Profile.Nickname)
- tasksData, err := api.GetMusicianTasks(data)
+ dailyTasks, err := api.GetMusicianDailyTasks(data)
+ if err != nil {
+ return []int{}, err
+ }
+ weeklyTasks, err := api.GetMusicianWeeklyTasks(data)
if err != nil {
return []int{}, err
}
var isObtainCloudBean bool
var autoTasks []int
- for i := 0; i < len(tasksData.Data.List); i++ {
- if tasksData.Data.List[i].Status == 20 {
- log.Printf("[%s] 「%s」任务已完成, 正在领取云豆", userData.Profile.Nickname, tasksData.Data.List[i].Description)
+ for _, task := range dailyTasks.Data.List {
+ if task.Status == 20 {
+ log.Printf("[%s] 「%s」任务已完成, 正在领取云豆", userData.Profile.Nickname, task.Description)
isObtainCloudBean = true
- result, err := api.ObtainCloudbean(data, tasksData.Data.List[i].UserMissionId, tasksData.Data.List[i].Period)
+ result, err := api.ObtainCloudbean(data, task.UserMissionId, task.Period)
if err != nil {
log.Errorln(err)
}
if result.Code == 200 {
- log.Printf("[%s] 领取「%s」任务云豆成功", userData.Profile.Nickname, tasksData.Data.List[i].Description)
+ log.Printf("[%s] 领取「%s」任务云豆成功, 云豆+%s", userData.Profile.Nickname, task.Description, task.RewardWorth)
} else {
- log.Errorf("[%s] 领取「%s」任务云豆失败: %s", userData.Profile.Nickname, tasksData.Data.List[i].Description, result.Message)
+ log.Errorf("[%s] 领取「%s」任务云豆失败: %s", userData.Profile.Nickname, task.Description, result.Message)
+ }
+ } else if autoTaskAvail(task.MissionId) && task.Status != 100 {
+ log.Printf("[%s] 任务「%s」任务未完成或进行中", userData.Profile.Nickname, task.Description)
+ autoTasks = append(autoTasks, task.MissionId)
+ }
+ }
+ for _, task := range weeklyTasks.Data.List {
+ for _, s := range task.UserStageTargetList {
+ if s.Status == 20 {
+ log.Printf("[%s] 「%s」任务已完成, 正在领取云豆", userData.Profile.Nickname, task.Description)
+ isObtainCloudBean = true
+ if s.UserMissionId != 0 {
+ result, err := api.ObtainCloudbean(data, int(s.UserMissionId), task.Period)
+ if err != nil {
+ log.Errorln(err)
+ }
+ if result.Code == 200 {
+ log.Printf("[%s] 领取「%s」任务云豆成功, 云豆+%d", userData.Profile.Nickname, task.Description, s.Worth)
+ } else {
+ log.Errorf("[%s] 领取「%s」任务云豆失败: %s", userData.Profile.Nickname, task.Description, result.Message)
+ }
+ }
+ } else if autoTaskAvail(task.MissionId) && task.Status != 100 {
+ log.Printf("[%s] 任务「%s」任务未完成或进行中", userData.Profile.Nickname, task.Description)
+ autoTasks = append(autoTasks, task.MissionId)
}
- }
- if autoTaskAvail(tasksData.Data.List[i].MissionId) && tasksData.Data.List[i].Status != 100 && tasksData.Data.List[i].Status != 20 {
- log.Printf("[%s] 任务「%s」任务未完成或进行中", userData.Profile.Nickname, tasksData.Data.List[i].Description)
- autoTasks = append(autoTasks, tasksData.Data.List[i].MissionId)
}
}
if isObtainCloudBean {
@@ -605,8 +653,25 @@ func checkPathExists(path string) bool {
return false
}
+func parseCircleID(artistDetail types.ArtistDetailData) {
+ for _, d := range artistDetail.Data.Blocks {
+ if d.Code == "PERSONAL_MY_CIRCLE" {
+ for _, creative := range d.Creatives {
+ for _, r := range creative.Resources {
+ if r.ResourceType != nil && r.ResourceId != nil {
+ if *r.ResourceType == "CIRCLE" && *r.ResourceId != "" {
+ circleID = *r.ResourceId
+ return
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
func autoTaskAvail(val int) bool {
- availAutoTasks := []int{135000, 399000, 398000, 393001, 395002, 396002}
+ availAutoTasks := []int{135000, 399000, 398000, 393001, 395002, 396002, 755000, 740005}
for i := 0; i < len(availAutoTasks); i++ {
if val == availAutoTasks[i] {
return true
From 37f48adbe597274ddeb24675e12e314762b0e298 Mon Sep 17 00:00:00 2001
From: xmxx
Date: Sun, 13 Mar 2022 01:16:24 +0800
Subject: [PATCH 04/17] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BB=E5=88=9B?=
=?UTF-8?q?=E8=AF=B4=E4=BB=BB=E5=8A=A1=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=94=AF?=
=?UTF-8?q?=E6=8C=81=E8=AE=BF=E9=97=AE=E4=BA=91=E5=9C=88=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
main.go | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/main.go b/main.go
index 7f74135..fec2a5a 100644
--- a/main.go
+++ b/main.go
@@ -238,7 +238,7 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
}
}()
switch autoTasks[i] {
- case 399000:
+ case 749006:
log.Printf("[%s] 执行音乐人签到任务中", userData.Profile.Nickname)
result, err := api.MusicianSign(data)
if err != nil {
@@ -249,14 +249,14 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
} else {
log.Printf("[%s] 音乐人签到失败: %s", userData.Profile.Nickname, result.Message)
}
- case 398000:
+ case 740004:
log.Printf("[%s] 执行发送动态任务中", userData.Profile.Nickname)
err := sendEventTask(userData, data)
if err != nil {
log.Println(err)
}
log.Printf("[%s] 发送动态任务执行完成", userData.Profile.Nickname)
- case 393001:
+ case 732004:
log.Printf("[%s] 执行回复评论任务中", userData.Profile.Nickname)
commentConfig := api.CommentConfig{
ResType: api.ResTypeMusic,
@@ -269,14 +269,14 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
log.Println(err)
}
log.Printf("[%s] 发送回复评论执行完成", userData.Profile.Nickname)
- case 395002:
+ case 755001:
log.Printf("[%s] 执行发送私信任务中", userData.Profile.Nickname)
err := sendMsgTask(userData, config.SendMsgConfig.UserID[processingUser], data)
if err != nil {
log.Println(err)
}
log.Printf("[%s] 发送私信任务执行完成", userData.Profile.Nickname)
- case 135000:
+ case 744005:
log.Printf("[%s] 执行发送 Mlog 任务中", userData.Profile.Nickname)
err := sendMlogTask(userData, data)
if err != nil {
@@ -671,7 +671,7 @@ func parseCircleID(artistDetail types.ArtistDetailData) {
}
func autoTaskAvail(val int) bool { //
- availAutoTasks := []int{135000, 399000, 398000, 393001, 395002, 396002, 755000, 740005}
+ availAutoTasks := []int{740004, 744005, 732004, 755001, 749006, 755000, 740005}
for i := 0; i < len(availAutoTasks); i++ {
if val == availAutoTasks[i] {
return true
From d72a16e8668dd4249cf454387b022e5cc67ae067 Mon Sep 17 00:00:00 2001
From: xmxx
Date: Sat, 9 Apr 2022 10:33:45 +0800
Subject: [PATCH 05/17] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?=
=?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BB=BB=E5=8A=A1=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
go.mod | 2 +-
go.sum | 4 ++--
main.go | 71 +++++++++++++++++++++++++++------------------------------
3 files changed, 37 insertions(+), 40 deletions(-)
diff --git a/go.mod b/go.mod
index 8423a55..b55c1c8 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/XiaoMengXinX/Fuck163MusicTasks/v2
go 1.17
require (
- github.com/XiaoMengXinX/Music163Api-Go v0.1.24
+ github.com/XiaoMengXinX/Music163Api-Go v0.1.25
github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.8.1
)
diff --git a/go.sum b/go.sum
index 585ced9..08e5a76 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-github.com/XiaoMengXinX/Music163Api-Go v0.1.24 h1:tz4c4R8yVJTi8zVdGA7PsBXXU4YmT9iUE7dQjE53Jy8=
-github.com/XiaoMengXinX/Music163Api-Go v0.1.24/go.mod h1:kLU/CkLxKnEJFCge0URvQ0lHt6ImoG1/2aVeNbgV2RQ=
+github.com/XiaoMengXinX/Music163Api-Go v0.1.25 h1:Wli9RTuNTad73cKqLtYQdd1u7B+2MCTNSXF47nlPOXE=
+github.com/XiaoMengXinX/Music163Api-Go v0.1.25/go.mod h1:kLU/CkLxKnEJFCge0URvQ0lHt6ImoG1/2aVeNbgV2RQ=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
diff --git a/main.go b/main.go
index fec2a5a..3655da2 100644
--- a/main.go
+++ b/main.go
@@ -4,11 +4,6 @@ import (
"encoding/json"
"flag"
"fmt"
- "github.com/XiaoMengXinX/Music163Api-Go/api"
- "github.com/XiaoMengXinX/Music163Api-Go/types"
- "github.com/XiaoMengXinX/Music163Api-Go/utils"
- "github.com/robfig/cron/v3"
- log "github.com/sirupsen/logrus"
"io"
"io/ioutil"
"math/rand"
@@ -17,6 +12,12 @@ import (
"runtime"
"strings"
"time"
+
+ "github.com/XiaoMengXinX/Music163Api-Go/api"
+ "github.com/XiaoMengXinX/Music163Api-Go/types"
+ "github.com/XiaoMengXinX/Music163Api-Go/utils"
+ "github.com/robfig/cron/v3"
+ log "github.com/sirupsen/logrus"
)
// LogFormatter 自定义 log 格式
@@ -202,7 +203,7 @@ func autoTasks(userData types.LoginStatusData, data utils.RequestData) error {
return err
}
if strings.Contains(userDetail.CurrentExpert.RoleName, "网易音乐人") {
- artistDetail, err := api.GetArtistDetail(data, int64(userDetail.Profile.ArtistId))
+ artistDetail, err := api.GetArtistHomepage(data, int64(userDetail.Profile.ArtistId))
parseCircleID(artistDetail)
autoTasks, err := checkCloudBean(userData, data)
if err != nil {
@@ -230,15 +231,15 @@ func autoTasks(userData types.LoginStatusData, data utils.RequestData) error {
return nil
}
-func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoTasks []int, i int) {
+func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoTasks []string, i int) {
defer func() {
err := recover()
if err != nil {
log.Errorln(err)
}
}()
- switch autoTasks[i] {
- case 749006:
+ switch {
+ case strings.Contains(autoTasks[i], "签到"):
log.Printf("[%s] 执行音乐人签到任务中", userData.Profile.Nickname)
result, err := api.MusicianSign(data)
if err != nil {
@@ -249,14 +250,14 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
} else {
log.Printf("[%s] 音乐人签到失败: %s", userData.Profile.Nickname, result.Message)
}
- case 740004:
+ case strings.Contains(autoTasks[i], "动态"):
log.Printf("[%s] 执行发送动态任务中", userData.Profile.Nickname)
err := sendEventTask(userData, data)
if err != nil {
log.Println(err)
}
log.Printf("[%s] 发送动态任务执行完成", userData.Profile.Nickname)
- case 732004:
+ case strings.Contains(autoTasks[i], "评论"):
log.Printf("[%s] 执行回复评论任务中", userData.Profile.Nickname)
commentConfig := api.CommentConfig{
ResType: api.ResTypeMusic,
@@ -269,21 +270,21 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
log.Println(err)
}
log.Printf("[%s] 发送回复评论执行完成", userData.Profile.Nickname)
- case 755001:
+ case strings.Contains(autoTasks[i], "私信"):
log.Printf("[%s] 执行发送私信任务中", userData.Profile.Nickname)
err := sendMsgTask(userData, config.SendMsgConfig.UserID[processingUser], data)
if err != nil {
log.Println(err)
}
log.Printf("[%s] 发送私信任务执行完成", userData.Profile.Nickname)
- case 744005:
+ case strings.Contains(autoTasks[i], "mlog"):
log.Printf("[%s] 执行发送 Mlog 任务中", userData.Profile.Nickname)
err := sendMlogTask(userData, data)
if err != nil {
log.Println(err)
}
log.Printf("[%s] 发送 Mlog 任务执行完成", userData.Profile.Nickname)
- case 755000:
+ case strings.Contains(autoTasks[i], "主创说"):
log.Printf("[%s] 执行发送主创说任务中", userData.Profile.Nickname)
commentConfig := api.CommentConfig{
ResType: api.ResTypeMusic,
@@ -295,7 +296,7 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
log.Println(err)
}
log.Printf("[%s] 发送主创说任务执行完成", userData.Profile.Nickname)
- case 740005:
+ case strings.Contains(autoTasks[i], "云圈"):
log.Printf("[%s] 执行访问云圈任务中", userData.Profile.Nickname)
err := getCircleTask(data)
if err != nil {
@@ -561,23 +562,23 @@ func vipGrowthpointTask(userData types.LoginStatusData, data utils.RequestData)
return err
}
-func checkCloudBean(userData types.LoginStatusData, data utils.RequestData) ([]int, error) {
+func checkCloudBean(userData types.LoginStatusData, data utils.RequestData) ([]string, error) {
cloudBeanData, err := api.GetCloudbeanNum(data)
if err != nil {
- return []int{}, err
+ return nil, err
}
log.Printf("[%s] 账号当前云豆数: %d", userData.Profile.Nickname, cloudBeanData.Data.CloudBean)
log.Printf("[%s] 获取音乐人任务中...", userData.Profile.Nickname)
dailyTasks, err := api.GetMusicianDailyTasks(data)
if err != nil {
- return []int{}, err
+ return nil, err
}
weeklyTasks, err := api.GetMusicianWeeklyTasks(data)
if err != nil {
- return []int{}, err
+ return nil, err
}
var isObtainCloudBean bool
- var autoTasks []int
+ var autoTasks []string
for _, task := range dailyTasks.Data.List {
if task.Status == 20 {
log.Printf("[%s] 「%s」任务已完成, 正在领取云豆", userData.Profile.Nickname, task.Description)
@@ -591,9 +592,9 @@ func checkCloudBean(userData types.LoginStatusData, data utils.RequestData) ([]i
} else {
log.Errorf("[%s] 领取「%s」任务云豆失败: %s", userData.Profile.Nickname, task.Description, result.Message)
}
- } else if autoTaskAvail(task.MissionId) && task.Status != 100 {
+ } else if autoTaskAvail(task.Description) && task.Status != 100 {
log.Printf("[%s] 任务「%s」任务未完成或进行中", userData.Profile.Nickname, task.Description)
- autoTasks = append(autoTasks, task.MissionId)
+ autoTasks = append(autoTasks, task.Description)
}
}
for _, task := range weeklyTasks.Data.List {
@@ -612,9 +613,9 @@ func checkCloudBean(userData types.LoginStatusData, data utils.RequestData) ([]i
log.Errorf("[%s] 领取「%s」任务云豆失败: %s", userData.Profile.Nickname, task.Description, result.Message)
}
}
- } else if autoTaskAvail(task.MissionId) && task.Status != 100 {
+ } else if autoTaskAvail(task.Description) && task.Status != 100 {
log.Printf("[%s] 任务「%s」任务未完成或进行中", userData.Profile.Nickname, task.Description)
- autoTasks = append(autoTasks, task.MissionId)
+ autoTasks = append(autoTasks, task.Description)
}
}
}
@@ -622,7 +623,7 @@ func checkCloudBean(userData types.LoginStatusData, data utils.RequestData) ([]i
time.Sleep(time.Duration(10) * time.Second)
cloudBeanData, err = api.GetCloudbeanNum(data)
if err != nil {
- return []int{}, err
+ return nil, err
}
log.Printf("[%s] 账号当前云豆数: %d", userData.Profile.Nickname, cloudBeanData.Data.CloudBean)
}
@@ -653,29 +654,25 @@ func checkPathExists(path string) bool {
return false
}
-func parseCircleID(artistDetail types.ArtistDetailData) {
+func parseCircleID(artistDetail types.ArtistHomepageData) {
for _, d := range artistDetail.Data.Blocks {
if d.Code == "PERSONAL_MY_CIRCLE" {
for _, creative := range d.Creatives {
for _, r := range creative.Resources {
- if r.ResourceType != nil && r.ResourceId != nil {
- if *r.ResourceType == "CIRCLE" && *r.ResourceId != "" {
- circleID = *r.ResourceId
- return
- }
+ if r.ResourceType == "CIRCLE" && r.ResourceId != "" {
+ circleID = r.ResourceId
+ return
}
+
}
}
}
}
}
-func autoTaskAvail(val int) bool { //
- availAutoTasks := []int{740004, 744005, 732004, 755001, 749006, 755000, 740005}
- for i := 0; i < len(availAutoTasks); i++ {
- if val == availAutoTasks[i] {
- return true
- }
+func autoTaskAvail(val string) bool {
+ if strings.Contains(val, "签到") || strings.Contains(val, "动态") || strings.Contains(val, "评论") || strings.Contains(val, "私信") || strings.Contains(val, "mlog") || strings.Contains(val, "主创说") || strings.Contains(val, "云圈") {
+ return true
}
return false
}
From 1c3a2cd42958cab5152983399fddd020c548bdcd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Wed, 13 Apr 2022 22:04:18 +0800
Subject: [PATCH 06/17] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 3c3fe09..9d0fbad 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,8 @@
+## 不支持云函数
+
## ✨ 特性
- web/Android 双平台每日签到
From ea34c403aa00ea8fd2ceac6eaa42fe3211415f49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Wed, 13 Apr 2022 22:07:51 +0800
Subject: [PATCH 07/17] Update README.md
---
README.md | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 9d0fbad..9f06c4e 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,11 @@
-## 不支持云函数
+## 本项目不支持云函数
+
+## 提问前请确保已阅读README文档
+
+## [提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md)
## ✨ 特性
From 22283f0b26803a8867d3c8ae97dadbf77bac4e2b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Wed, 13 Apr 2022 22:08:28 +0800
Subject: [PATCH 08/17] Update README.md
---
README.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 9f06c4e..dc38181 100644
--- a/README.md
+++ b/README.md
@@ -15,9 +15,7 @@
## 本项目不支持云函数
-## 提问前请确保已阅读README文档
-
-## [提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md)
+## 提问前请确保已阅读READhttps://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md#%E5%9C%A8%E6%8F%90%E9%97%AE%E4%B9%8B%E5%89%8D)
## ✨ 特性
From 0d7b801dcd3cfd23904b0879c9b3ac26f3f9ca9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Wed, 13 Apr 2022 22:09:00 +0800
Subject: [PATCH 09/17] Update README.md
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index dc38181..e1bf74e 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,9 @@
## 本项目不支持云函数
-## 提问前请确保已阅读READhttps://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md#%E5%9C%A8%E6%8F%90%E9%97%AE%E4%B9%8B%E5%89%8D)
+## 提问前请确保已阅读README文档
+
+## [提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md#%E5%9C%A8%E6%8F%90%E9%97%AE%E4%B9%8B%E5%89%8D)
## ✨ 特性
From d5beccb554e41913c9e818e155817e55718cef86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Sat, 16 Apr 2022 01:04:33 +0800
Subject: [PATCH 10/17] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e1bf74e..e857f35 100644
--- a/README.md
+++ b/README.md
@@ -89,7 +89,7 @@ $ ./Fuck163MusicTasks
{
"Cookies": [ // 至少填入一个用户的 MUSIC_U, 支持多用户及多 Cookie
{
- "Name": "MUSIC_U",
+ "Name": "MUSIC_U", // 不要修改此字段
"Value": "USER_1_MUSIC_U"
}
]
From 02b1341452dd685573a4bc4f44ba72fb7a55d185 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Thu, 21 Apr 2022 00:06:19 +0800
Subject: [PATCH 11/17] Update README.md
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index e857f35..7ffc851 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,10 @@
## [提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md#%E5%9C%A8%E6%8F%90%E9%97%AE%E4%B9%8B%E5%89%8D)
+## 提issue前请先看看别人的issue里有没有你的问题
+
+## 重复提issue以及乱提issue的直接close
+
## ✨ 特性
- web/Android 双平台每日签到
From ab2c76d8698143ee71d631d668ec46c16c21bf9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Thu, 21 Apr 2022 00:11:58 +0800
Subject: [PATCH 12/17] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 7ffc851..dfb30f5 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,8 @@
## [提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md#%E5%9C%A8%E6%8F%90%E9%97%AE%E4%B9%8B%E5%89%8D)
+## 二维码无法扫描的问题见 https://github.com/XiaoMengXinX/Fuck163MusicTasks/issues/17
+
## 提issue前请先看看别人的issue里有没有你的问题
## 重复提issue以及乱提issue的直接close
From 4cac5014ccc7becc22dea2a8e3db482bf7c420ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?lz=E5=B7=B2=E7=BB=8F=E6=98=AF=E6=9D=A1=E5=92=B8=E9=B1=BC?=
=?UTF-8?q?=E4=BA=86?=
Date: Wed, 4 May 2022 00:12:49 +0800
Subject: [PATCH 13/17] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index dfb30f5..87d0b28 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,8 @@
## 重复提issue以及乱提issue的直接close
+## TG交流群 [@Music163_gruop](https://t.me/Music163_group)
+
## ✨ 特性
- web/Android 双平台每日签到
From 37ae57918eb23293d190c83892639d149d9a4357 Mon Sep 17 00:00:00 2001
From: XiaoMengXinX
Date: Sun, 17 Jul 2022 22:29:35 +0800
Subject: [PATCH 14/17] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8?=
=?UTF-8?q?=E5=AE=8C=E6=88=90=E3=80=8C=E5=9C=A8=E5=8A=A8=E6=80=81=E5=88=86?=
=?UTF-8?q?=E4=BA=AB=E6=AD=8C=E6=9B=B2=E3=80=8D=E3=80=81=E3=80=8C=E5=88=86?=
=?UTF-8?q?=E4=BA=AB=E8=87=AA=E5=B7=B1=E7=9A=84=E6=AD=8C=E6=9B=B2=E3=80=8D?=
=?UTF-8?q?=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 3 +++
config_example.json | 3 +++
go.mod | 2 +-
go.sum | 4 ++--
main.go | 47 ++++++++++++++++++++++++++++++++++++++++++++-
types.go | 3 +++
6 files changed, 58 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 3c3fe09..b6f98b6 100644
--- a/README.md
+++ b/README.md
@@ -97,6 +97,9 @@ $ ./Fuck163MusicTasks
]
}
],
+ "MusicShareConfig": { // 分享音乐配置
+ "MySongID": 114514 // 填入任意一首音乐人名下的歌曲ID
+ },
"EventSendConfig": { // 发送动态配置
"LagConfig": { // 延时配置,若要完全关闭延时,请将 RandomLag 设为 false,并将 DefaultLag 设为 0
"RandomLag": true, // 是否开启随机延时
diff --git a/config_example.json b/config_example.json
index 63376ef..13de3c0 100644
--- a/config_example.json
+++ b/config_example.json
@@ -18,6 +18,9 @@
]
}
],
+ "MusicShareConfig": {
+ "MySongID": 114514
+ },
"EventSendConfig": {
"LagConfig": {
"RandomLag": true,
diff --git a/go.mod b/go.mod
index b55c1c8..38d47d9 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/XiaoMengXinX/Fuck163MusicTasks/v2
go 1.17
require (
- github.com/XiaoMengXinX/Music163Api-Go v0.1.25
+ github.com/XiaoMengXinX/Music163Api-Go v0.1.29
github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.8.1
)
diff --git a/go.sum b/go.sum
index 08e5a76..cb9d890 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-github.com/XiaoMengXinX/Music163Api-Go v0.1.25 h1:Wli9RTuNTad73cKqLtYQdd1u7B+2MCTNSXF47nlPOXE=
-github.com/XiaoMengXinX/Music163Api-Go v0.1.25/go.mod h1:kLU/CkLxKnEJFCge0URvQ0lHt6ImoG1/2aVeNbgV2RQ=
+github.com/XiaoMengXinX/Music163Api-Go v0.1.29 h1:c7ekfgo4qgEJ3Wjm9rMhGm7ggN8XqbD1idQka4unJ+Q=
+github.com/XiaoMengXinX/Music163Api-Go v0.1.29/go.mod h1:kLU/CkLxKnEJFCge0URvQ0lHt6ImoG1/2aVeNbgV2RQ=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
diff --git a/main.go b/main.go
index 3655da2..99fd6e5 100644
--- a/main.go
+++ b/main.go
@@ -239,6 +239,13 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
}
}()
switch {
+ case strings.Contains(autoTasks[i], "分享"):
+ log.Printf("[%s] 执行分享音乐任务中", userData.Profile.Nickname)
+ err := shareMusicTask(userData, data)
+ if err != nil {
+ log.Println(err)
+ }
+ log.Printf("[%s] 分享音乐任务执行完成", userData.Profile.Nickname)
case strings.Contains(autoTasks[i], "签到"):
log.Printf("[%s] 执行音乐人签到任务中", userData.Profile.Nickname)
result, err := api.MusicianSign(data)
@@ -306,6 +313,44 @@ func musicianTasks(userData types.LoginStatusData, data utils.RequestData, autoT
}
}
+func shareMusicTask(userData types.LoginStatusData, data utils.RequestData) error {
+ shareResult, err := api.SongShare(data, config.MusicShareConfig.MySongID)
+ if err != nil {
+ return err
+ }
+ if shareResult.Code == 200 {
+ log.Printf("[%s] 分享音乐成功, 歌曲ID: %d", userData.Profile.Nickname, config.MusicShareConfig.MySongID)
+ } else {
+ log.Printf("[%s] 分享音乐失败, 原因: %s, 歌曲ID: %d", userData.Profile.Nickname, shareResult.Message, config.MusicShareConfig.MySongID)
+ }
+ sendResult, err := api.ShareResource(data, config.MusicShareConfig.MySongID, "song", "")
+ if err != nil {
+ return err
+ }
+ if sendResult.Code == 200 {
+ log.Printf("[%s] 发送歌曲分享动态成功, 动态ID: %d, 歌曲ID: %d", userData.Profile.Nickname, sendResult.Event.Id, config.MusicShareConfig.MySongID)
+ if config.EventSendConfig.LagConfig.LagBetweenSendAndDelete {
+ randomLag := eventLag.Get()
+ if randomLag != 0 {
+ log.Printf("[%s] 延时 %d 秒", userData.Profile.Nickname, randomLag)
+ time.Sleep(time.Duration(randomLag) * time.Second)
+ }
+ }
+ delResult, err := api.DelEvent(data, sendResult.Event.Id)
+ if err != nil {
+ return err
+ }
+ if delResult.Code != 200 {
+ log.Errorf("[%s] 删除动态失败, 动态ID: %d, 代码: %d, 原因: \"%s\"", userData.Profile.Nickname, sendResult.Event.Id, delResult.Code, delResult.Message)
+ } else {
+ log.Printf("[%s] 删除动态成功, 动态ID: %d", userData.Profile.Nickname, sendResult.Event.Id)
+ }
+ } else {
+ log.Errorf("[%s] 发送歌曲分享动态, 代码: %d, 原因: \"%s\"", userData.Profile.Nickname, sendResult.Code, sendResult.Message)
+ }
+ return nil
+}
+
func getCircleTask(data utils.RequestData) error {
if circleID != "" {
result, err := api.GetCircle(data, circleID)
@@ -671,7 +716,7 @@ func parseCircleID(artistDetail types.ArtistHomepageData) {
}
func autoTaskAvail(val string) bool {
- if strings.Contains(val, "签到") || strings.Contains(val, "动态") || strings.Contains(val, "评论") || strings.Contains(val, "私信") || strings.Contains(val, "mlog") || strings.Contains(val, "主创说") || strings.Contains(val, "云圈") {
+ if strings.Contains(val, "签到") || strings.Contains(val, "动态") || strings.Contains(val, "评论") || strings.Contains(val, "私信") || strings.Contains(val, "mlog") || strings.Contains(val, "主创说") || strings.Contains(val, "云圈") || strings.Contains(val, "分享") {
return true
}
return false
diff --git a/types.go b/types.go
index b77f306..72d1b16 100644
--- a/types.go
+++ b/types.go
@@ -10,6 +10,9 @@ type Config struct {
Users []struct {
Cookies []*http.Cookie `json:"Cookies"`
} `json:"Users"`
+ MusicShareConfig struct {
+ MySongID int `json:"MySongID"`
+ } `json:"MusicShareConfig"`
EventSendConfig struct {
LagConfig LagConfig `json:"LagConfig"`
} `json:"EventSendConfig"`
From f59b54368b22470d160adfcebc9aab022d503fdc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=B4=E6=B8=8A?= <1577242215@qq.com>
Date: Wed, 29 Mar 2023 21:54:16 +0800
Subject: [PATCH 15/17] =?UTF-8?q?=E6=96=B0=E5=A2=9EPushPlus=EF=BC=8Cserver?=
=?UTF-8?q?=E9=85=B1=E6=8E=A8=E9=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
main.go | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
types.go | 2 ++
2 files changed, 58 insertions(+)
diff --git a/main.go b/main.go
index 99fd6e5..f7e7bfe 100644
--- a/main.go
+++ b/main.go
@@ -1,12 +1,15 @@
package main
import (
+ "bytes"
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"math/rand"
+ "net/http"
+ "net/url"
"os"
"path"
"runtime"
@@ -38,6 +41,7 @@ var msgLag RandomNum
var mlogLag RandomNum
var processingUser int
var circleID string
+var pushMsg string
var configFileName = flag.String("c", "config.json", "Config filename") // 从 cli 参数读取配置文件名
var printVersion = flag.Bool("v", false, "Print version")
var isDEBUG = flag.Bool("d", false, "DEBUG mode")
@@ -128,6 +132,7 @@ Build ARCH: %s
startTasks()
startCron()
+ startPushMsg()
}
func startCron() {
@@ -187,6 +192,52 @@ func startTasks() {
}
}
+// 推送消息
+func startPushMsg() {
+ // PushPlus
+ if config.PushPlusToken != "" {
+ // 消息内容
+ content := fmt.Sprintf("网易云音乐自动任务已完成")
+ content += pushMsg
+ // 推送相关
+ data := url.Values{}
+ data.Set("token", config.PushPlusToken)
+ data.Set("title", "网易云音乐自动任务")
+ data.Set("content", content)
+ res, err := http.PostForm("http://www.pushplus.plus/send", data)
+ if err != nil {
+ log.Errorln(err)
+ }
+ defer res.Body.Close()
+ log.Println("PushPlus推送:", res.Status)
+ }
+ // Server酱
+ if config.ServerSendKey != "" {
+ sendUrl := fmt.Sprintf("https://sc.ftqq.com/%s.send", config.ServerSendKey)
+ // 消息内容
+ type Message struct {
+ Title string `json:"title"`
+ Desp string `json:"desp"`
+ }
+ title := fmt.Sprintf("网易云音乐自动任务")
+ content := fmt.Sprintf("网易云音乐自动任务已完成")
+ content += pushMsg
+ content = strings.ReplaceAll(content, "\n", "\n\n")
+ message := Message{
+ Title: title,
+ Desp: content,
+ }
+ messageJson, err := json.Marshal(message)
+ // 推送相关
+ res, err := http.Post(sendUrl, "application/json", bytes.NewReader(messageJson))
+ if err != nil {
+ log.Errorln(err)
+ }
+ defer res.Body.Close()
+ log.Println("Server酱推送:", res.Status)
+ }
+}
+
func autoTasks(userData types.LoginStatusData, data utils.RequestData) error {
defer func() {
err := recover()
@@ -373,6 +424,7 @@ func userSignTask(userData types.LoginStatusData, data utils.RequestData) error
log.Printf("[%s] %s (%s)", userData.Profile.Nickname, result.Msg, "Android")
} else {
log.Printf("[%s] 签到成功 (%s)", userData.Profile.Nickname, "Android")
+ pushMsg += fmt.Sprintf("\n[%s] 签到成功 (%s)", userData.Profile.Nickname, "Android")
}
result, err = api.UserSign(data, 1)
@@ -383,6 +435,7 @@ func userSignTask(userData types.LoginStatusData, data utils.RequestData) error
log.Printf("[%s] %s (%s)", userData.Profile.Nickname, result.Msg, "web/PC")
} else {
log.Printf("[%s] 签到成功 (%s)", userData.Profile.Nickname, "Android")
+ pushMsg += fmt.Sprintf("\n[%s] 签到成功 (%s)", userData.Profile.Nickname, "Android")
}
return nil
}
@@ -613,6 +666,7 @@ func checkCloudBean(userData types.LoginStatusData, data utils.RequestData) ([]s
return nil, err
}
log.Printf("[%s] 账号当前云豆数: %d", userData.Profile.Nickname, cloudBeanData.Data.CloudBean)
+ pushMsg += fmt.Sprintf("\n[%s] 当前云豆数: %d", userData.Profile.Nickname, cloudBeanData.Data.CloudBean)
log.Printf("[%s] 获取音乐人任务中...", userData.Profile.Nickname)
dailyTasks, err := api.GetMusicianDailyTasks(data)
if err != nil {
@@ -634,6 +688,7 @@ func checkCloudBean(userData types.LoginStatusData, data utils.RequestData) ([]s
}
if result.Code == 200 {
log.Printf("[%s] 领取「%s」任务云豆成功, 云豆+%s", userData.Profile.Nickname, task.Description, task.RewardWorth)
+ pushMsg += fmt.Sprintf("\n[%s] 完成「%s」任务云豆+%s", userData.Profile.Nickname, task.Description, task.RewardWorth)
} else {
log.Errorf("[%s] 领取「%s」任务云豆失败: %s", userData.Profile.Nickname, task.Description, result.Message)
}
@@ -654,6 +709,7 @@ func checkCloudBean(userData types.LoginStatusData, data utils.RequestData) ([]s
}
if result.Code == 200 {
log.Printf("[%s] 领取「%s」任务云豆成功, 云豆+%d", userData.Profile.Nickname, task.Description, s.Worth)
+ pushMsg += fmt.Sprintf("\n[%s] 完成「%s」任务云豆+%d", userData.Profile.Nickname, task.Description, s.Worth)
} else {
log.Errorf("[%s] 领取「%s」任务云豆失败: %s", userData.Profile.Nickname, task.Description, result.Message)
}
diff --git a/types.go b/types.go
index 72d1b16..b13afc6 100644
--- a/types.go
+++ b/types.go
@@ -40,6 +40,8 @@ type Config struct {
EnableLag bool `json:"EnableLag"`
LagConfig LagConfig `json:"LagConfig"`
} `json:"Cron"`
+ PushPlusToken string `json:"PushPlusToken"`
+ ServerSendKey string `json:"ServerSendKey"`
}
// LagConfig 延迟设置
From 4ee2dba4b39b8ba59573cd57c3030f15f4766c5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=B4=E6=B8=8A?= <1577242215@qq.com>
Date: Wed, 29 Mar 2023 21:55:18 +0800
Subject: [PATCH 16/17] =?UTF-8?q?=E6=96=B0=E5=A2=9EPushPlus=EF=BC=8Cserver?=
=?UTF-8?q?=E9=85=B1=E6=8E=A8=E9=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config_example.json | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/config_example.json b/config_example.json
index 13de3c0..b56b005 100644
--- a/config_example.json
+++ b/config_example.json
@@ -86,5 +86,7 @@
"LagMin": 600,
"LagMax": 3600
}
- }
+ },
+ "PushPlusToken": "",
+ "ServerSendKey": ""
}
\ No newline at end of file
From dcef1d3a797d70ed40841c800518097e4bdf2261 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=B4=E6=B8=8A?= <1577242215@qq.com>
Date: Wed, 29 Mar 2023 21:57:34 +0800
Subject: [PATCH 17/17] =?UTF-8?q?=E6=96=B0=E5=A2=9EPushPlus=EF=BC=8Cserver?=
=?UTF-8?q?=E9=85=B1=E6=8E=A8=E9=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 090735e..a54080f 100644
--- a/README.md
+++ b/README.md
@@ -180,7 +180,9 @@ $ ./Fuck163MusicTasks
"LagMin": 600,
"LagMax": 3600
}
- }
+ },
+ "PushPlusToken": "", // PushPlus Token, 用于推送运行日志(随便填一个就好)
+ "ServerSendKey": "" // Server酱 SendKey
}
```