Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sealdice/go-cqhttp
Browse files Browse the repository at this point in the history
  • Loading branch information
fy0 committed Oct 10, 2023
2 parents cba8900 + 942b432 commit 254dcc6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/close_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Check and Close Invalid PR

on:
pull_request_target:
types: [opened, reopened]

jobs:
# This workflow closes invalid PR
close_pr:
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions: write-all

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Close PR if it is not pointed to dev branch
if: github.event.pull_request.base.ref != 'dev'
uses: superbrothers/close-pull-request@v3
with:
# Optional. Post a issue comment just before closing a pull request.
comment: "Invalid PR to `non-dev` branch `${{ github.event.pull_request.base.ref }}`."
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: release
name: Release

on:
push:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ _✨ 基于 [Mirai](https://github.com/mamoe/mirai) 以及 [MiraiGo](https://git
<a href="https://github.com/Mrs4s/go-cqhttp/blob/master/CONTRIBUTING.md">参与贡献</a>
</p>

## 重要信息
由于QQ官方针对协议库的围追堵截, 不断更新加密方案, 我们已无力继续维护此项目.
建议Bot开发者尽快迁移至无头NTQQ项目 -> https://github.com/Mrs4s/go-cqhttp/issues/2471

## 兼容性
go-cqhttp 兼容 [OneBot-v11](https://github.com/botuniverse/onebot-11) 绝大多数内容,并在其基础上做了一些扩展,详情请看 go-cqhttp 的文档。
Expand Down
20 changes: 14 additions & 6 deletions cmd/gocq/qsign.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,15 @@ func energy(uin uint64, id string, _ string, salt []byte) ([]byte, error) {
// 提交回调 buffer
func signSubmit(uin string, cmd string, callbackID int64, buffer []byte, t string) {
buffStr := hex.EncodeToString(buffer)
tail := 64
endl := "..."
if len(buffStr) < tail {
tail = len(buffStr)
endl = "."
if base.Debug {
tail := 64
endl := "..."
if len(buffStr) < tail {
tail = len(buffStr)
endl = "."
}
log.Debugf("submit (%v): uin=%v, cmd=%v, callbackID=%v, buffer=%v%s", t, uin, cmd, callbackID, buffStr[:tail], endl)
}
log.Infof("submit (%v): uin=%v, cmd=%v, callbackID=%v, buffer=%v%s", t, uin, cmd, callbackID, buffStr[:tail], endl)

signServer, _, err := requestSignServer(
http.MethodGet,
Expand All @@ -208,6 +210,12 @@ func signSubmit(uin string, cmd string, callbackID int64, buffer []byte, t strin
// signCallback
// 刷新 token 和签名的回调
func signCallback(uin string, results []gjson.Result, t string) {
for { // 等待至在线
if cli.Online.Load() {
break
}
time.Sleep(1 * time.Second)
}
for _, result := range results {
cmd := result.Get("cmd").String()
callbackID := result.Get("callbackId").Int()
Expand Down
6 changes: 3 additions & 3 deletions coolq/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ func (bot *CQBot) CQSendGroupMessage(groupID int64, m gjson.Result, autoEscape b
} else {
str := m.String()
if str == "" {
log.Warn("群消息发送失败: 信息为空.")
log.Warnf("群 %v 消息发送失败: 信息为空.", groupID)
return Failed(100, "EMPTY_MSG_ERROR", "消息为空")
}
if autoEscape {
Expand Down Expand Up @@ -981,7 +981,7 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) globa
}
ret := bot.Client.SendGroupForwardMessage(groupID, fe)
if ret == nil || ret.Id == -1 {
log.Warnf("合并转发(群)消息发送失败: 账号可能被风控.")
log.Warnf("合并转发(群 %v)消息发送失败: 账号可能被风控.", groupID)
return Failed(100, "SEND_MSG_API_ERROR", "请参考 go-cqhttp 端输出")
}
mid := bot.InsertGroupMessage(ret, source)
Expand All @@ -1007,7 +1007,7 @@ func (bot *CQBot) CQSendPrivateForwardMessage(userID int64, m gjson.Result) glob
}
mid := bot.SendPrivateMessage(userID, 0, &message.SendingMessage{Elements: []message.IMessageElement{fe}})
if mid == -1 {
log.Warnf("合并转发(好友)消息发送失败: 账号可能被风控.")
log.Warnf("合并转发(好友 %v)消息发送失败: 账号可能被风控.", userID)
return Failed(100, "SEND_MSG_API_ERROR", "请参考 go-cqhttp 端输出")
}
log.Infof("发送好友 %v(%v) 的合并转发消息: %v (%v)", userID, userID, limitedString(m.String()), mid)
Expand Down
4 changes: 2 additions & 2 deletions coolq/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,14 @@ func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) (in
newElem = append(newElem, e)
}
if len(newElem) == 0 {
log.Warnf("群消息发送失败: 消息为空.")
log.Warnf("群 %v 消息发送失败: 消息为空.", groupID)
return -1, errors.New("empty message")
}
m.Elements = newElem
bot.checkMedia(newElem, groupID)
ret := bot.Client.SendGroupMessage(groupID, m)
if ret == nil || ret.Id == -1 {
log.Warnf("群消息发送失败: 账号可能被风控.")
log.Warnf("群 %v 发送消息失败: 账号可能被风控.", groupID)
return -1, errors.New("send group message failed: blocked by server")
}
return bot.InsertGroupMessage(ret, source), nil
Expand Down

0 comments on commit 254dcc6

Please sign in to comment.