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
a712db5d
Commit
a712db5d
authored
Oct 03, 2020
by
Mrs4s
Committed by
GitHub
Oct 03, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #339 from wdvxdr1123/dev
feature support .get_word_slices
parents
4c8ae2f0
030eb6b7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
4 deletions
+64
-4
coolq/api.go
coolq/api.go
+11
-0
coolq/cqcode.go
coolq/cqcode.go
+11
-2
docs/cqhttp.md
docs/cqhttp.md
+31
-1
global/net.go
global/net.go
+0
-1
server/http.go
server/http.go
+8
-0
server/websocket.go
server/websocket.go
+3
-0
No files found.
coolq/api.go
View file @
a712db5d
...
...
@@ -102,6 +102,17 @@ func (bot *CQBot) CQGetGroupMemberInfo(groupId, userId int64) MSG {
return
OK
(
convertGroupMemberInfo
(
groupId
,
member
))
}
func
(
bot
*
CQBot
)
CQGetWordSlices
(
content
string
)
MSG
{
slices
,
err
:=
bot
.
Client
.
GetWordSegmentation
(
content
)
if
err
!=
nil
{
return
Failed
(
100
)
}
for
i
:=
0
;
i
<
len
(
slices
);
i
++
{
slices
[
i
]
=
strings
.
ReplaceAll
(
slices
[
i
],
"
\u0000
"
,
""
)
}
return
OK
(
MSG
{
"slices"
:
slices
})
}
// https://cqhttp.cc/docs/4.15/#/API?id=send_group_msg-%E5%8F%91%E9%80%81%E7%BE%A4%E6%B6%88%E6%81%AF
func
(
bot
*
CQBot
)
CQSendGroupMessage
(
groupId
int64
,
i
interface
{},
autoEscape
bool
)
MSG
{
var
str
string
...
...
coolq/cqcode.go
View file @
a712db5d
...
...
@@ -361,9 +361,18 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
t
,
_
:=
strconv
.
ParseInt
(
d
[
"qq"
],
10
,
64
)
id
,
_
:=
strconv
.
Atoi
(
d
[
"id"
])
if
id
<
0
||
id
>=
9
{
return
nil
,
errors
.
New
(
"invalid gift id"
)
return
nil
,
errors
.
New
(
"invalid gift id"
)
}
return
&
GiftElement
{
Target
:
t
,
GiftId
:
GiftId
[
id
]},
nil
return
&
GiftElement
{
Target
:
t
,
GiftId
:
GiftId
[
id
]},
nil
case
"tts"
:
if
!
group
{
return
nil
,
errors
.
New
(
"private voice unsupported now"
)
}
data
,
err
:=
bot
.
Client
.
GetTts
(
d
[
"text"
])
if
err
!=
nil
{
return
nil
,
err
}
return
&
message
.
VoiceElement
{
Data
:
data
},
nil
case
"record"
:
if
!
group
{
return
nil
,
errors
.
New
(
"private voice unsupported now"
)
...
...
docs/cqhttp.md
View file @
a712db5d
...
...
@@ -287,6 +287,22 @@ Type: `cardimage`
[CQ:cardimage,file=https://i.pixiv.cat/img-master/img/2020/03/25/00/00/08/80334602_p0_master1200.jpg]
```
### 文本转语音
> 注意:通过TX的TTS接口,采用的音源与登录账号的性别有关
Type:
`tts`
范围:
**发送(仅群聊)**
参数:
| 参数名 | 类型 | 说明 |
| ------ | ------ | ----------- |
| text | string | 内容 |
示例:
`[CQ:tts,text=这是一条测试消息]`
## API
### 设置群名
...
...
@@ -418,7 +434,21 @@ Type: `cardimage`
|
`group_id`
| int64 | 群号 |
|
`messages`
| forward node[] | 自定义转发消息, 具体看CQCode |
###
### 获取中文分词
终结点:
`/.get_word_slices`
**参数**
| 字段 | 类型 | 说明 |
| ------------ | ------ | ------ |
|
`content`
| string | 内容 |
**响应数据**
| 字段 | 类型 | 说明 |
| ---------- | ----------------- | -------- |
|
`slices`
| string[] | 词组 |
## 事件
...
...
global/net.go
View file @
a712db5d
...
...
@@ -50,4 +50,3 @@ func NeteaseMusicSongInfo(id string) (gjson.Result, error) {
}
return
gjson
.
ParseBytes
(
d
)
.
Get
(
"songs.0"
),
nil
}
server/http.go
View file @
a712db5d
...
...
@@ -356,6 +356,11 @@ func (s *httpServer) OcrImage(c *gin.Context) {
c
.
JSON
(
200
,
s
.
bot
.
CQOcrImage
(
img
))
}
func
(
s
*
httpServer
)
GetWordSlices
(
c
*
gin
.
Context
)
{
content
:=
getParam
(
c
,
"content"
)
c
.
JSON
(
200
,
s
.
bot
.
CQGetWordSlices
(
content
))
}
func
(
s
*
httpServer
)
SetGroupPortrait
(
c
*
gin
.
Context
)
{
gid
,
_
:=
strconv
.
ParseInt
(
getParam
(
c
,
"group_id"
),
10
,
64
)
file
:=
getParam
(
c
,
"file"
)
...
...
@@ -520,4 +525,7 @@ var httpApi = map[string]func(s *httpServer, c *gin.Context){
".ocr_image"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
OcrImage
(
c
)
},
".get_word_slices"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
GetWordSlices
(
c
)
},
}
server/websocket.go
View file @
a712db5d
...
...
@@ -504,6 +504,9 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
".ocr_image"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQOcrImage
(
p
.
Get
(
"image"
)
.
Str
)
},
".get_word_slices"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQGetWordSlices
(
p
.
Get
(
"content"
)
.
Str
)
},
"set_group_portrait"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQSetGroupPortrait
(
p
.
Get
(
"group_id"
)
.
Int
(),
p
.
Get
(
"file"
)
.
String
(),
p
.
Get
(
"cache"
)
.
String
())
},
...
...
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