Skip to content

Commit

Permalink
[Feat] Update package for other dependency (#28)
Browse files Browse the repository at this point in the history
Fixes #27
  • Loading branch information
ThreeCatsLoveFish authored Jul 23, 2022
1 parent 7384b43 commit 97fc995
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 44 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
</p>
<div align="center">
<h1> 最新 B 站粉丝牌助手</h1>
<p>当前版本:1.3</p>
<p>当前版本:1.4</p>
</div>

### 功能说明

- 每日直播区签到
- 每日观看 30 分钟
- 每日点赞 3 次直播间 (200\*3 亲密度)
- 每日分享 5 次直播间 (100\*5 亲密度)
- 每日观看 80 分钟 (100 亲密度 / 5min)
- 每日点赞 1 次直播间 (100 亲密度)
- 每日自定义弹幕打卡 (100 亲密度)
- 弹幕打卡前自动佩戴勋章
- 可选需要的打卡类型
Expand All @@ -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

### 友情链接

Expand Down
10 changes: 8 additions & 2 deletions Usage.md
Original file line number Diff line number Diff line change
@@ -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 用户

Expand Down Expand Up @@ -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" # 推送名称,对应上面对应用户的推送,请保证名称唯一
Expand Down
11 changes: 4 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
module MedalHelper
module github.com/ThreeCatsLoveFish/medalhelper

go 1.16

require github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f

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
)
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package main

import (
"MedalHelper/service"
"MedalHelper/service/push"
"MedalHelper/util"
"fmt"
"os"
"strconv"
"strings"
"sync"
"time"

"github.com/ThreeCatsLoveFish/medalhelper/service"
"github.com/ThreeCatsLoveFish/medalhelper/service/push"
"github.com/ThreeCatsLoveFish/medalhelper/util"

"github.com/robfig/cron"
)

Expand All @@ -21,7 +22,7 @@ func init() {
}

func logo() {
fmt.Print(`
fmt.Print(`
__ __ __ __ __ __ __
| \ / \ | \ | \ | \ | \ | \
| ▓▓\ / ▓▓ ______ ____| ▓▓ ______ | ▓▓ | ▓▓ | ▓▓ ______ | ▓▓ ______ ______ ______
Expand Down
5 changes: 3 additions & 2 deletions manager/api.go
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
17 changes: 9 additions & 8 deletions service/action.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions service/async.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand Down
3 changes: 2 additions & 1 deletion service/interface.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package service

import (
"MedalHelper/dto"
"sync"

"github.com/ThreeCatsLoveFish/medalhelper/dto"
)

type IConcurrency interface {
Expand Down
2 changes: 1 addition & 1 deletion service/push/base.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package push

import "MedalHelper/util"
import "github.com/ThreeCatsLoveFish/medalhelper/util"

var pushMap map[string]Push

Expand Down
5 changes: 3 additions & 2 deletions service/push/push_deer.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 3 additions & 2 deletions service/push/push_plus.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 2 additions & 1 deletion service/push/push_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package push

import (
"MedalHelper/util"
"testing"

"github.com/ThreeCatsLoveFish/medalhelper/util"
)

func TestPushDeerPush(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions service/push/telegram.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
9 changes: 5 additions & 4 deletions service/user.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" # 推送名称,对应上面对应用户的推送,请保证名称唯一
Expand Down
15 changes: 15 additions & 0 deletions util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 97fc995

Please sign in to comment.