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
17f8232a
Commit
17f8232a
authored
Aug 24, 2020
by
wdvxdr1123
Committed by
GitHub
Aug 24, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3 from Mrs4s/master
pull
parents
65acc888
248ba84a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
9 deletions
+23
-9
coolq/api.go
coolq/api.go
+11
-3
coolq/cqcode.go
coolq/cqcode.go
+6
-0
go.mod
go.mod
+1
-1
go.sum
go.sum
+4
-4
server/http.go
server/http.go
+1
-1
No files found.
coolq/api.go
View file @
17f8232a
...
@@ -489,7 +489,7 @@ func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG {
...
@@ -489,7 +489,7 @@ func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG {
bot
.
CQProcessFriendRequest
(
context
.
Get
(
"flag"
)
.
Str
,
operation
.
Get
(
"approve"
)
.
Bool
())
bot
.
CQProcessFriendRequest
(
context
.
Get
(
"flag"
)
.
Str
,
operation
.
Get
(
"approve"
)
.
Bool
())
}
}
if
reqType
==
"group"
{
if
reqType
==
"group"
{
bot
.
CQProcessGroupRequest
(
context
.
Get
(
"flag"
)
.
Str
,
context
.
Get
(
"sub_type"
)
.
Str
,
context
.
Get
(
"reason"
)
.
Str
,
operation
.
Get
(
"approve"
)
.
Bool
())
bot
.
CQProcessGroupRequest
(
context
.
Get
(
"flag"
)
.
Str
,
context
.
Get
(
"sub_type"
)
.
Str
,
operation
.
Get
(
"reason"
)
.
Str
,
operation
.
Get
(
"approve"
)
.
Bool
())
}
}
}
}
}
}
...
@@ -503,11 +503,19 @@ func (bot *CQBot) CQGetImage(file string) MSG {
...
@@ -503,11 +503,19 @@ func (bot *CQBot) CQGetImage(file string) MSG {
if
b
,
err
:=
ioutil
.
ReadFile
(
path
.
Join
(
global
.
IMAGE_PATH
,
file
));
err
==
nil
{
if
b
,
err
:=
ioutil
.
ReadFile
(
path
.
Join
(
global
.
IMAGE_PATH
,
file
));
err
==
nil
{
r
:=
binary
.
NewReader
(
b
)
r
:=
binary
.
NewReader
(
b
)
r
.
ReadBytes
(
16
)
r
.
ReadBytes
(
16
)
return
OK
(
MSG
{
msg
:=
MSG
{
"size"
:
r
.
ReadInt32
(),
"size"
:
r
.
ReadInt32
(),
"filename"
:
r
.
ReadString
(),
"filename"
:
r
.
ReadString
(),
"url"
:
r
.
ReadString
(),
"url"
:
r
.
ReadString
(),
})
}
local
:=
path
.
Join
(
global
.
CACHE_PATH
,
file
+
"."
+
path
.
Ext
(
msg
[
"filename"
]
.
(
string
)))
if
!
global
.
PathExists
(
local
)
{
if
data
,
err
:=
global
.
GetBytes
(
msg
[
"url"
]
.
(
string
));
err
==
nil
{
_
=
ioutil
.
WriteFile
(
local
,
data
,
0644
)
}
}
msg
[
"file"
]
=
local
return
OK
(
msg
)
}
}
return
Failed
(
100
)
return
Failed
(
100
)
}
}
...
...
coolq/cqcode.go
View file @
17f8232a
...
@@ -329,6 +329,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
...
@@ -329,6 +329,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
}
}
var
size
int32
var
size
int32
var
hash
[]
byte
var
hash
[]
byte
var
url
string
if
path
.
Ext
(
rawPath
)
==
".cqimg"
{
if
path
.
Ext
(
rawPath
)
==
".cqimg"
{
for
_
,
line
:=
range
strings
.
Split
(
global
.
ReadAllText
(
rawPath
),
"
\n
"
)
{
for
_
,
line
:=
range
strings
.
Split
(
global
.
ReadAllText
(
rawPath
),
"
\n
"
)
{
kv
:=
strings
.
SplitN
(
line
,
"="
,
2
)
kv
:=
strings
.
SplitN
(
line
,
"="
,
2
)
...
@@ -344,8 +345,13 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
...
@@ -344,8 +345,13 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
r
:=
binary
.
NewReader
(
b
)
r
:=
binary
.
NewReader
(
b
)
hash
=
r
.
ReadBytes
(
16
)
hash
=
r
.
ReadBytes
(
16
)
size
=
r
.
ReadInt32
()
size
=
r
.
ReadInt32
()
r
.
ReadString
()
url
=
r
.
ReadString
()
}
}
if
size
==
0
{
if
size
==
0
{
if
url
!=
""
{
return
bot
.
ToElement
(
t
,
map
[
string
]
string
{
"file"
:
url
},
group
)
}
return
nil
,
errors
.
New
(
"img size is 0"
)
return
nil
,
errors
.
New
(
"img size is 0"
)
}
}
if
len
(
hash
)
!=
16
{
if
len
(
hash
)
!=
16
{
...
...
go.mod
View file @
17f8232a
...
@@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
...
@@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
go 1.14
require (
require (
github.com/Mrs4s/MiraiGo v0.0.0-2020082
2190748-ce670caee0a8
github.com/Mrs4s/MiraiGo v0.0.0-2020082
3184203-93de1f445681
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
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
...
...
go.sum
View file @
17f8232a
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-2020082
2102558-4dc018de2be7 h1:X6ebQxHSXRXDa3ZkMSFYnUhEIKdn6iPUmcFf2pl46oA
=
github.com/Mrs4s/MiraiGo v0.0.0-2020082
3075559-507fe33e842d h1:F7ssNQDHqB7NZVwTeADRY+AxKT3eeSlBzfzeZYTUfxM
=
github.com/Mrs4s/MiraiGo v0.0.0-2020082
2102558-4dc018de2be7
/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-2020082
3075559-507fe33e842d
/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-2020082
2190748-ce670caee0a8 h1:29b2Y1TehWby+jEXC7kjOvXk/PxwZ1BeFAKwOzTaW7M
=
github.com/Mrs4s/MiraiGo v0.0.0-2020082
3184203-93de1f445681 h1:hnaJH7BGD+Sb2Xb59SLpRy+f8B3Rx29Qy53ZM0AbIsE
=
github.com/Mrs4s/MiraiGo v0.0.0-2020082
2190748-ce670caee0a8
/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-2020082
3184203-93de1f445681
/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
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=
...
...
server/http.go
View file @
17f8232a
...
@@ -41,7 +41,7 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) {
...
@@ -41,7 +41,7 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) {
c
.
Status
(
404
)
c
.
Status
(
404
)
return
return
}
}
if
c
.
Request
.
Method
==
"POST"
&&
c
.
Request
.
Header
.
Get
(
"Content-Type"
)
==
"application/json"
{
if
c
.
Request
.
Method
==
"POST"
&&
strings
.
Contains
(
c
.
Request
.
Header
.
Get
(
"Content-Type"
),
"application/json"
)
{
d
,
err
:=
c
.
GetRawData
()
d
,
err
:=
c
.
GetRawData
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Warnf
(
"获取请求 %v 的Body时出现错误: %v"
,
c
.
Request
.
RequestURI
,
err
)
log
.
Warnf
(
"获取请求 %v 的Body时出现错误: %v"
,
c
.
Request
.
RequestURI
,
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