From 97fc9954a7377c229dc7b703b72059389efc819d Mon Sep 17 00:00:00 2001
From: Zhimin Sun <121097854@qq.com>
Date: Sat, 23 Jul 2022 13:06:07 +0800
Subject: [PATCH] [Feat] Update package for other dependency (#28)
Fixes #27
---
README.md | 8 +++-----
Usage.md | 10 ++++++++--
go.mod | 11 ++++-------
go.sum | 14 ++++++++++++++
main.go | 9 +++++----
manager/api.go | 5 +++--
service/action.go | 17 +++++++++--------
service/async.go | 5 +++--
service/interface.go | 3 ++-
service/push/base.go | 2 +-
service/push/push_deer.go | 5 +++--
service/push/push_plus.go | 5 +++--
service/push/push_test.go | 3 ++-
service/push/telegram.go | 5 +++--
service/user.go | 9 +++++----
users.yaml | 2 +-
util/config.go | 15 +++++++++++++++
17 files changed, 84 insertions(+), 44 deletions(-)
diff --git a/README.md b/README.md
index 5a9232b..e40e2ed 100644
--- a/README.md
+++ b/README.md
@@ -3,15 +3,14 @@
最新 B 站粉丝牌助手
-
当前版本:1.3
+
当前版本:1.4
### 功能说明
- 每日直播区签到
-- 每日观看 30 分钟
-- 每日点赞 3 次直播间 (200\*3 亲密度)
-- 每日分享 5 次直播间 (100\*5 亲密度)
+- 每日观看 80 分钟 (100 亲密度 / 5min)
+- 每日点赞 1 次直播间 (100 亲密度)
- 每日自定义弹幕打卡 (100 亲密度)
- 弹幕打卡前自动佩戴勋章
- 可选需要的打卡类型
@@ -28,7 +27,6 @@
[![wakatime](https://wakatime.com/badge/github/ThreeCatsLoveFish/MedalHelper.svg)](https://wakatime.com/badge/github/ThreeCatsLoveFish/MedalHelper)
具体使用方法请看[使用文档](Usage.md)
-add a pull request
### 友情链接
diff --git a/Usage.md b/Usage.md
index 9812d47..2d41f54 100644
--- a/Usage.md
+++ b/Usage.md
@@ -1,8 +1,14 @@
# 使用说明
+### GO项目下游依赖
+
+```bash
+go get github.com/ThreeCatsLoveFish/medalhelper
+```
+
### Windows 用户
-> Windows10以上用户请直接前往[免配置高速通道](https://github.com/ThreeCatsLoveFish/MedalHelper/releases/tag/v1.0)
+> Windows10以上用户请直接前往[免配置高速通道](https://github.com/ThreeCatsLoveFish/MedalHelper/releases/tag/v1.4)
### Docker 用户
@@ -135,7 +141,7 @@ CD:
retry: 1 # 任务失败重试时间,单位秒,设置为0不重试
max_try: 10 # 任务失败最多重试次数,单位次,设置为0不重试
like: 2 # 点赞间隔时间,单位秒,设置为0不点赞
- share: 5 # 分享间隔时间,单位秒,设置为0不分享
+ share: 5 # 【已废弃】分享间隔时间,单位秒,设置为0不分享
danmu: 6 # 弹幕间隔时间,单位秒,设置为0不发送弹幕,只支持同步
PUSH:
- name: "PUSH_PLUS_SAMPLE" # 推送名称,对应上面对应用户的推送,请保证名称唯一
diff --git a/go.mod b/go.mod
index beab317..dfdf368 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module MedalHelper
+module github.com/ThreeCatsLoveFish/medalhelper
go 1.16
@@ -6,15 +6,12 @@ require github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d
require (
github.com/TwiN/go-color v1.1.0
- github.com/gookit/config/v2 v2.1.0
- github.com/sethvargo/go-retry v0.2.3
-)
-
-require (
github.com/google/uuid v1.3.0
+ github.com/gookit/config/v2 v2.1.2
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/robfig/cron v1.2.0
+ github.com/sethvargo/go-retry v0.2.3
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
github.com/tidwall/gjson v1.14.1
- golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
+ golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
)
diff --git a/go.sum b/go.sum
index 8f7afd1..d8e2426 100644
--- a/go.sum
+++ b/go.sum
@@ -22,14 +22,21 @@ github.com/gookit/color v1.5.0 h1:1Opow3+BWDwqor78DcJkJCIwnkviFi+rrOANki9BUFw=
github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo=
github.com/gookit/config/v2 v2.1.0 h1:RNiT4tsAkDBP5QPhxGk/vEcQO4ET1xdRBd9BStL4G1E=
github.com/gookit/config/v2 v2.1.0/go.mod h1:2qFkfHkS7Aj4T1LaJh5jxejxhO34NM/eJj4/DY/C9Zs=
+github.com/gookit/config/v2 v2.1.2 h1:qPW58LTY8CTOnHFN9r9q2NU3jk+6UQ+JYWV6x2JepH4=
+github.com/gookit/config/v2 v2.1.2/go.mod h1:IPaiN75J82aoFsavbpK8SazWLQ0Y4QOYjucqA3ggiVM=
github.com/gookit/goutil v0.5.0 h1:SrbfjqZ8iprxJOfKZVT0yGJ4/82afr4Qa0RQwON19I4=
github.com/gookit/goutil v0.5.0/go.mod h1:pq1eTibwb2wN96jrci0xy7xogWzzo9CihOQJEAvz4yQ=
+github.com/gookit/goutil v0.5.2 h1:1IbfIUiRV+Y+5IdgBeb/O7hWvq8OnnP1+sB/Ua2Q6jE=
+github.com/gookit/goutil v0.5.2/go.mod h1:pq1eTibwb2wN96jrci0xy7xogWzzo9CihOQJEAvz4yQ=
github.com/gookit/ini/v2 v2.1.0 h1:L1qn8CfP1KYlbogKuMsJ3FiDdKDwvABCKeeuMWDlQzQ=
github.com/gookit/ini/v2 v2.1.0/go.mod h1:r06awbwBtIHxjA7ndqWJkRgCAvSG+5FdSGrrbGfigtY=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
+github.com/hashicorp/hcl/v2 v2.12.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
+github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
+github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@@ -46,6 +53,8 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
+github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
@@ -85,6 +94,8 @@ golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM=
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
+golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
+golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
@@ -121,3 +132,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/main.go b/main.go
index 83d9833..6f17147 100644
--- a/main.go
+++ b/main.go
@@ -1,9 +1,6 @@
package main
import (
- "MedalHelper/service"
- "MedalHelper/service/push"
- "MedalHelper/util"
"fmt"
"os"
"strconv"
@@ -11,6 +8,10 @@ import (
"sync"
"time"
+ "github.com/ThreeCatsLoveFish/medalhelper/service"
+ "github.com/ThreeCatsLoveFish/medalhelper/service/push"
+ "github.com/ThreeCatsLoveFish/medalhelper/util"
+
"github.com/robfig/cron"
)
@@ -21,7 +22,7 @@ func init() {
}
func logo() {
- fmt.Print(`
+ fmt.Print(`
__ __ __ __ __ __ __
| \ / \ | \ | \ | \ | \ | \
| ▓▓\ / ▓▓ ______ ____| ▓▓ ______ | ▓▓ | ▓▓ | ▓▓ ______ | ▓▓ ______ ______ ______
diff --git a/manager/api.go b/manager/api.go
index 0adb44f..99f50ed 100644
--- a/manager/api.go
+++ b/manager/api.go
@@ -1,13 +1,14 @@
package manager
import (
- "MedalHelper/dto"
- "MedalHelper/util"
"encoding/json"
"fmt"
"math/rand"
"strings"
"time"
+
+ "github.com/ThreeCatsLoveFish/medalhelper/dto"
+ "github.com/ThreeCatsLoveFish/medalhelper/util"
)
func LoginVerify(accessKey string) (dto.BiliAccountResp, error) {
diff --git a/service/action.go b/service/action.go
index 60168fd..d1033d8 100644
--- a/service/action.go
+++ b/service/action.go
@@ -1,10 +1,11 @@
package service
import (
- "MedalHelper/dto"
- "MedalHelper/manager"
- "MedalHelper/util"
"time"
+
+ "github.com/ThreeCatsLoveFish/medalhelper/dto"
+ "github.com/ThreeCatsLoveFish/medalhelper/manager"
+ "github.com/ThreeCatsLoveFish/medalhelper/util"
)
// Like implement IExec, sync like 3 times
@@ -16,7 +17,7 @@ func (Like) Do(user User, medal dto.MedalInfo) bool {
if util.GlobalConfig.CD.Like == 0 {
return true
}
- times := 3
+ times := 1
ticker := time.NewTicker(time.Duration(util.GlobalConfig.CD.Like) * time.Second)
for i := 0; i < times; i++ {
if ok := manager.LikeInteract(user.accessKey, medal.RoomInfo.RoomID); !ok {
@@ -48,7 +49,7 @@ func (ALike) Do(user User, medal dto.MedalInfo) bool {
if util.GlobalConfig.CD.Like == 0 {
return true
}
- times := 3
+ times := 1
for i := 0; i < times; i++ {
if ok := manager.LikeInteract(user.accessKey, medal.RoomInfo.RoomID); !ok {
return false
@@ -78,7 +79,7 @@ func (Share) Do(user User, medal dto.MedalInfo) bool {
if util.GlobalConfig.CD.Share == 0 {
return true
}
- times := 5
+ times := 1
ticker := time.NewTicker(time.Duration(util.GlobalConfig.CD.Share) * time.Second)
for i := 0; i < times; i++ {
if ok := manager.ShareRoom(user.accessKey, medal.RoomInfo.RoomID); !ok {
@@ -110,7 +111,7 @@ func (AShare) Do(user User, medal dto.MedalInfo) bool {
if util.GlobalConfig.CD.Share == 0 {
return true
}
- times := 5
+ times := 1
ticker := time.NewTicker(time.Duration(util.GlobalConfig.CD.Share) * time.Second)
for i := 0; i < times; i++ {
if ok := manager.ShareRoom(user.accessKey, medal.RoomInfo.RoomID); !ok {
@@ -188,7 +189,7 @@ func (WatchLive) Do(user User, medal dto.MedalInfo) bool {
); !ok {
return false
}
- user.info("%s 房间心跳包已发送(%d/%d)", medal.AnchorInfo.NickName, i + 1, times)
+ user.info("%s 房间心跳包已发送(%d/%d)", medal.AnchorInfo.NickName, i+1, times)
time.Sleep(1 * time.Minute)
}
return true
diff --git a/service/async.go b/service/async.go
index 599bafd..769635f 100644
--- a/service/async.go
+++ b/service/async.go
@@ -1,13 +1,14 @@
package service
import (
- "MedalHelper/dto"
- "MedalHelper/util"
"context"
"errors"
"sync"
"time"
+ "github.com/ThreeCatsLoveFish/medalhelper/dto"
+ "github.com/ThreeCatsLoveFish/medalhelper/util"
+
"github.com/sethvargo/go-retry"
)
diff --git a/service/interface.go b/service/interface.go
index 0c1efe7..de7ad0d 100644
--- a/service/interface.go
+++ b/service/interface.go
@@ -1,8 +1,9 @@
package service
import (
- "MedalHelper/dto"
"sync"
+
+ "github.com/ThreeCatsLoveFish/medalhelper/dto"
)
type IConcurrency interface {
diff --git a/service/push/base.go b/service/push/base.go
index 3f40037..38d1cde 100644
--- a/service/push/base.go
+++ b/service/push/base.go
@@ -1,6 +1,6 @@
package push
-import "MedalHelper/util"
+import "github.com/ThreeCatsLoveFish/medalhelper/util"
var pushMap map[string]Push
diff --git a/service/push/push_deer.go b/service/push/push_deer.go
index 2e69175..815aa5d 100644
--- a/service/push/push_deer.go
+++ b/service/push/push_deer.go
@@ -1,9 +1,10 @@
package push
import (
- "MedalHelper/manager"
- "MedalHelper/util"
"net/url"
+
+ "github.com/ThreeCatsLoveFish/medalhelper/manager"
+ "github.com/ThreeCatsLoveFish/medalhelper/util"
)
const PushDeerName string = "push_deer"
diff --git a/service/push/push_plus.go b/service/push/push_plus.go
index b1ee724..262e983 100644
--- a/service/push/push_plus.go
+++ b/service/push/push_plus.go
@@ -1,9 +1,10 @@
package push
import (
- "MedalHelper/manager"
- "MedalHelper/util"
"net/url"
+
+ "github.com/ThreeCatsLoveFish/medalhelper/manager"
+ "github.com/ThreeCatsLoveFish/medalhelper/util"
)
const PushPlusName string = "push_plus"
diff --git a/service/push/push_test.go b/service/push/push_test.go
index 53cf1c3..60d4a62 100644
--- a/service/push/push_test.go
+++ b/service/push/push_test.go
@@ -1,8 +1,9 @@
package push
import (
- "MedalHelper/util"
"testing"
+
+ "github.com/ThreeCatsLoveFish/medalhelper/util"
)
func TestPushDeerPush(t *testing.T) {
diff --git a/service/push/telegram.go b/service/push/telegram.go
index cbe6df3..565ecc9 100644
--- a/service/push/telegram.go
+++ b/service/push/telegram.go
@@ -1,10 +1,11 @@
package push
import (
- "MedalHelper/manager"
- "MedalHelper/util"
"fmt"
"net/url"
+
+ "github.com/ThreeCatsLoveFish/medalhelper/manager"
+ "github.com/ThreeCatsLoveFish/medalhelper/util"
)
const TelegramName string = "telegram"
diff --git a/service/user.go b/service/user.go
index 631597d..f5244d9 100644
--- a/service/user.go
+++ b/service/user.go
@@ -1,16 +1,17 @@
package service
import (
- "MedalHelper/dto"
- "MedalHelper/manager"
- "MedalHelper/service/push"
- "MedalHelper/util"
"context"
"errors"
"fmt"
"sync"
"time"
+ "github.com/ThreeCatsLoveFish/medalhelper/dto"
+ "github.com/ThreeCatsLoveFish/medalhelper/manager"
+ "github.com/ThreeCatsLoveFish/medalhelper/service/push"
+ "github.com/ThreeCatsLoveFish/medalhelper/util"
+
"github.com/TwiN/go-color"
"github.com/google/uuid"
"github.com/sethvargo/go-retry"
diff --git a/users.yaml b/users.yaml
index 638bdfb..212acba 100644
--- a/users.yaml
+++ b/users.yaml
@@ -39,7 +39,7 @@ CD:
retry: 1 # 任务失败重试时间,单位秒,设置为0不重试
max_try: 10 # 任务失败最多重试次数,单位次,设置为0不重试
like: 2 # 点赞间隔时间,单位秒,设置为0不点赞
- share: 5 # 分享间隔时间,单位秒,设置为0不分享
+ share: 5 # 【已废弃】分享间隔时间,单位秒,设置为0不分享
danmu: 6 # 弹幕间隔时间,单位秒,设置为0不发送弹幕,只支持同步
PUSH:
- name: "PUSH_DEER_SAMPLE" # 推送名称,对应上面对应用户的推送,请保证名称唯一
diff --git a/util/config.go b/util/config.go
index 695f97f..4e63dbe 100644
--- a/util/config.go
+++ b/util/config.go
@@ -52,3 +52,18 @@ func InitConfig() {
// Load config file
conf.BindStruct("", &GlobalConfig)
}
+
+// LoadConfig bind endpoints with config file
+func LoadConfig(filePath string) {
+ conf := config.NewWithOptions("push", func(opt *config.Options) {
+ opt.DecoderConfig.TagName = "yaml"
+ opt.ParseEnv = true
+ })
+ conf.AddDriver(yaml.Driver)
+ err := conf.LoadFiles(filePath)
+ if err != nil {
+ panic(err)
+ }
+ // Load config file
+ conf.BindStruct("", &GlobalConfig)
+}