Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
go-cqhttp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
go-cqhttp
Commits
9b41cd8e
Commit
9b41cd8e
authored
Sep 26, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Plain Diff
update MiraiGo.
parents
e0ab2417
c7ab32fe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
45 deletions
+7
-45
coolq/api.go
coolq/api.go
+4
-0
coolq/cqcode.go
coolq/cqcode.go
+2
-2
docs/file.md
docs/file.md
+0
-2
main.go
main.go
+1
-41
No files found.
coolq/api.go
View file @
9b41cd8e
...
@@ -125,6 +125,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo
...
@@ -125,6 +125,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo
if
mid
==
-
1
{
if
mid
==
-
1
{
return
Failed
(
100
)
return
Failed
(
100
)
}
}
log
.
Infof
(
"发送群 %v(%v) 的消息: %v (%v)"
,
groupId
,
groupId
,
m
.
String
(),
mid
)
return
OK
(
MSG
{
"message_id"
:
mid
})
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
str
=
func
()
string
{
str
=
func
()
string
{
...
@@ -151,6 +152,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo
...
@@ -151,6 +152,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo
if
mid
==
-
1
{
if
mid
==
-
1
{
return
Failed
(
100
)
return
Failed
(
100
)
}
}
log
.
Infof
(
"发送群 %v(%v) 的消息: %v (%v)"
,
groupId
,
groupId
,
str
,
mid
)
return
OK
(
MSG
{
"message_id"
:
mid
})
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
...
@@ -247,6 +249,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b
...
@@ -247,6 +249,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b
if
mid
==
-
1
{
if
mid
==
-
1
{
return
Failed
(
100
)
return
Failed
(
100
)
}
}
log
.
Infof
(
"发送好友 %v(%v) 的消息: %v (%v)"
,
userId
,
userId
,
m
.
String
(),
mid
)
return
OK
(
MSG
{
"message_id"
:
mid
})
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
str
=
func
()
string
{
str
=
func
()
string
{
...
@@ -271,6 +274,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b
...
@@ -271,6 +274,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b
if
mid
==
-
1
{
if
mid
==
-
1
{
return
Failed
(
100
)
return
Failed
(
100
)
}
}
log
.
Infof
(
"发送好友 %v(%v) 的消息: %v (%v)"
,
userId
,
userId
,
str
,
mid
)
return
OK
(
MSG
{
"message_id"
:
mid
})
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
...
...
coolq/cqcode.go
View file @
9b41cd8e
...
@@ -58,8 +58,6 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
...
@@ -58,8 +58,6 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
"type"
:
"text"
,
"type"
:
"text"
,
"data"
:
map
[
string
]
string
{
"text"
:
o
.
Content
},
"data"
:
map
[
string
]
string
{
"text"
:
o
.
Content
},
}
}
case
*
message
.
ReplyElement
:
continue
case
*
message
.
LightAppElement
:
case
*
message
.
LightAppElement
:
//m = MSG{
//m = MSG{
// "type": "text",
// "type": "text",
...
@@ -144,6 +142,8 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
...
@@ -144,6 +142,8 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
"data"
:
map
[
string
]
string
{
"data"
:
o
.
Content
,
"resid"
:
fmt
.
Sprintf
(
"%d"
,
o
.
Id
)},
"data"
:
map
[
string
]
string
{
"data"
:
o
.
Content
,
"resid"
:
fmt
.
Sprintf
(
"%d"
,
o
.
Id
)},
}
}
}
}
default
:
continue
}
}
r
=
append
(
r
,
m
)
r
=
append
(
r
,
m
)
}
}
...
...
docs/file.md
View file @
9b41cd8e
...
@@ -7,7 +7,6 @@ go-cqhttp 默认生成的文件树如下所示:
...
@@ -7,7 +7,6 @@ go-cqhttp 默认生成的文件树如下所示:
├── go-cqhttp
├── go-cqhttp
├── config.json
├── config.json
├── device.json
├── device.json
├── servers.bin
├── logs
├── logs
│ └── xx-xx-xx.log
│ └── xx-xx-xx.log
└── data
└── data
...
@@ -21,7 +20,6 @@ go-cqhttp 默认生成的文件树如下所示:
...
@@ -21,7 +20,6 @@ go-cqhttp 默认生成的文件树如下所示:
| go-cqhttp | go-cqhttp可执行文件 |
| go-cqhttp | go-cqhttp可执行文件 |
| config.json | 运行配置文件 |
| config.json | 运行配置文件 |
| device.json | 虚拟设备配置文件 |
| device.json | 虚拟设备配置文件 |
| servers.bin | 储存QQ服务器地址 |
| logs | 日志存放目录 |
| logs | 日志存放目录 |
| data | 数据目录 |
| data | 数据目录 |
| data/images | 图片缓存目录 |
| data/images | 图片缓存目录 |
...
...
main.go
View file @
9b41cd8e
...
@@ -10,7 +10,6 @@ import (
...
@@ -10,7 +10,6 @@ import (
"image"
"image"
"io"
"io"
"io/ioutil"
"io/ioutil"
"net"
"os"
"os"
"os/signal"
"os/signal"
"path"
"path"
...
@@ -237,47 +236,8 @@ func main() {
...
@@ -237,47 +236,8 @@ func main() {
}
}
})
})
cli
.
OnServerUpdated
(
func
(
bot
*
client
.
QQClient
,
e
*
client
.
ServerUpdatedEvent
)
{
cli
.
OnServerUpdated
(
func
(
bot
*
client
.
QQClient
,
e
*
client
.
ServerUpdatedEvent
)
{
log
.
Infof
(
"收到服务器地址更新通知, 将在下一次重连时应用. 地址信息已储存到 servers.bin 文件"
)
log
.
Infof
(
"收到服务器地址更新通知, 将在下一次重连时应用. "
)
_
=
ioutil
.
WriteFile
(
"servers.bin"
,
binary
.
NewWriterF
(
func
(
w
*
binary
.
Writer
)
{
w
.
WriteUInt16
(
func
()
(
c
uint16
)
{
for
_
,
s
:=
range
e
.
Servers
{
if
!
strings
.
Contains
(
s
.
Server
,
"com"
)
{
c
++
}
}
return
}())
for
_
,
s
:=
range
e
.
Servers
{
if
!
strings
.
Contains
(
s
.
Server
,
"com"
)
{
w
.
WriteString
(
s
.
Server
)
w
.
WriteUInt16
(
uint16
(
s
.
Port
))
}
}
}),
0644
)
})
})
if
global
.
PathExists
(
"servers.bin"
)
{
if
data
,
err
:=
ioutil
.
ReadFile
(
"servers.bin"
);
err
==
nil
{
func
()
{
defer
func
()
{
if
pan
:=
recover
();
pan
!=
nil
{
log
.
Error
(
"读取服务器地址时出现错误: "
,
pan
)
}
}()
r
:=
binary
.
NewReader
(
data
)
var
addr
[]
*
net
.
TCPAddr
l
:=
r
.
ReadUInt16
()
for
i
:=
0
;
i
<
int
(
l
);
i
++
{
addr
=
append
(
addr
,
&
net
.
TCPAddr
{
IP
:
net
.
ParseIP
(
r
.
ReadString
()),
Port
:
int
(
r
.
ReadUInt16
()),
})
}
if
len
(
addr
)
>
0
{
cli
.
SetCustomServer
(
addr
)
}
}()
}
}
rsp
,
err
:=
cli
.
Login
()
rsp
,
err
:=
cli
.
Login
()
for
{
for
{
global
.
Check
(
err
)
global
.
Check
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment