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
062a8983
Commit
062a8983
authored
Sep 29, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev'
parents
43ecc259
83ce4e58
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
14 deletions
+44
-14
coolq/api.go
coolq/api.go
+14
-4
docs/cqhttp.md
docs/cqhttp.md
+22
-0
global/fs.go
global/fs.go
+3
-2
go.mod
go.mod
+1
-1
go.sum
go.sum
+4
-7
No files found.
coolq/api.go
View file @
062a8983
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"path"
"path"
"runtime"
"runtime"
"strconv"
"strconv"
"strings"
"time"
"time"
"github.com/Mrs4s/MiraiGo/binary"
"github.com/Mrs4s/MiraiGo/binary"
...
@@ -125,7 +126,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo
...
@@ -125,7 +126,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
)
log
.
Infof
(
"发送群 %v(%v) 的消息: %v (%v)"
,
groupId
,
groupId
,
limitedString
(
m
.
String
()
),
mid
)
return
OK
(
MSG
{
"message_id"
:
mid
})
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
str
=
func
()
string
{
str
=
func
()
string
{
...
@@ -152,7 +153,7 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, i interface{}, autoEscape bo
...
@@ -152,7 +153,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
)
log
.
Infof
(
"发送群 %v(%v) 的消息: %v (%v)"
,
groupId
,
groupId
,
limitedString
(
str
)
,
mid
)
return
OK
(
MSG
{
"message_id"
:
mid
})
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
...
@@ -249,7 +250,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b
...
@@ -249,7 +250,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
)
log
.
Infof
(
"发送好友 %v(%v) 的消息: %v (%v)"
,
userId
,
userId
,
limitedString
(
m
.
String
()
),
mid
)
return
OK
(
MSG
{
"message_id"
:
mid
})
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
str
=
func
()
string
{
str
=
func
()
string
{
...
@@ -274,7 +275,7 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, i interface{}, autoEscape b
...
@@ -274,7 +275,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
)
log
.
Infof
(
"发送好友 %v(%v) 的消息: %v (%v)"
,
userId
,
userId
,
limitedString
(
str
)
,
mid
)
return
OK
(
MSG
{
"message_id"
:
mid
})
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
...
@@ -758,3 +759,12 @@ func convertGroupMemberInfo(groupId int64, m *client.GroupMemberInfo) MSG {
...
@@ -758,3 +759,12 @@ func convertGroupMemberInfo(groupId int64, m *client.GroupMemberInfo) MSG {
"card_changeable"
:
false
,
"card_changeable"
:
false
,
}
}
}
}
func
limitedString
(
str
string
)
string
{
if
strings
.
Count
(
str
,
""
)
<=
10
{
return
str
}
limited
:=
[]
rune
(
str
)
limited
=
limited
[
:
10
]
return
string
(
limited
)
+
" ..."
}
docs/cqhttp.md
View file @
062a8983
...
@@ -268,6 +268,28 @@ Type: `cardimage`
...
@@ -268,6 +268,28 @@ Type: `cardimage`
| group_id | int64 | 群号 |
| group_id | int64 | 群号 |
| group_name | string | 新名 |
| group_name | string | 新名 |
### 设置群头像
终结点:
`/set_group_portrait`
**参数**
| 字段 | 类型 | 说明 |
| -------- | ------ | ---- |
| group_id | int64 | 群号 |
| file | string | 图片文件名 |
| cache | int | 表示是否使用已缓存的文件 |
[1]
`file`
参数支持以下几种格式:
-
绝对路径,例如
`file:///C:\\Users\Richard\Pictures\1.png`
,格式使用
[
`file` URI
](
https://tools.ietf.org/html/rfc8089
)
-
网络 URL,例如
`http://i1.piimg.com/567571/fdd6e7b6d93f1ef0.jpg`
-
Base64 编码,例如
`base64://iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAIAAADJt1n/AAAAKElEQVQ4EWPk5+RmIBcwkasRpG9UM4mhNxpgowFGMARGEwnBIEJVAAAdBgBNAZf+QAAAAABJRU5ErkJggg==`
[2]
`cache`
参数: 通过网络 URL 发送时有效,
`1`
表示使用缓存,
`0`
关闭关闭缓存,默认 为
`1`
[3] 目前这个API在登录一段时间后因cookie失效而失效,请考虑后使用
### 获取图片信息
### 获取图片信息
终结点:
`/get_image`
终结点:
`/get_image`
...
...
global/fs.go
View file @
062a8983
...
@@ -53,7 +53,7 @@ func IsAMRorSILK(b []byte) bool {
...
@@ -53,7 +53,7 @@ func IsAMRorSILK(b []byte) bool {
}
}
func
FindFile
(
f
,
cache
,
PATH
string
)
(
data
[]
byte
,
err
error
)
{
func
FindFile
(
f
,
cache
,
PATH
string
)
(
data
[]
byte
,
err
error
)
{
data
,
err
=
nil
,
errors
.
New
(
"
can't find the file: "
+
f
)
data
,
err
=
nil
,
errors
.
New
(
"
syntax error"
)
if
strings
.
HasPrefix
(
f
,
"http"
)
||
strings
.
HasPrefix
(
f
,
"https"
)
{
if
strings
.
HasPrefix
(
f
,
"http"
)
||
strings
.
HasPrefix
(
f
,
"https"
)
{
if
cache
==
""
{
if
cache
==
""
{
cache
=
"1"
cache
=
"1"
...
@@ -74,7 +74,8 @@ func FindFile(f, cache, PATH string) (data []byte, err error) {
...
@@ -74,7 +74,8 @@ func FindFile(f, cache, PATH string) (data []byte, err error) {
return
nil
,
err
return
nil
,
err
}
}
}
else
if
strings
.
HasPrefix
(
f
,
"file"
)
{
}
else
if
strings
.
HasPrefix
(
f
,
"file"
)
{
fu
,
err
:=
url
.
Parse
(
f
)
var
fu
*
url
.
URL
fu
,
err
=
url
.
Parse
(
f
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
go.mod
View file @
062a8983
...
@@ -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-2020092
6101830-afb0ed6368ad
github.com/Mrs4s/MiraiGo v0.0.0-2020092
9101232-fbb53eba9b5a
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/go-playground/validator/v10 v10.3.0 // indirect
github.com/go-playground/validator/v10 v10.3.0 // indirect
...
...
go.sum
View file @
062a8983
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-2020092
1142226-9a449519db5c h1:TpGiSjI8Pe0YLEQPAVkOV37OFLeJnQ6jxvcDSb/LESY
=
github.com/Mrs4s/MiraiGo v0.0.0-2020092
8082341-65c1709f5eec h1:lzFAr6b1yO6JIzfse0VIsPq71E0KfdsoS3VnyOLurS4
=
github.com/Mrs4s/MiraiGo v0.0.0-2020092
1142226-9a449519db5
c/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
github.com/Mrs4s/MiraiGo v0.0.0-2020092
8082341-65c1709f5ee
c/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
github.com/Mrs4s/MiraiGo v0.0.0-2020092
6101830-afb0ed6368ad h1:m4KU2n3desxr1L3Idk7qRlf71+77rm0JEMWqd4gmrlQ
=
github.com/Mrs4s/MiraiGo v0.0.0-2020092
9101232-fbb53eba9b5a h1:MaKFlcVI0aW7PFMrxpv2UBmvMGqKsiQP3O9j5wtVYYg
=
github.com/Mrs4s/MiraiGo v0.0.0-2020092
6101830-afb0ed6368ad
/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
github.com/Mrs4s/MiraiGo v0.0.0-2020092
9101232-fbb53eba9b5a
/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
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=
...
@@ -58,7 +58,6 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
...
@@ -58,7 +58,6 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
...
@@ -140,8 +139,6 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w
...
@@ -140,8 +139,6 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009 h1:W0lCpv29Hv0UaM1LXb9QlBHLNP8UFfcKjblhVCWftOM=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200916084744-dbad9cb7cb7a h1:chkwkn8HYWVtTE5DCQNKYlkyptadXYY0+PuyaVdyMo4=
golang.org/x/sys v0.0.0-20200916084744-dbad9cb7cb7a h1:chkwkn8HYWVtTE5DCQNKYlkyptadXYY0+PuyaVdyMo4=
golang.org/x/sys v0.0.0-20200916084744-dbad9cb7cb7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200916084744-dbad9cb7cb7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
...
...
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