Skip to content

Commit

Permalink
ci: support goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
aFlyBird0 committed Feb 28, 2023
1 parent 64c1685 commit 1a7aa95
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: goreleaser

on:
push:
# run only against tags
tags:
- '*'

permissions:
contents: write
# packages: write
# issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v3
with:
go-version: '>=1.19'
cache: true
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.
- uses: goreleaser/goreleaser-action@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
# distribution:
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ target/

*.png

dist/

bird_qq_bot
webserver
48 changes: 48 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- id: "bird_qq_bot"
main: ./
binary: "bird_qq_bot"
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
- id: "webserver"
main: ./sidecar/webserver
binary: "webserver"
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
release:
extra_files:
- glob: "application.example.yaml"
- glob: "DingTalk JinBuTi.ttf"
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@

## 快速开始
[application.example.yaml](./application.example.yaml) 复制一份,并重命名为 `application.yaml`
填写账号密码,运行即可。

两种登录方式:

1. 扫码登录,`bot.login-method``qrcode`。然后程序会在启动时,同时在终端中打印出二维码与在当前目录生成 `qrcode.png` 文件,用手机扫码登录即可。
2. 账号密码登录,`bot.login-method``common`,并填写 `bot.account``bot.password`

注:很可能会触发QQ风控,比如密码登录会提示需要滑块验证,这时候就会自动转成扫码登录,同时扫码登录要求扫码的手机和运行QQ机器人的服务器在同一网络环境在。

## 现有功能
### 群复读撤回
Expand All @@ -24,6 +30,8 @@
* localServer:在部署机器人的服务器上启动一个 web 服务,把统计结果以网址的形式发到群里
* remoteServer:把统计信息推送到远程服务器上(见Remote-Webserver 部署),把统计结果以网址的形式发到群里

详细配置见配置文件。

#### Remote-Webserver 部署(可选)

本地平台编译:
Expand Down
2 changes: 1 addition & 1 deletion application.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ modules:
triggers: [ "分数实时排名", ":score", ":score" ] # 主动触发排名计算
displayPicture: true # 是否将分析结果转换为图片发到群里(和webserver可以同时开启)
tailPictureInPicture: "" # 缀在分析结果图片后面的图片,可以放群二维码,留空则不缀图。不要取名为 qr_code.png,会覆盖机器人登录二维码
fontPath: "DingTalk JinBuTi.ttf" # 字体文件路径,用于生成图片
fontPath: "DingTalk JinBuTi.ttf" # 字体文件路径,用于生成图片,ttf格式
webserver: # 考研分数模块,利用一个webserver来存储、展示数据
# 如果在本地直接起一个webserver,配置这里,否则留空
localPort: 8091
Expand Down
10 changes: 6 additions & 4 deletions modules/kaoyanScore/analyse.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (m *kaoyanScore) generateScoreAnalyse(c *client.QQClient) map[groupCode]str
}
msg1 += "\n\n以上结果通过群名片分析而得,存在一定误差,仅供参考。\n"
//msg1 += m.headMsgInWebserver + "\n"
logger.Info("拼接得到的考研分数排名:\n %v\n", msg1)
//logger.Info("拼接得到的考研分数排名:\n %v\n", msg1)

// 发送某些过密分数段分布详情
GroupCodeScoreCountMap := make(map[ScoreFilter][]ScoreGroupCount)
Expand Down Expand Up @@ -101,9 +101,11 @@ func (m *kaoyanScore) generateScoreAnalyse(c *client.QQClient) map[groupCode]str
}
}
}
logger.Info("拼接得到的过密分数排名:\n %v\n", msg2)
fmt.Println(msg2)
result[group] = msg1 + "\n" + msg2 + "\n"
//logger.Info("拼接得到的过密分数排名:\n %v\n", msg2)
//fmt.Println(msg2)
msg := msg1 + msg2
logger.Infof("拼接得到的考研分数排名:\n %v\n", msg)
result[group] = msg
}

return result
Expand Down
1 change: 1 addition & 0 deletions modules/kaoyanScore/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (m *kaoyanScore) sendWebserverMsgToGroup(c *client.QQClient, groupCode int6
c.SendGroupMessage(groupCode, groupMsg)
}

// 把字符串消息转成图片发出去
func (m *kaoyanScore) sendGroupImgMsgFromStr(c *client.QQClient, groupCode int64, msg string) {
var buf bytes.Buffer
var tailPicture image.Image
Expand Down

0 comments on commit 1a7aa95

Please sign in to comment.