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
8c63a420
Commit
8c63a420
authored
Sep 09, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: set_group_admin.
parent
b1fccbc0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
1 deletion
+40
-1
coolq/api.go
coolq/api.go
+20
-0
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-0
server/http.go
server/http.go
+9
-0
server/websocket.go
server/websocket.go
+8
-0
No files found.
coolq/api.go
View file @
8c63a420
...
...
@@ -404,6 +404,26 @@ func (bot *CQBot) CQDeleteMessage(messageId int32) MSG {
return
OK
(
nil
)
}
// https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#set_group_admin-%E7%BE%A4%E7%BB%84%E8%AE%BE%E7%BD%AE%E7%AE%A1%E7%90%86%E5%91%98
func
(
bot
*
CQBot
)
CQSetGroupAdmin
(
groupId
,
userId
int64
,
enable
bool
)
MSG
{
group
:=
bot
.
Client
.
FindGroup
(
groupId
)
if
group
==
nil
||
group
.
OwnerUin
!=
bot
.
Client
.
Uin
{
return
Failed
(
100
)
}
mem
:=
group
.
FindMember
(
userId
)
if
mem
==
nil
{
return
Failed
(
100
)
}
mem
.
SetAdmin
(
enable
)
t
,
err
:=
bot
.
Client
.
GetGroupMembers
(
group
)
if
err
!=
nil
{
log
.
Warnf
(
"刷新群 %v 成员列表失败: %v"
,
groupId
,
err
)
return
Failed
(
100
)
}
group
.
Members
=
t
return
OK
(
nil
)
}
func
(
bot
*
CQBot
)
CQGetVipInfo
(
userId
int64
)
MSG
{
msg
:=
MSG
{}
vip
,
err
:=
bot
.
Client
.
GetVipInfo
(
userId
)
...
...
go.mod
View file @
8c63a420
...
...
@@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-20200909
095006-dde8bded28d1
github.com/Mrs4s/MiraiGo v0.0.0-20200909
103204-808a63a78efe
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 @
8c63a420
...
...
@@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mrs4s/MiraiGo v0.0.0-20200909095006-dde8bded28d1 h1:3cmUqA5RaikLx+59SODlBA7tjORQoh4t1w5CzH5bIH8=
github.com/Mrs4s/MiraiGo v0.0.0-20200909095006-dde8bded28d1/go.mod h1:cwYPI2uq6nxNbx0nA6YuAKF1V5szSs6FPlGVLQvRUlo=
github.com/Mrs4s/MiraiGo v0.0.0-20200909103204-808a63a78efe h1:O2BW87BwpwZDsn7YFHLfRGFGvTS4OUZsG2UiA13OxcQ=
github.com/Mrs4s/MiraiGo v0.0.0-20200909103204-808a63a78efe/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 @
8c63a420
...
...
@@ -282,6 +282,12 @@ func (s *httpServer) SetGroupName(c *gin.Context) {
c
.
JSON
(
200
,
s
.
bot
.
CQSetGroupName
(
gid
,
getParam
(
c
,
"group_name"
)))
}
func
(
s
*
httpServer
)
SetGroupAdmin
(
c
*
gin
.
Context
)
{
gid
,
_
:=
strconv
.
ParseInt
(
getParam
(
c
,
"group_id"
),
10
,
64
)
uid
,
_
:=
strconv
.
ParseInt
(
getParam
(
c
,
"user_id"
),
10
,
64
)
c
.
JSON
(
200
,
s
.
bot
.
CQSetGroupAdmin
(
gid
,
uid
,
getParamOrDefault
(
c
,
"enable"
,
"true"
)
==
"true"
))
}
func
(
s
*
httpServer
)
SendGroupNotice
(
c
*
gin
.
Context
)
{
gid
,
_
:=
strconv
.
ParseInt
(
getParam
(
c
,
"group_id"
),
10
,
64
)
c
.
JSON
(
200
,
s
.
bot
.
CQSetGroupMemo
(
gid
,
getParam
(
c
,
"content"
)))
...
...
@@ -440,6 +446,9 @@ var httpApi = map[string]func(s *httpServer, c *gin.Context){
"set_group_name"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
SetGroupName
(
c
)
},
"set_group_admin"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
SetGroupAdmin
(
c
)
},
"_send_group_notice"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
SendGroupNotice
(
c
)
},
...
...
server/websocket.go
View file @
8c63a420
...
...
@@ -454,6 +454,14 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
"set_group_name"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQSetGroupName
(
p
.
Get
(
"group_id"
)
.
Int
(),
p
.
Get
(
"group_name"
)
.
Str
)
},
"set_group_admin"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQSetGroupAdmin
(
p
.
Get
(
"group_id"
)
.
Int
(),
p
.
Get
(
"user_id"
)
.
Int
(),
func
()
bool
{
if
p
.
Get
(
"enable"
)
.
Exists
()
{
return
p
.
Get
(
"enable"
)
.
Bool
()
}
return
true
}())
},
"_send_group_notice"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQSetGroupMemo
(
p
.
Get
(
"group_id"
)
.
Int
(),
p
.
Get
(
"content"
)
.
Str
)
},
...
...
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