Skip to content

Commit 1861e08

Browse files
committed
Merge branch 'dev'
2 parents 7525f8a + 9a71343 commit 1861e08

File tree

17 files changed

+418
-487
lines changed

17 files changed

+418
-487
lines changed

.github/workflows/release.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: release
2+
run-name: release
3+
concurrency:
4+
group: ci-${{ github.ref }}
5+
cancel-in-progress: true
6+
on:
7+
push:
8+
tags:
9+
- v*
10+
11+
env:
12+
GOPROXY: https://goproxy.buffge.com,direct
13+
CC: x86_64-w64-mingw32-gcc
14+
jobs:
15+
releaseApp:
16+
runs-on: arc-runner-set
17+
permissions:
18+
contents: write
19+
strategy:
20+
matrix:
21+
go-version: [ '1.23' ]
22+
steps:
23+
- name: Check out repository code
24+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
25+
- name: install go deps
26+
run: |
27+
go mod tidy
28+
- name: go build
29+
run: |
30+
export BUILD_USER='${{github.actor}}'
31+
make build
32+
- name: upx
33+
run: |
34+
make upx
35+
- name: package
36+
run: |
37+
mv bin hh-lol-prophet-${{ github.ref_name }}
38+
zip -r hh-lol-prophet-${{ github.ref_name }}.zip ./hh-lol-prophet-${{ github.ref_name }}
39+
mkdir release-package
40+
mv hh-lol-prophet-${{ github.ref_name }}.zip release-package
41+
mv hh-lol-prophet-${{ github.ref_name }}/hh-lol-prophet.exe release-package
42+
- name: upload release
43+
run: |
44+
s3cmd sync release-package/ s3://buff-pub/hh-lol-prophet/${{ github.ref_name }}/
45+
- name: generate tag message env
46+
run: |
47+
echo "TAG_MESSAGE=$(git tag -l --format='%(contents:subject)' ${{ github.ref_name }})" >> $GITHUB_ENV
48+
- name: Release
49+
uses: softprops/action-gh-release@v2
50+
with:
51+
body: ${{ github.env.TAG_MESSAGE }}
52+
files: |
53+
release-package/hh-lol-prophet-${{ github.ref_name }}.zip
54+
- uses: buffge/dingtalk-action@34743c736212579f8ff99d2dca75879b56371796
55+
if: ${{ success() }}
56+
env:
57+
DINGTALK_ACCESS_TOKEN: ${{ secrets.DINGTALK_ACCESS_TOKEN }}
58+
DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }}
59+
with:
60+
msgtype: markdown
61+
title: " hh-lol-propher 成功"
62+
text: |
63+
**<font color=#54aeff size=4>az-blog 构建成功</font>**
64+
65+
**<font size=4>commitMsg: ${{ github.event.head_commit.message }}</font>**
66+
- uses: buffge/dingtalk-action@34743c736212579f8ff99d2dca75879b56371796
67+
if: ${{ failure() }}
68+
env:
69+
DINGTALK_ACCESS_TOKEN: ${{ secrets.DINGTALK_ACCESS_TOKEN }}
70+
DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }}
71+
with:
72+
msgtype: markdown
73+
title: "hh-lol-propher 失败"
74+
text: |
75+
**<font color=#cf222e size=4>az-blog 构建失败</font>**
76+
77+
**<font size=4>commitMsg: ${{ github.event.head_commit.message }}</font>**

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ logs/
2121
#docs
2222
.vscode
2323
ttt.md
24-
*.db
24+
*.db
25+
cmd/dev
26+
bin

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
.PHONY: build mode upx doc
1+
.PHONY: default build mode upx doc
2+
23
GIT_COMMIT=`git rev-list -1 HEAD`
3-
BUILD_TIME=`date '+%Y-%m-%d_%H:%M:%S'`
4-
BUILD_USER=`whoami`
5-
export GOPROXY=https://goproxy.cn,direct
4+
BUILD_TIME=`date '+%Y-%m-%d_%H:%M:%S%z'`
5+
BUILD_USER?=`whoami`
6+
GOPROXY?=https://goproxy.cn,direct
7+
default: build
68
build: cmd/hh-lol-prophet/main.go
79
@CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -tags=jsoniter -ldflags "-s -w \
810
-X github.com/real-web-world/hh-lol-prophet.Commit=$(GIT_COMMIT) \
@@ -14,5 +16,4 @@ doc: cmd/hh-lol-prophet/main.go
1416
clean: bin/
1517
@rm -rf bin/hh-lol-prophet.exe
1618
upx : cmd/hh-lol-prophet/main.go
17-
make build
1819
upx -9 ./bin/hh-lol-prophet.exe

api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ func (api Api) QueryHorseBySummonerName(c *gin.Context) {
3838
return
3939
}
4040
summonerName := strings.TrimSpace(d.SummonerName)
41-
var summonerID int64 = 0
41+
var summoner *lcu.Summoner
4242
if summonerName == "" {
4343
if api.p.currSummoner == nil {
4444
app.ErrorMsg("系统错误")
4545
return
4646
}
47-
summonerID = api.p.currSummoner.SummonerId
47+
summoner = lcu.ConvertCurrSummonerToSummoner(api.p.currSummoner)
4848
} else {
4949
info, err := lcu.QuerySummonerByName(summonerName)
5050
if err != nil || info.SummonerId <= 0 {
5151
app.ErrorMsg("未查询到召唤师")
5252
return
5353
}
54-
summonerID = info.SummonerId
54+
summoner = info
5555
}
56-
scoreInfo, err := GetUserScore(summonerID)
56+
scoreInfo, err := GetUserScore(summoner)
5757
if err != nil {
5858
app.CommonError(err)
5959
return

app.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package hh_lol_prophet
22

33
import (
4+
"fmt"
45
"sync"
56
"time"
67

@@ -29,9 +30,20 @@ var (
2930
GetCurrConversationID = lcu.GetCurrConversationID
3031
QuerySummoner = lcu.QuerySummoner
3132
QueryGameSummary = lcu.QueryGameSummary
32-
ListGamesBySummonerID = lcu.ListGamesBySummonerID
3333
)
3434

35+
func listSummoner(summonerIDList []int64) (map[int64]*lcu.Summoner, error) {
36+
list, err := lcu.ListSummoner(summonerIDList)
37+
if err != nil {
38+
return nil, err
39+
}
40+
res := make(map[int64]*lcu.Summoner, len(summonerIDList))
41+
for _, summoner := range list {
42+
summoner := summoner
43+
res[summoner.SummonerId] = &summoner
44+
}
45+
return res, nil
46+
}
3547
func getTeamUsers() (string, []int64, error) {
3648
conversationID, err := GetCurrConversationID()
3749
if err != nil {
@@ -53,18 +65,13 @@ func getSummonerIDListFromConversationMsgList(msgList []lcu.ConversationMsg) []i
5365
}
5466
return summonerIDList
5567
}
56-
57-
func GetUserScore(summonerID int64) (*lcu.UserScore, error) {
68+
func GetUserScore(summoner *lcu.Summoner) (*lcu.UserScore, error) {
69+
summonerID := summoner.SummonerId
5870
userScoreInfo := &lcu.UserScore{
5971
SummonerID: summonerID,
6072
Score: defaultScore,
6173
}
62-
// 获取用户信息
63-
summoner, err := QuerySummoner(summonerID)
64-
if err != nil {
65-
return nil, err
66-
}
67-
userScoreInfo.SummonerName = summoner.DisplayName
74+
userScoreInfo.SummonerName = fmt.Sprintf("%s#%s", summoner.GameName, summoner.TagLine)
6875
// 获取战绩列表
6976
gameList, err := listGameHistory(summoner.Puuid)
7077
if err != nil {
@@ -78,10 +85,7 @@ func GetUserScore(summonerID int64) (*lcu.UserScore, error) {
7885
currKDAList := make([][3]int, len(gameList))
7986
for i, info := range gameList {
8087
info := info
81-
// 国服
8288
currKDAList[len(gameList)-i-1] = [3]int{
83-
// 台服
84-
// currKDAList[i] = [3]int{
8589
info.Participants[0].Stats.Kills,
8690
info.Participants[0].Stats.Deaths,
8791
info.Participants[0].Stats.Assists,

bin/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

bin/.gitkeep

Whitespace-only changes.

bootstrap/init.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package bootstrap
22

33
import (
4+
"crypto/sha1"
5+
"encoding/binary"
6+
"encoding/hex"
47
"encoding/json"
5-
"io"
6-
"net/http"
8+
"log"
79
"os"
8-
"strings"
910
"time"
1011

1112
"github.com/getsentry/sentry-go"
@@ -69,6 +70,9 @@ func initClientConf() (err error) {
6970
}
7071
if !bdk.IsFile(dbPath) {
7172
db, err = gorm.Open(sqlite.Open(dbPath), gormCfg)
73+
if err != nil {
74+
log.Fatalln("创建配置文件失败")
75+
}
7276
bts, _ := json.Marshal(global.DefaultClientConf)
7377
err = db.Exec(models.InitLocalClientSql, models.LocalClientConfKey, string(bts)).Error
7478
if err != nil {
@@ -77,6 +81,9 @@ func initClientConf() (err error) {
7781
*global.ClientConf = global.DefaultClientConf
7882
} else {
7983
db, err = gorm.Open(sqlite.Open(dbPath), gormCfg)
84+
if err != nil {
85+
log.Fatalln("配置文件错误,请删除配置文件重试")
86+
}
8087
confItem := &models.Config{}
8188
err = db.Table("config").Where("k = ?", models.LocalClientConfKey).First(confItem).Error
8289
if err != nil {
@@ -146,8 +153,10 @@ func initAutoReloadCalcConf() {
146153
ticker := time.NewTicker(time.Minute)
147154
for {
148155
latestScoreConf, err := buffApi.GetCurrConf()
149-
if err == nil && latestScoreConf != nil && latestScoreConf.Enabled {
150-
global.SetScoreConf(*latestScoreConf)
156+
if err == nil {
157+
if latestScoreConf.Enabled {
158+
global.SetScoreConf(*latestScoreConf)
159+
}
151160
}
152161
<-ticker.C
153162
}
@@ -169,21 +178,15 @@ func initLib() {
169178
}
170179

171180
func initUserInfo() {
172-
resp, err := http.Get("https://api.ip.sb/ip")
173-
if err != nil {
174-
return
175-
}
176-
defer resp.Body.Close()
177-
bts, _ := io.ReadAll(resp.Body)
181+
sha1.New()
182+
hBts := sha1.Sum(binary.LittleEndian.AppendUint64(nil, bdk.GetMac()))
178183
global.SetUserInfo(global.UserInfo{
179-
IP: strings.Trim(string(bts), "\n"),
180-
// Mac: windows.GetMac(),
181-
// CpuID: windows.GetCpuID(),
184+
MacHash: hex.EncodeToString(hBts[:]),
182185
})
183186
}
184187
func initSentry(dsn string) error {
185188
isDebugMode := global.IsDevMode()
186-
sampleRate := 1.0
189+
sampleRate := 0.1
187190
if !isDebugMode {
188191
sampleRate = 1.0
189192
}
@@ -202,16 +205,13 @@ func initSentry(dsn string) error {
202205
userInfo := global.GetUserInfo()
203206
sentry.ConfigureScope(func(scope *sentry.Scope) {
204207
scope.SetContext("buffgeDefault", map[string]interface{}{
205-
"ip": userInfo.IP,
208+
"mac": userInfo.MacHash,
206209
"version": global.AppBuildInfo.Version,
207-
// "mac": userInfo.Mac,
208-
// "cpuID": userInfo.CpuID,
209210
})
210211
scope.SetUser(sentry.User{
211-
// ID: userInfo.Mac,
212-
IPAddress: userInfo.IP,
212+
ID: userInfo.MacHash,
213213
})
214-
// scope.SetExtra("cpuID", userInfo.CpuID)
214+
scope.SetExtra("mac", userInfo.MacHash)
215215
})
216216
}
217217
return err

global/global.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type (
1919
BuildTime string
2020
}
2121
UserInfo struct {
22-
IP string `json:"ip"`
22+
MacHash string `json:"macHash"`
2323
}
2424
)
2525

go.mod

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,56 @@
11
module github.com/real-web-world/hh-lol-prophet
22

3-
go 1.19
3+
go 1.23
44

55
require (
66
github.com/atotto/clipboard v0.1.4
77
github.com/avast/retry-go v3.0.0+incompatible
8-
github.com/getsentry/sentry-go v0.12.0
9-
github.com/gin-contrib/cors v1.3.1
10-
github.com/gin-contrib/pprof v1.3.0
11-
github.com/gin-gonic/gin v1.7.7
12-
github.com/go-playground/validator/v10 v10.10.0
13-
github.com/gorilla/websocket v1.5.0
14-
github.com/jinzhu/configor v1.2.1
15-
github.com/jinzhu/now v1.1.4
16-
github.com/joho/godotenv v1.4.0
8+
github.com/getsentry/sentry-go v0.29.1
9+
github.com/gin-contrib/cors v1.7.2
10+
github.com/gin-contrib/pprof v1.5.0
11+
github.com/gin-gonic/gin v1.10.0
12+
github.com/go-playground/validator/v10 v10.22.1
13+
github.com/gorilla/websocket v1.5.3
14+
github.com/jinzhu/configor v1.2.2
15+
github.com/jinzhu/now v1.1.5
16+
github.com/joho/godotenv v1.5.1
1717
github.com/pkg/errors v0.9.1
18-
go.uber.org/zap v1.21.0
19-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
20-
golang.org/x/sys v0.0.0-20220209214540-3681064d5158
21-
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
22-
gopkg.in/natefinch/lumberjack.v2 v2.0.0
23-
gorm.io/driver/sqlite v1.3.1
24-
gorm.io/gorm v1.23.1
18+
go.uber.org/zap v1.27.0
19+
golang.org/x/sync v0.8.0
20+
golang.org/x/sys v0.26.0
21+
golang.org/x/time v0.7.0
22+
gopkg.in/natefinch/lumberjack.v2 v2.2.1
23+
gorm.io/driver/sqlite v1.5.6
24+
gorm.io/gorm v1.25.12
2525
)
2626

2727
require (
28-
github.com/BurntSushi/toml v1.0.0 // indirect
28+
github.com/BurntSushi/toml v1.4.0 // indirect
29+
github.com/bytedance/sonic v1.12.3 // indirect
30+
github.com/bytedance/sonic/loader v0.2.1 // indirect
31+
github.com/cloudwego/base64x v0.1.4 // indirect
32+
github.com/cloudwego/iasm v0.2.0 // indirect
33+
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
2934
github.com/gin-contrib/sse v0.1.0 // indirect
30-
github.com/go-playground/locales v0.14.0 // indirect
31-
github.com/go-playground/universal-translator v0.18.0 // indirect
32-
github.com/golang/protobuf v1.5.2 // indirect
35+
github.com/go-playground/locales v0.14.1 // indirect
36+
github.com/go-playground/universal-translator v0.18.1 // indirect
37+
github.com/goccy/go-json v0.10.3 // indirect
3338
github.com/jinzhu/inflection v1.0.0 // indirect
3439
github.com/json-iterator/go v1.1.12 // indirect
35-
github.com/leodido/go-urn v1.2.1 // indirect
36-
github.com/mattn/go-isatty v0.0.14 // indirect
37-
github.com/mattn/go-sqlite3 v1.14.9 // indirect
40+
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
41+
github.com/leodido/go-urn v1.4.0 // indirect
42+
github.com/mattn/go-isatty v0.0.20 // indirect
43+
github.com/mattn/go-sqlite3 v1.14.24 // indirect
3844
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3945
github.com/modern-go/reflect2 v1.0.2 // indirect
40-
github.com/ugorji/go/codec v1.2.6 // indirect
41-
go.uber.org/atomic v1.9.0 // indirect
42-
go.uber.org/multierr v1.7.0 // indirect
43-
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
44-
golang.org/x/text v0.3.7 // indirect
45-
google.golang.org/protobuf v1.27.1 // indirect
46-
gopkg.in/yaml.v2 v2.4.0 // indirect
46+
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
47+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
48+
github.com/ugorji/go/codec v1.2.12 // indirect
49+
go.uber.org/multierr v1.11.0 // indirect
50+
golang.org/x/arch v0.11.0 // indirect
51+
golang.org/x/crypto v0.28.0 // indirect
52+
golang.org/x/net v0.30.0 // indirect
53+
golang.org/x/text v0.19.0 // indirect
54+
google.golang.org/protobuf v1.35.1 // indirect
55+
gopkg.in/yaml.v3 v3.0.1 // indirect
4756
)

0 commit comments

Comments
 (0)