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
72d62ad7
Commit
72d62ad7
authored
Sep 21, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update MiraiGo.
parent
387d33a0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
7 deletions
+28
-7
coolq/api.go
coolq/api.go
+14
-0
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-6
server/http.go
server/http.go
+8
-0
server/websocket.go
server/websocket.go
+3
-0
No files found.
coolq/api.go
View file @
72d62ad7
...
...
@@ -648,6 +648,20 @@ func (bot *CQBot) CQCanSendRecord() MSG {
return
OK
(
MSG
{
"yes"
:
true
})
}
func
(
bot
*
CQBot
)
CQOcrImage
(
imageId
string
)
MSG
{
img
,
err
:=
bot
.
makeImageElem
(
"image"
,
map
[
string
]
string
{
"file"
:
imageId
},
true
)
if
err
!=
nil
{
log
.
Warnf
(
"load image error: %v"
,
err
)
return
Failed
(
100
)
}
rsp
,
err
:=
bot
.
Client
.
ImageOcr
(
img
)
if
err
!=
nil
{
log
.
Warnf
(
"ocr image error: %v"
,
err
)
return
Failed
(
100
)
}
return
OK
(
rsp
)
}
func
(
bot
*
CQBot
)
CQReloadEventFilter
()
MSG
{
global
.
BootFilter
()
return
OK
(
nil
)
...
...
go.mod
View file @
72d62ad7
...
...
@@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-202009211
34646-b16719557421
github.com/Mrs4s/MiraiGo v0.0.0-202009211
42226-9a449519db5c
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
github.com/gin-gonic/gin v1.6.3
github.com/go-playground/validator/v10 v10.3.0 // indirect
...
...
go.sum
View file @
72d62ad7
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/Mrs4s/MiraiGo v0.0.0-20200919083021-4013c077186d h1:LZ1pjJJ7sD/AOL8tvkTB9bPc0DiOErCNN+wWXUMyvX0=
github.com/Mrs4s/MiraiGo v0.0.0-20200919083021-4013c077186d/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
github.com/Mrs4s/MiraiGo v0.0.0-20200919153352-249af274638d h1:nGJSE9xQBeDiugBKKX0vUOq51MqlUEm/y2FMfZFH/w4=
github.com/Mrs4s/MiraiGo v0.0.0-20200919153352-249af274638d/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
github.com/Mrs4s/MiraiGo v0.0.0-20200921134646-b16719557421 h1:64KSlIHas2kUc6wc1N5QnkBrUAQpW78f++sqZOe1zAk=
github.com/Mrs4s/MiraiGo v0.0.0-20200921134646-b16719557421/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
github.com/Mrs4s/MiraiGo v0.0.0-20200921142226-9a449519db5c h1:TpGiSjI8Pe0YLEQPAVkOV37OFLeJnQ6jxvcDSb/LESY=
github.com/Mrs4s/MiraiGo v0.0.0-20200921142226-9a449519db5c/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
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=
...
...
server/http.go
View file @
72d62ad7
...
...
@@ -349,6 +349,11 @@ func (s *httpServer) HandleQuickOperation(c *gin.Context) {
}
}
func
(
s
*
httpServer
)
OcrImage
(
c
*
gin
.
Context
)
{
img
:=
getParam
(
c
,
"image"
)
c
.
JSON
(
200
,
s
.
bot
.
CQOcrImage
(
img
))
}
func
getParamOrDefault
(
c
*
gin
.
Context
,
k
,
def
string
)
string
{
r
:=
getParam
(
c
,
k
)
if
r
!=
""
{
...
...
@@ -500,4 +505,7 @@ var httpApi = map[string]func(s *httpServer, c *gin.Context){
".handle_quick_operation"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
HandleQuickOperation
(
c
)
},
".ocr_image"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
OcrImage
(
c
)
},
}
server/websocket.go
View file @
72d62ad7
...
...
@@ -501,6 +501,9 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
"reload_event_filter"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQReloadEventFilter
()
},
".ocr_image"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQOcrImage
(
p
.
Get
(
"image"
)
.
Str
)
},
".handle_quick_operation"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQHandleQuickOperation
(
p
.
Get
(
"context"
),
p
.
Get
(
"operation"
))
},
...
...
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