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
2ec7f83d
Commit
2ec7f83d
authored
Aug 07, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
supported .cqimg direct sending.
parent
06f4a10c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
coolq/cqcode.go
coolq/cqcode.go
+21
-4
main.go
main.go
+1
-1
No files found.
coolq/cqcode.go
View file @
2ec7f83d
...
@@ -2,6 +2,7 @@ package coolq
...
@@ -2,6 +2,7 @@ package coolq
import
(
import
(
"encoding/base64"
"encoding/base64"
"encoding/hex"
"errors"
"errors"
"fmt"
"fmt"
"github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/binary"
...
@@ -204,16 +205,32 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
...
@@ -204,16 +205,32 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
if
len
(
b
)
<
20
{
if
len
(
b
)
<
20
{
return
nil
,
errors
.
New
(
"invalid local file"
)
return
nil
,
errors
.
New
(
"invalid local file"
)
}
}
r
:=
binary
.
NewReader
(
b
)
var
size
int32
hash
:=
r
.
ReadBytes
(
16
)
var
hash
[]
byte
if
path
.
Ext
(
rawPath
)
==
".cqimg"
{
for
_
,
line
:=
range
strings
.
Split
(
global
.
ReadAllText
(
rawPath
),
"
\n
"
)
{
kv
:=
strings
.
SplitN
(
line
,
"="
,
2
)
switch
kv
[
0
]
{
case
"md5"
:
hash
,
_
=
hex
.
DecodeString
(
kv
[
1
])
case
"size"
:
t
,
_
:=
strconv
.
Atoi
(
kv
[
1
])
size
=
int32
(
t
)
}
}
}
else
{
r
:=
binary
.
NewReader
(
b
)
hash
=
r
.
ReadBytes
(
16
)
size
=
r
.
ReadInt32
()
}
if
group
{
if
group
{
rsp
,
err
:=
bot
.
Client
.
QueryGroupImage
(
1
,
hash
,
r
.
ReadInt32
()
)
rsp
,
err
:=
bot
.
Client
.
QueryGroupImage
(
1
,
hash
,
size
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
rsp
,
nil
return
rsp
,
nil
}
}
rsp
,
err
:=
bot
.
Client
.
QueryFriendImage
(
1
,
hash
,
r
.
ReadInt32
()
)
rsp
,
err
:=
bot
.
Client
.
QueryFriendImage
(
1
,
hash
,
size
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
main.go
View file @
2ec7f83d
...
@@ -184,7 +184,7 @@ func main() {
...
@@ -184,7 +184,7 @@ func main() {
log
.
Info
(
"アトリは、高性能ですから!"
)
log
.
Info
(
"アトリは、高性能ですから!"
)
cli
.
OnDisconnected
(
func
(
bot
*
client
.
QQClient
,
e
*
client
.
ClientDisconnectedEvent
)
{
cli
.
OnDisconnected
(
func
(
bot
*
client
.
QQClient
,
e
*
client
.
ClientDisconnectedEvent
)
{
if
conf
.
ReLogin
{
if
conf
.
ReLogin
{
log
.
Warnf
(
"Bot已离线
,将在 %v 秒后尝试重连."
,
conf
.
ReLoginDelay
)
log
.
Warnf
(
"Bot已离线
(%v),将在 %v 秒后尝试重连."
,
e
.
Message
,
conf
.
ReLoginDelay
)
time
.
Sleep
(
time
.
Second
*
time
.
Duration
(
conf
.
ReLoginDelay
))
time
.
Sleep
(
time
.
Second
*
time
.
Duration
(
conf
.
ReLoginDelay
))
rsp
,
err
:=
cli
.
Login
()
rsp
,
err
:=
cli
.
Login
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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