1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-06-30 11:53:25 +00:00

Compare commits

...

31 Commits

Author SHA1 Message Date
4526e00d79 update .goreleaser.yml
(cherry picked from commit eb8a65c682)

add maintainer
(cherry picked from commit a5947ece10)
2021-04-30 19:26:06 +08:00
f6280baa0c use goreleaser
(cherry picked from commit 2b3842e61c)
2021-04-30 19:25:20 +08:00
Sam
8974adb009 fix: panic on empty forward msg
(cherry picked from commit c06aee39d9)
2021-04-30 17:00:29 +08:00
2226be777a fix: reduce limitedString memory cost
(cherry picked from commit 5b0c693aba)
2021-04-30 16:53:47 +08:00
127d636b8a fix unexpected ReadPassword behavior in linux(#794)
(cherry picked from commit a361366916)
2021-04-30 16:53:47 +08:00
f1a480c01d update MiraiGo 2021-04-30 16:53:47 +08:00
2f227842f7 fix: send temp message
(cherry picked from commit cebf9c25e1)
2021-04-30 16:22:27 +08:00
c24a2b327a fix: tts can't play on ios(#849)
(cherry picked from commit 1ecb1f62dc)

(cherry picked from commit 0487f849bc)
2021-04-30 15:47:31 +08:00
5f247715b9 feat(go-silk): update go-silk support darwin arm64
(cherry picked from commit ad260f6217)
2021-04-30 15:28:55 +08:00
ae73451677 fix(cqcode): some escape error in cqcode serialize
fix typo
(cherry picked from commit ecf695a68d)

fix escape
(cherry picked from commit 337e53ebc6)
2021-04-30 14:58:06 +08:00
2aed5d5a16 fix(ws server): add lock when accept a connection
(cherry picked from commit 5d61a254e6)
2021-04-30 14:48:14 +08:00
Sam
190eb00143 fix(coolq): fix temp message when group does not exist(#717)
(cherry picked from commit 2febee01d9)
2021-04-30 14:46:53 +08:00
84fef8f0c0 fix(cqcode): split url does not work
(cherry picked from commit 8db68f9427)
2021-04-30 14:45:17 +08:00
5049a8f697 Merge pull request #697 from povsister/ldflags-typo
Fix a comment typo
2021-03-09 16:11:39 +08:00
c0260bc82d update MiraiGo. 2021-03-09 16:07:29 +08:00
8185c4cdf1 fix typo 2021-03-08 22:32:15 +08:00
0bcd16b252 Merge pull request #702 from sam01101/dev
限制 handle_quick_op... 的 at_sender 使用场景
2021-03-08 08:35:17 +08:00
Sam
b2738d909b 限制 handle_quick_op... 的 at_sender 使用场景, Closes #701 2021-03-06 20:31:58 +08:00
95f2227898 Merge pull request #698 from sam01101/dev
Fix bug
2021-03-05 19:59:59 +08:00
cdb700c92f update MiraiGo. 2021-03-05 19:03:09 +08:00
Sam
626de1cb17 Closes #556 2021-03-05 17:34:21 +08:00
bfc3958f34 Fix a comment typo 2021-03-05 12:57:07 +08:00
9a2b69ccf0 Merge branch 'dev' of https://github.com/Mrs4s/go-cqhttp into dev 2021-03-04 19:49:32 +08:00
5854f51506 update MiraiGo. 2021-03-04 19:49:19 +08:00
cf5d3cef95 Merge pull request #696 from sam01101/dev
临时会话添加Group字段, Fixes #695
2021-03-04 16:36:24 +08:00
6864dc449b more memory usage. 2021-03-04 16:16:54 +08:00
b781c3b43b [temp_msg] Changed gorup_id to sender list 2021-03-04 16:11:41 +08:00
e36a9a95c5 update MiraiGo. 2021-03-04 16:09:10 +08:00
Sam
a639b60155 临时会话添加Group字段, Fixes #695 2021-03-04 15:13:22 +08:00
77e0363e32 update. 2021-03-04 11:13:33 +08:00
5d0d8f3908 update MiraiGo. fix #689 2021-03-04 09:07:07 +08:00
17 changed files with 302 additions and 123 deletions

View File

@ -1,36 +1,28 @@
name: release
on: on:
release: push:
types: [created] tags:
- 'v*'
jobs: jobs:
releases-matrix: goreleaser:
name: Release Go Binary
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
# build and publish in parallel: linux/386, linux/amd64, windows/386, windows/amd64, darwin/386, darwin/amd64, darwin/arm64
goos: [linux, windows, darwin]
goarch: ["386", amd64, arm, arm64]
exclude:
- goos: darwin
goarch: arm
- goos: darwin
goarch: "386"
- goos: windows
goarch: arm64
steps: steps:
- uses: actions/checkout@v2 - name: Checkout
- name: Set RELEASE_VERSION env uses: actions/checkout@v2.3.4
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
- uses: pcrbot/go-release-action@master
env:
CGO_ENABLED: 0
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "https://golang.org/dl/go1.16.linux-amd64.tar.gz"
build_flags: -trimpath
ldflags: -w -s -X "github.com/Mrs4s/go-cqhttp/coolq.Version=${{ env.RELEASE_VERSION }}"
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.16.2'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

85
.goreleaser.yml Normal file
View File

@ -0,0 +1,85 @@
env:
- GO111MODULE=on
before:
hooks:
- go mod tidy
builds:
- id: nowin
env:
- CGO_ENABLED=0
- GO111MODULE=on
goos:
- linux
- darwin
goarch:
- 386
- amd64
- arm
- arm64
ignore:
- goos: darwin
goarch: arm
- goos: darwin
goarch: 386
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -trimpath
ldflags:
- -s -w -X github.com/Mrs4s/go-cqhttp/coolq.Version=v{{.Version}}
- id: win
env:
- CGO_ENABLED=0
- GO111MODULE=on
goos:
- windows
goarch:
- 386
- amd64
- arm
goarm:
- 7
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -trimpath
ldflags:
- -s -w -X github.com/Mrs4s/go-cqhttp/coolq.Version=v{{.Version}}
checksum:
name_template: "{{ .ProjectName }}_checksums.txt"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- fix typo
- Merge pull request
- Merge branch
- Merge remote-tracking
- go mod tidy
archives:
- id: binary
builds:
- win
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
format_overrides:
- goos: windows
format: binary
- id: nowin
builds:
- nowin
- win
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
format_overrides:
- goos: windows
format: zip
nfpms:
- license: AGPL 3.0
homepage: https://go-cqhttp.org
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
formats:
- deb
- rpm
maintainer: Mrs4s

View File

@ -279,4 +279,4 @@ go-cqhttp兼容[OneBot-v11](https://github.com/howmanybots/onebot/tree/master/v1
## 性能 ## 性能
在关闭数据库的情况下, 加载 25 个好友 128 个群运行 24 小时后内存使用为 10MB 左右. 开启数据库后内存使用将根据消息量增加 10-20MB, 如果系统内存小于 128M 建议关闭数据库使用. 在关闭数据库的情况下, 加载 25 个好友 128 个群运行 24 小时后内存使用为 15MB 左右. 开启数据库后内存使用将根据消息量增加 10-20MB, 如果系统内存小于 128M 建议关闭数据库使用.

View File

@ -4,27 +4,41 @@ import (
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/MiraiGo/message"
"github.com/tidwall/gjson"
"io/ioutil" "io/ioutil"
"math" "math"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"runtime" "runtime"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"unicode/utf8"
"github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils"
log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
"github.com/Mrs4s/go-cqhttp/global" "github.com/Mrs4s/go-cqhttp/global"
log "github.com/sirupsen/logrus"
) )
// Version go-cqhttp的版本信息在编译时使用ldfalgs进行覆盖 // Version go-cqhttp的版本信息在编译时使用ldflags进行覆盖
var Version = "unknown" var Version = "unknown"
func init() {
if Version != "unknown" {
return
}
info, ok := debug.ReadBuildInfo()
if ok {
Version = info.Main.Version
}
}
// CQGetLoginInfo 获取登录号信息 // CQGetLoginInfo 获取登录号信息
// //
// https://git.io/Jtz1I // https://git.io/Jtz1I
@ -438,12 +452,12 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) MSG {
// CQSendPrivateMessage 发送私聊消息 // CQSendPrivateMessage 发送私聊消息
// //
// https://git.io/Jtz1l // https://git.io/Jtz1l
func (bot *CQBot) CQSendPrivateMessage(userID int64, i interface{}, autoEscape bool) MSG { func (bot *CQBot) CQSendPrivateMessage(userID int64, groupId int64, i interface{}, autoEscape bool) MSG {
var str string var str string
if m, ok := i.(gjson.Result); ok { if m, ok := i.(gjson.Result); ok {
if m.Type == gjson.JSON { if m.Type == gjson.JSON {
elem := bot.ConvertObjectMessage(m, false) elem := bot.ConvertObjectMessage(m, false)
mid := bot.SendPrivateMessage(userID, &message.SendingMessage{Elements: elem}) mid := bot.SendPrivateMessage(userID, groupId, &message.SendingMessage{Elements: elem})
if mid == -1 { if mid == -1 {
return Failed(100, "SEND_MSG_API_ERROR", "请参考输出") return Failed(100, "SEND_MSG_API_ERROR", "请参考输出")
} }
@ -468,7 +482,7 @@ func (bot *CQBot) CQSendPrivateMessage(userID int64, i interface{}, autoEscape b
} else { } else {
elem = bot.ConvertStringMessage(str, false) elem = bot.ConvertStringMessage(str, false)
} }
mid := bot.SendPrivateMessage(userID, &message.SendingMessage{Elements: elem}) mid := bot.SendPrivateMessage(userID, groupId, &message.SendingMessage{Elements: elem})
if mid == -1 { if mid == -1 {
return Failed(100, "SEND_MSG_API_ERROR", "请参考输出") return Failed(100, "SEND_MSG_API_ERROR", "请参考输出")
} }
@ -831,9 +845,9 @@ func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG {
if reply.Exists() { if reply.Exists() {
autoEscape := global.EnsureBool(operation.Get("auto_escape"), false) autoEscape := global.EnsureBool(operation.Get("auto_escape"), false)
at := !isAnonymous // 除匿名消息场合外默认 true at := !isAnonymous && msgType == "group" // 除匿名消息场合外默认 true
if operation.Get("at_sender").Exists() { if operation.Get("at_sender").Exists() {
at = operation.Get("at_sender").Bool() && !isAnonymous at = operation.Get("at_sender").Bool() && !isAnonymous && msgType == "group"
} }
if at && reply.IsArray() { if at && reply.IsArray() {
@ -874,7 +888,7 @@ func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG {
bot.CQSendGroupMessage(context.Get("group_id").Int(), reply, autoEscape) bot.CQSendGroupMessage(context.Get("group_id").Int(), reply, autoEscape)
} }
if msgType == "private" { if msgType == "private" {
bot.CQSendPrivateMessage(context.Get("user_id").Int(), reply, autoEscape) bot.CQSendPrivateMessage(context.Get("user_id").Int(), context.Get("group_id").Int(), reply, autoEscape)
} }
} }
if msgType == "group" { if msgType == "group" {
@ -1354,10 +1368,15 @@ func convertGroupMemberInfo(groupID int64, m *client.GroupMemberInfo) MSG {
} }
func limitedString(str string) string { func limitedString(str string) string {
if strings.Count(str, "") <= 10 { if utf8.RuneCountInString(str) <= 10 {
return str return str
} }
limited := []rune(str) b := utils.S2B(str)
limited = limited[:10] limited := make([]rune, 0, 10)
for i := 0; i < 10; i++ {
decodeRune, size := utf8.DecodeRune(b)
b = b[size:]
limited = append(limited, decodeRune)
}
return string(limited) + " ..." return string(limited) + " ..."
} }

View File

@ -17,10 +17,11 @@ import (
"github.com/Mrs4s/MiraiGo/client" "github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/MiraiGo/message" "github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils" "github.com/Mrs4s/MiraiGo/utils"
"github.com/Mrs4s/go-cqhttp/global"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb"
"github.com/Mrs4s/go-cqhttp/global"
) )
var json = jsoniter.ConfigCompatibleWithStandardLibrary var json = jsoniter.ConfigCompatibleWithStandardLibrary
@ -242,7 +243,7 @@ func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) int
} }
// SendPrivateMessage 发送私聊消息 // SendPrivateMessage 发送私聊消息
func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) int32 { func (bot *CQBot) SendPrivateMessage(target int64, groupID int64, m *message.SendingMessage) int32 {
var newElem []message.IMessageElement var newElem []message.IMessageElement
for _, elem := range m.Elements { for _, elem := range m.Elements {
if i, ok := elem.(*LocalImageElement); ok { if i, ok := elem.(*LocalImageElement); ok {
@ -259,7 +260,7 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
return 0 return 0
} }
if i, ok := elem.(*message.VoiceElement); ok { if i, ok := elem.(*message.VoiceElement); ok {
fv, err := bot.Client.UploadPrivatePtt(target, i.Data) fv, err := bot.Client.UploadPrivatePtt(target, bytes.NewReader(i.Data))
if err != nil { if err != nil {
log.Warnf("警告: 私聊 %v 消息语音上传失败: %v", target, err) log.Warnf("警告: 私聊 %v 消息语音上传失败: %v", target, err)
continue continue
@ -294,16 +295,37 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
if msg != nil { if msg != nil {
id = bot.InsertPrivateMessage(msg) id = bot.InsertPrivateMessage(msg)
} }
} else if code, ok := bot.tempMsgCache.Load(target); ok { // 临时会话 } else if code, ok := bot.tempMsgCache.Load(target); ok || groupID != 0 { // 临时会话
msg := bot.Client.SendTempMessage(code.(int64), target, m) switch {
if msg != nil { case groupID != 0 && bot.Client.FindGroup(groupID) == nil:
id = bot.InsertTempMessage(target, msg) log.Errorf("错误: 找不到群(%v)", groupID)
id = -1
case groupID != 0 && !bot.Client.FindGroup(groupID).AdministratorOrOwner():
log.Errorf("错误: 机器人在群(%v) 为非管理员或群主, 无法主动发起临时会话", groupID)
id = -1
case groupID != 0 && bot.Client.FindGroup(groupID).FindMember(target) == nil:
log.Errorf("错误: 群员(%v) 不在 群(%v), 无法发起临时会话", target, groupID)
id = -1
default:
if code != nil && groupID == 0 {
groupID = code.(int64)
}
msg := bot.Client.SendGroupTempMessage(groupID, target, m)
if msg != nil {
id = bot.InsertTempMessage(target, msg)
}
} }
} else if _, ok := bot.oneWayMsgCache.Load(target); ok { // 单向好友 } else if _, ok := bot.oneWayMsgCache.Load(target); ok { // 单向好友
msg := bot.Client.SendPrivateMessage(target, m) msg := bot.Client.SendPrivateMessage(target, m)
if msg != nil { if msg != nil {
id = bot.InsertPrivateMessage(msg) id = bot.InsertPrivateMessage(msg)
} }
} else {
nickname := "Unknown"
if summaryInfo, _ := bot.Client.GetSummaryInfo(target); summaryInfo != nil {
nickname = summaryInfo.Nickname
}
log.Errorf("错误: 请先添加 %v(%v) 为好友", nickname, target)
} }
if id == -1 { if id == -1 {
return -1 return -1

View File

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"crypto/md5" "crypto/md5"
"encoding/base64" "encoding/base64"
goBinary "encoding/binary"
"encoding/hex" "encoding/hex"
xml2 "encoding/xml" xml2 "encoding/xml"
"errors" "errors"
@ -25,9 +24,11 @@ import (
"github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/message" "github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/utils" "github.com/Mrs4s/MiraiGo/utils"
"github.com/Mrs4s/go-cqhttp/global"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"github.com/Mrs4s/go-cqhttp/global"
"github.com/Mrs4s/go-cqhttp/global/codec"
) )
/* /*
@ -46,15 +47,8 @@ var SplitURL = false
var magicCQ = uint32(0) var magicCQ = uint32(0)
func init() { func init() {
const sizeInt = int(unsafe.Sizeof(0)) var CQHeader = "[CQ:"
x := 0x1234 magicCQ = *(*uint32)(unsafe.Pointer((*reflect.StringHeader)(unsafe.Pointer(&CQHeader)).Data))
p := unsafe.Pointer(&x)
p2 := (*[sizeInt]byte)(p)
if p2[0] == 0 {
magicCQ = goBinary.BigEndian.Uint32([]byte("[CQ:"))
} else {
magicCQ = goBinary.LittleEndian.Uint32([]byte("[CQ:"))
}
} }
// add 指针运算 // add 指针运算
@ -232,7 +226,7 @@ func ToArrayMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r []M
} else { } else {
m = MSG{ m = MSG{
"type": "image", "type": "image",
"data": map[string]string{"file": hex.EncodeToString(o.Md5) + ".image", "url": CQCodeEscapeText(o.Url)}, "data": map[string]string{"file": hex.EncodeToString(o.Md5) + ".image", "url": o.Url},
} }
} }
case *message.FriendImageElement: case *message.FriendImageElement:
@ -244,7 +238,7 @@ func ToArrayMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r []M
} else { } else {
m = MSG{ m = MSG{
"type": "image", "type": "image",
"data": map[string]string{"file": hex.EncodeToString(o.Md5) + ".image", "url": CQCodeEscapeText(o.Url)}, "data": map[string]string{"file": hex.EncodeToString(o.Md5) + ".image", "url": o.Url},
} }
} }
case *message.GroupFlashImgElement: case *message.GroupFlashImgElement:
@ -330,13 +324,13 @@ func ToStringMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r st
if ur { if ur {
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image") r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
} else { } else {
r += fmt.Sprintf("[CQ:image,file=%s,url=%s]", hex.EncodeToString(o.Md5)+".image", CQCodeEscapeText(o.Url)) r += fmt.Sprintf("[CQ:image,file=%s,url=%s]", hex.EncodeToString(o.Md5)+".image", CQCodeEscapeValue(o.Url))
} }
case *message.FriendImageElement: case *message.FriendImageElement:
if ur { if ur {
r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image") r += fmt.Sprintf("[CQ:image,file=%s]", hex.EncodeToString(o.Md5)+".image")
} else { } else {
r += fmt.Sprintf("[CQ:image,file=%s,url=%s]", hex.EncodeToString(o.Md5)+".image", CQCodeEscapeText(o.Url)) r += fmt.Sprintf("[CQ:image,file=%s,url=%s]", hex.EncodeToString(o.Md5)+".image", CQCodeEscapeValue(o.Url))
} }
case *message.GroupFlashImgElement: case *message.GroupFlashImgElement:
return fmt.Sprintf("[CQ:image,type=flash,file=%s]", o.Filename) return fmt.Sprintf("[CQ:image,type=flash,file=%s]", o.Filename)
@ -360,7 +354,7 @@ func ToStringMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r st
func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMessageElement) { func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMessageElement) {
var t, key string var t, key string
var d = map[string]string{} var d = map[string]string{}
ptr := unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&s)).Data) ptr := unsafe.Pointer((*reflect.StringHeader)(unsafe.Pointer(&s)).Data)
l := len(s) l := len(s)
i, j, CQBegin := 0, 0, 0 i, j, CQBegin := 0, 0, 0
@ -397,10 +391,7 @@ func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMes
if err != nil { if err != nil {
msgTime = time.Now().Unix() msgTime = time.Now().Unix()
} }
messageSeq, err := strconv.ParseInt(d["seq"], 10, 64) messageSeq, _ := strconv.ParseInt(d["seq"], 10, 64)
if err != nil {
messageSeq = 0
}
r = append([]message.IMessageElement{ r = append([]message.IMessageElement{
&message.ReplyElement{ &message.ReplyElement{
ReplySeq: int32(messageSeq), ReplySeq: int32(messageSeq),
@ -414,9 +405,15 @@ func (bot *CQBot) ConvertStringMessage(s string, isGroup bool) (r []message.IMes
} }
if t == "forward" { // 单独处理转发 if t == "forward" { // 单独处理转发
if id, ok := d["id"]; ok { if id, ok := d["id"]; ok {
r = []message.IMessageElement{bot.Client.DownloadForwardMessage(id)} if fwdMsg := bot.Client.DownloadForwardMessage(id); fwdMsg == nil {
return log.Warnf("警告: Forward 信息不存在或已过期")
} else {
r = []message.IMessageElement{fwdMsg}
}
} else {
log.Warnf("警告: Forward 元素中必须包含 id")
} }
return
} }
elem, err := bot.ToElement(t, d, isGroup) elem, err := bot.ToElement(t, d, isGroup)
if err != nil { if err != nil {
@ -442,7 +439,13 @@ S1: // Plain Text
if *(*byte)(add(ptr, uintptr(i))) == '[' && i+4 < l && if *(*byte)(add(ptr, uintptr(i))) == '[' && i+4 < l &&
*(*uint32)(add(ptr, uintptr(i))) == magicCQ { // Magic :uint32([]byte("[CQ:")) *(*uint32)(add(ptr, uintptr(i))) == magicCQ { // Magic :uint32([]byte("[CQ:"))
if i > j { if i > j {
r = append(r, message.NewText(CQCodeUnescapeText(s[j:i]))) if SplitURL {
for _, str := range global.SplitURL(CQCodeUnescapeText(s[j:i])) {
r = append(r, message.NewText(str))
}
} else {
r = append(r, message.NewText(CQCodeUnescapeText(s[j:i])))
}
} }
CQBegin = i CQBegin = i
i += 4 i += 4
@ -500,7 +503,13 @@ S4: // CQCode param value
goto End goto End
End: End:
if i > j { if i > j {
r = append(r, message.NewText(CQCodeUnescapeText(s[j:i]))) if SplitURL {
for _, str := range global.SplitURL(CQCodeUnescapeText(s[j:i])) {
r = append(r, message.NewText(str))
}
} else {
r = append(r, message.NewText(CQCodeUnescapeText(s[j:i])))
}
} }
return return
} }
@ -541,10 +550,7 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, isGroup bool) (r []messag
if err != nil { if err != nil {
msgTime = time.Now().Unix() msgTime = time.Now().Unix()
} }
messageSeq, err := strconv.ParseInt(e.Get("data").Get("seq").String(), 10, 64) messageSeq, _ := strconv.ParseInt(e.Get("data").Get("seq").String(), 10, 64)
if err != nil {
messageSeq = 0
}
r = append([]message.IMessageElement{ r = append([]message.IMessageElement{
&message.ReplyElement{ &message.ReplyElement{
ReplySeq: int32(messageSeq), ReplySeq: int32(messageSeq),
@ -557,7 +563,16 @@ func (bot *CQBot) ConvertObjectMessage(m gjson.Result, isGroup bool) (r []messag
} }
} }
if t == "forward" { if t == "forward" {
r = []message.IMessageElement{bot.Client.DownloadForwardMessage(e.Get("data.id").String())} id := e.Get("data.id").String()
if id == "" {
log.Warnf("警告: Forward 元素中必须包含 id")
} else {
if fwdMsg := bot.Client.DownloadForwardMessage(id); fwdMsg == nil {
log.Warnf("警告: Forward 信息不存在或已过期")
} else {
r = []message.IMessageElement{fwdMsg}
}
}
return return
} }
d := make(map[string]string) d := make(map[string]string)
@ -669,7 +684,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, isGroup bool) (m inte
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &message.VoiceElement{Data: data}, nil return &message.VoiceElement{Data: codec.RecodeTo24K(data)}, nil
case "record": case "record":
f := d["file"] f := d["file"]
data, err := global.FindFile(f, d["cache"], global.VoicePath) data, err := global.FindFile(f, d["cache"], global.VoicePath)

View File

@ -11,8 +11,9 @@ import (
"github.com/Mrs4s/MiraiGo/binary" "github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/client" "github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/MiraiGo/message" "github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/go-cqhttp/global"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/Mrs4s/go-cqhttp/global"
) )
var format = "string" var format = "string"
@ -101,7 +102,8 @@ func (bot *CQBot) groupMessageEvent(c *client.QQClient, m *message.GroupMessage)
bot.dispatchEventMessage(gm) bot.dispatchEventMessage(gm)
} }
func (bot *CQBot) tempMessageEvent(c *client.QQClient, m *message.TempMessage) { func (bot *CQBot) tempMessageEvent(c *client.QQClient, m1 *client.TempMessageEvent) {
m := m1.Message
bot.checkMedia(m.Elements) bot.checkMedia(m.Elements)
cqm := ToStringMessage(m.Elements, m.Sender.Uin, true) cqm := ToStringMessage(m.Elements, m.Sender.Uin, true)
bot.tempMsgCache.Store(m.Sender.Uin, m.GroupCode) bot.tempMsgCache.Store(m.Sender.Uin, m.GroupCode)
@ -123,6 +125,7 @@ func (bot *CQBot) tempMessageEvent(c *client.QQClient, m *message.TempMessage) {
"time": time.Now().Unix(), "time": time.Now().Unix(),
"sender": MSG{ "sender": MSG{
"user_id": m.Sender.Uin, "user_id": m.Sender.Uin,
"group_id": m.GroupCode,
"nickname": m.Sender.Nickname, "nickname": m.Sender.Nickname,
"sex": "unknown", "sex": "unknown",
"age": 0, "age": 0,

View File

@ -1,4 +1,4 @@
// +build linux windows,!arm darwin,!arm64 // +build linux windows,!arm darwin
// +build 386 amd64 arm arm64 // +build 386 amd64 arm arm64
// Package codec Slik编码核心模块 // Package codec Slik编码核心模块
@ -51,3 +51,16 @@ func EncodeToSilk(record []byte, tempName string, useCache bool) (silkWav []byte
} }
return return
} }
// RecodeTo24K 将silk重新编码为 24000 bit rate
func RecodeTo24K(data []byte) []byte {
pcm, err := silk.DecodeSilkBuffToPcm(data, 24000)
if err != nil {
panic(err)
}
data, err = silk.EncodePcmBuffToSilk(pcm, 24000, 24000, true)
if err != nil {
panic(err)
}
return data
}

View File

@ -1,8 +0,0 @@
package codec
import "github.com/pkg/errors"
//EncodeToSilk 将音频编码为Silk
func EncodeToSilk(record []byte, tempName string, useCache bool) ([]byte, error) {
return nil, errors.New("not supported now")
}

View File

@ -8,3 +8,8 @@ import "errors"
func EncodeToSilk(record []byte, tempName string, useCache bool) ([]byte, error) { func EncodeToSilk(record []byte, tempName string, useCache bool) ([]byte, error) {
return nil, errors.New("not supported now") return nil, errors.New("not supported now")
} }
// RecodeTo24K 将silk重新编码为 24000 bit rate
func RecodeTo24K(data []byte) []byte {
return data
}

View File

@ -8,3 +8,8 @@ import "errors"
func EncodeToSilk(record []byte, tempName string, useCache bool) ([]byte, error) { func EncodeToSilk(record []byte, tempName string, useCache bool) ([]byte, error) {
return nil, errors.New("not supported now") return nil, errors.New("not supported now")
} }
// RecodeTo24K 将silk重新编码为 24000 bit rate
func RecodeTo24K(data []byte) []byte {
return data
}

View File

@ -6,3 +6,8 @@ import "errors"
func EncodeToSilk(record []byte, tempName string, useCache bool) ([]byte, error) { func EncodeToSilk(record []byte, tempName string, useCache bool) ([]byte, error) {
return nil, errors.New("not supported now") return nil, errors.New("not supported now")
} }
// RecodeTo24K 将silk重新编码为 24000 bit rate
func RecodeTo24K(data []byte) []byte {
return data
}

5
go.mod
View File

@ -3,13 +3,14 @@ module github.com/Mrs4s/go-cqhttp
go 1.16 go 1.16
require ( require (
github.com/Mrs4s/MiraiGo v0.0.0-20210302163721-39a33e4c4965 github.com/Mrs4s/MiraiGo v0.0.0-20210429065541-8f474db6a37e
github.com/dustin/go-humanize v1.0.0 github.com/dustin/go-humanize v1.0.0
github.com/gin-contrib/pprof v1.3.0 github.com/gin-contrib/pprof v1.3.0
github.com/gin-gonic/gin v1.6.3 github.com/gin-gonic/gin v1.6.3
github.com/gorilla/websocket v1.4.2 github.com/gorilla/websocket v1.4.2
github.com/guonaihong/gout v0.1.4 github.com/guonaihong/gout v0.1.4
github.com/hjson/hjson-go v3.1.0+incompatible github.com/hjson/hjson-go v3.1.0+incompatible
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/json-iterator/go v1.1.10 github.com/json-iterator/go v1.1.10
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
@ -19,7 +20,7 @@ require (
github.com/syndtr/goleveldb v1.0.0 github.com/syndtr/goleveldb v1.0.0
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
github.com/tidwall/gjson v1.6.8 github.com/tidwall/gjson v1.6.8
github.com/wdvxdr1123/go-silk v0.0.0-20210207032612-169bbdf8861d github.com/wdvxdr1123/go-silk v0.0.0-20210316130616-d47b553def60
github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189 github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect

33
go.sum
View File

@ -1,10 +1,11 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mrs4s/MiraiGo v0.0.0-20210302163721-39a33e4c4965 h1:zrm7q2Wnj82pqdbaF72es7SYm2aV4dlrwfvVcNoR4hc= github.com/Mrs4s/MiraiGo v0.0.0-20210429065541-8f474db6a37e h1:MEBnCfoVolYSsO/KZ5IbU1l/WV+yMuucgbOxwSwEaRM=
github.com/Mrs4s/MiraiGo v0.0.0-20210302163721-39a33e4c4965/go.mod h1:yhqA0NyKxUf7I/0HR/1OMchveFggX8wde04gqdGrNfU= github.com/Mrs4s/MiraiGo v0.0.0-20210429065541-8f474db6a37e/go.mod h1:NjiWhlvGxwv1ftOWIoiFa/OzklnAYI4YqNexFOKSZKw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
@ -19,6 +20,7 @@ github.com/gin-gonic/gin v1.6.0/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwv
github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.6.2/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
@ -45,8 +47,10 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
@ -54,7 +58,10 @@ github.com/guonaihong/gout v0.1.4 h1:uBBoyztMX9okC27OQxqhn6bZ0ROkGyvnEIHwtp3TM4g
github.com/guonaihong/gout v0.1.4/go.mod h1:0rFYAYyzbcxEg11eY2qUbffJs7hHRPeugAnlVYSp8Ic= github.com/guonaihong/gout v0.1.4/go.mod h1:0rFYAYyzbcxEg11eY2qUbffJs7hHRPeugAnlVYSp8Ic=
github.com/hjson/hjson-go v3.1.0+incompatible h1:DY/9yE8ey8Zv22bY+mHV1uk2yRy0h8tKhZ77hEdi0Aw= github.com/hjson/hjson-go v3.1.0+incompatible h1:DY/9yE8ey8Zv22bY+mHV1uk2yRy0h8tKhZ77hEdi0Aw=
github.com/hjson/hjson-go v3.1.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio= github.com/hjson/hjson-go v3.1.0+incompatible/go.mod h1:qsetwF8NlsTsOTwZTApNlTCerV+b2GjYRRcIk4JMFio=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
@ -63,6 +70,7 @@ github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALr
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is= github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4= github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4=
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA= github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
@ -72,16 +80,20 @@ github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHX
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
@ -94,6 +106,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
@ -109,8 +122,8 @@ github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/wdvxdr1123/go-silk v0.0.0-20210207032612-169bbdf8861d h1:gJTKbjZtlMt/almOeFi/UpVtT3RHqRWscgEuDtnF5TU= github.com/wdvxdr1123/go-silk v0.0.0-20210316130616-d47b553def60 h1:lRKf10iIOW0VsH5WDF621ihzR+R2wEBZVtNRHuLLCb4=
github.com/wdvxdr1123/go-silk v0.0.0-20210207032612-169bbdf8861d/go.mod h1:twOxzexmM2Il1ReUu1fB5tnUotOq/dp56xjk/ZHwb1I= github.com/wdvxdr1123/go-silk v0.0.0-20210316130616-d47b553def60/go.mod h1:ecFKZPX81BaB70I6ruUgEwYcDOtuNgJGnjdK+MIl5ko=
github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189 h1:4UJw9if55Fu3HOwbfcaQlJ27p3oeJU2JZqoeT3ITJQk= github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189 h1:4UJw9if55Fu3HOwbfcaQlJ27p3oeJU2JZqoeT3ITJQk=
github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189/go.mod h1:rIrm5geMiBhPQkdfUm8gDFi/WiHneOp1i9KjmJqc+9I= github.com/yinghau76/go-ascii-art v0.0.0-20190517192627-e7f465a30189/go.mod h1:rIrm5geMiBhPQkdfUm8gDFi/WiHneOp1i9KjmJqc+9I=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@ -148,6 +161,7 @@ golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlp
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE=
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@ -156,6 +170,7 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@ -175,18 +190,22 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
modernc.org/libc v1.7.6 h1:P0qDJAlSR6hSAuE8mQgz9eH/GzigfEd3IIn7HmTQgT0= modernc.org/libc v1.8.1 h1:y9oPIhwcaFXxX7kMp6Qb2ZLKzr0mDkikWN3CV5GS63o=
modernc.org/libc v1.7.6/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= modernc.org/libc v1.8.1/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY= modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY=
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=

31
main.go
View File

@ -8,9 +8,6 @@ import (
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/Mrs4s/go-cqhttp/global/terminal"
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
easy "github.com/t-tomalak/logrus-easy-formatter"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -25,18 +22,21 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/Mrs4s/go-cqhttp/server" "github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/client"
"github.com/guonaihong/gout" "github.com/guonaihong/gout"
jsoniter "github.com/json-iterator/go"
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
log "github.com/sirupsen/logrus"
easy "github.com/t-tomalak/logrus-easy-formatter"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/pbkdf2"
"golang.org/x/term" "golang.org/x/term"
"github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/client"
"github.com/Mrs4s/go-cqhttp/coolq" "github.com/Mrs4s/go-cqhttp/coolq"
"github.com/Mrs4s/go-cqhttp/global" "github.com/Mrs4s/go-cqhttp/global"
jsoniter "github.com/json-iterator/go" "github.com/Mrs4s/go-cqhttp/global/terminal"
log "github.com/sirupsen/logrus" "github.com/Mrs4s/go-cqhttp/server"
) )
var json = jsoniter.ConfigCompatibleWithStandardLibrary var json = jsoniter.ConfigCompatibleWithStandardLibrary
@ -119,11 +119,6 @@ func init() {
} }
func main() { func main() {
if terminal.RunningByDoubleClick() {
log.Warning("警告: 强烈不推荐通过双击直接运行本程序, 这将导致一些非预料的后果.")
log.Warning("将等待10s后启动")
time.Sleep(time.Second * 10)
}
var byteKey []byte var byteKey []byte
arg := os.Args arg := os.Args
if len(arg) > 1 { if len(arg) > 1 {
@ -145,7 +140,11 @@ func main() {
} }
} }
} }
if terminal.RunningByDoubleClick() && !isFastStart {
log.Warning("警告: 强烈不推荐通过双击直接运行本程序, 这将导致一些非预料的后果.")
log.Warning("将等待10s后启动")
time.Sleep(time.Second * 10)
}
if conf.Uin == 0 || (conf.Password == "" && conf.PasswordEncrypted == "") { if conf.Uin == 0 || (conf.Password == "" && conf.PasswordEncrypted == "") {
log.Warnf("请修改 config.hjson 以添加账号密码.") log.Warnf("请修改 config.hjson 以添加账号密码.")
if !isFastStart { if !isFastStart {
@ -188,6 +187,7 @@ func main() {
if len(byteKey) == 0 { if len(byteKey) == 0 {
log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)") log.Infof("密码加密已启用, 请输入Key对密码进行解密以继续: (Enter 提交)")
cancel := make(chan struct{}, 1) cancel := make(chan struct{}, 1)
state, _ := term.GetState(int(os.Stdin.Fd()))
go func() { go func() {
select { select {
case <-cancel: case <-cancel:
@ -195,6 +195,7 @@ func main() {
case <-time.After(time.Second * 45): case <-time.After(time.Second * 45):
log.Infof("解密key输入超时") log.Infof("解密key输入超时")
time.Sleep(3 * time.Second) time.Sleep(3 * time.Second)
_ = term.Restore(int(os.Stdin.Fd()), state)
os.Exit(0) os.Exit(0)
} }
}() }()
@ -350,7 +351,7 @@ func OldPasswordDecrypt(encryptedPassword string, key []byte) string {
func checkUpdate() { func checkUpdate() {
log.Infof("正在检查更新.") log.Infof("正在检查更新.")
if coolq.Version == "unknown" { if coolq.Version == "(devel)" {
log.Warnf("检查更新失败: 使用的 Actions 测试版或自编译版本.") log.Warnf("检查更新失败: 使用的 Actions 测试版或自编译版本.")
return return
} }

View File

@ -45,17 +45,17 @@ func getGroupMemberInfo(bot *coolq.CQBot, p resultGetter) coolq.MSG {
func sendMSG(bot *coolq.CQBot, p resultGetter) coolq.MSG { func sendMSG(bot *coolq.CQBot, p resultGetter) coolq.MSG {
autoEscape := global.EnsureBool(p.Get("auto_escape"), false) autoEscape := global.EnsureBool(p.Get("auto_escape"), false)
if p.Get("message_type").Str == "private" { if p.Get("message_type").Str == "private" {
return bot.CQSendPrivateMessage(p.Get("user_id").Int(), p.Get("message"), autoEscape) return bot.CQSendPrivateMessage(p.Get("user_id").Int(), p.Get("group_id").Int(), p.Get("message"), autoEscape)
} }
if p.Get("message_type").Str == "group" { if p.Get("message_type").Str == "group" {
return bot.CQSendGroupMessage(p.Get("group_id").Int(), p.Get("message"), autoEscape) return bot.CQSendGroupMessage(p.Get("group_id").Int(), p.Get("message"), autoEscape)
} }
if p.Get("user_id").Int() != 0 {
return bot.CQSendPrivateMessage(p.Get("user_id").Int(), p.Get("group_id").Int(), p.Get("message"), autoEscape)
}
if p.Get("group_id").Int() != 0 { if p.Get("group_id").Int() != 0 {
return bot.CQSendGroupMessage(p.Get("group_id").Int(), p.Get("message"), autoEscape) return bot.CQSendGroupMessage(p.Get("group_id").Int(), p.Get("message"), autoEscape)
} }
if p.Get("user_id").Int() != 0 {
return bot.CQSendPrivateMessage(p.Get("user_id").Int(), p.Get("message"), autoEscape)
}
return coolq.MSG{} return coolq.MSG{}
} }
@ -69,7 +69,7 @@ func sendGroupForwardMSG(bot *coolq.CQBot, p resultGetter) coolq.MSG {
} }
func sendPrivateMSG(bot *coolq.CQBot, p resultGetter) coolq.MSG { func sendPrivateMSG(bot *coolq.CQBot, p resultGetter) coolq.MSG {
return bot.CQSendPrivateMessage(p.Get("user_id").Int(), p.Get("message"), return bot.CQSendPrivateMessage(p.Get("user_id").Int(), p.Get("group_id").Int(), p.Get("message"),
global.EnsureBool(p.Get("auto_escape"), false)) global.EnsureBool(p.Get("auto_escape"), false))
} }

View File

@ -301,7 +301,9 @@ func (s *webSocketServer) any(w http.ResponseWriter, r *http.Request) {
} }
log.Infof("接受 WebSocket 连接: %v (/)", r.RemoteAddr) log.Infof("接受 WebSocket 连接: %v (/)", r.RemoteAddr)
conn := &webSocketConn{Conn: c, apiCaller: apiCaller{s.bot}} conn := &webSocketConn{Conn: c, apiCaller: apiCaller{s.bot}}
s.eventConnMutex.Lock()
s.eventConn = append(s.eventConn, conn) s.eventConn = append(s.eventConn, conn)
s.eventConnMutex.Unlock()
s.listenAPI(conn) s.listenAPI(conn)
} }