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
06fccbd9
Commit
06fccbd9
authored
Aug 02, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix http api send raw msg error.
parent
81d2ad3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
38 deletions
+57
-38
coolq/api.go
coolq/api.go
+54
-35
coolq/bot.go
coolq/bot.go
+1
-1
server/http.go
server/http.go
+2
-2
No files found.
coolq/api.go
View file @
06fccbd9
...
@@ -96,28 +96,36 @@ func (bot *CQBot) CQGetGroupMemberInfo(groupId, userId int64, noCache bool) MSG
...
@@ -96,28 +96,36 @@ func (bot *CQBot) CQGetGroupMemberInfo(groupId, userId int64, noCache bool) MSG
}
}
// 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
// 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
,
m
gjson
.
Result
)
MSG
{
func
(
bot
*
CQBot
)
CQSendGroupMessage
(
groupId
int64
,
i
interface
{}
)
MSG
{
if
m
.
Type
==
gjson
.
String
{
var
str
string
str
:=
m
.
Str
if
m
,
ok
:=
i
.
(
gjson
.
Result
);
ok
{
if
str
==
""
{
if
m
.
Type
==
gjson
.
JSON
{
return
Failed
(
100
)
elem
:=
bot
.
ConvertObjectMessage
(
m
,
true
)
}
mid
:=
bot
.
SendGroupMessage
(
groupId
,
&
message
.
SendingMessage
{
Elements
:
elem
})
elem
:=
bot
.
ConvertStringMessage
(
str
,
true
)
if
mid
==
-
1
{
mid
:=
bot
.
SendGroupMessage
(
groupId
,
&
message
.
SendingMessage
{
Elements
:
elem
}
)
return
Failed
(
100
)
if
mid
==
-
1
{
}
return
Failed
(
100
)
return
OK
(
MSG
{
"message_id"
:
mid
}
)
}
}
return
OK
(
MSG
{
"message_id"
:
mid
})
str
=
func
()
string
{
if
m
.
Str
!=
""
{
return
m
.
Str
}
return
m
.
Raw
}()
}
}
if
m
.
Type
==
gjson
.
JSON
{
if
s
,
ok
:=
i
.
(
string
);
ok
{
elem
:=
bot
.
ConvertObjectMessage
(
m
,
true
)
str
=
s
mid
:=
bot
.
SendGroupMessage
(
groupId
,
&
message
.
SendingMessage
{
Elements
:
elem
})
if
mid
==
-
1
{
return
Failed
(
100
)
}
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
return
Failed
(
100
)
if
str
==
""
{
return
Failed
(
100
)
}
elem
:=
bot
.
ConvertStringMessage
(
str
,
true
)
mid
:=
bot
.
SendGroupMessage
(
groupId
,
&
message
.
SendingMessage
{
Elements
:
elem
})
if
mid
==
-
1
{
return
Failed
(
100
)
}
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
func
(
bot
*
CQBot
)
CQSendGroupForwardMessage
(
groupId
int64
,
m
gjson
.
Result
)
MSG
{
func
(
bot
*
CQBot
)
CQSendGroupForwardMessage
(
groupId
int64
,
m
gjson
.
Result
)
MSG
{
...
@@ -191,25 +199,36 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG {
...
@@ -191,25 +199,36 @@ func (bot *CQBot) CQSendGroupForwardMessage(groupId int64, m gjson.Result) MSG {
}
}
// https://cqhttp.cc/docs/4.15/#/API?id=send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF
// https://cqhttp.cc/docs/4.15/#/API?id=send_private_msg-%E5%8F%91%E9%80%81%E7%A7%81%E8%81%8A%E6%B6%88%E6%81%AF
func
(
bot
*
CQBot
)
CQSendPrivateMessage
(
userId
int64
,
m
gjson
.
Result
)
MSG
{
func
(
bot
*
CQBot
)
CQSendPrivateMessage
(
userId
int64
,
i
interface
{})
MSG
{
if
m
.
Type
==
gjson
.
String
{
var
str
string
str
:=
m
.
Str
if
m
,
ok
:=
i
.
(
gjson
.
Result
);
ok
{
elem
:=
bot
.
ConvertStringMessage
(
str
,
false
)
if
m
.
Type
==
gjson
.
JSON
{
mid
:=
bot
.
SendPrivateMessage
(
userId
,
&
message
.
SendingMessage
{
Elements
:
elem
})
elem
:=
bot
.
ConvertObjectMessage
(
m
,
true
)
if
mid
==
-
1
{
mid
:=
bot
.
SendPrivateMessage
(
userId
,
&
message
.
SendingMessage
{
Elements
:
elem
})
return
Failed
(
100
)
if
mid
==
-
1
{
return
Failed
(
100
)
}
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
return
OK
(
MSG
{
"message_id"
:
mid
})
str
=
func
()
string
{
if
m
.
Str
!=
""
{
return
m
.
Str
}
return
m
.
Raw
}()
}
}
if
m
.
Type
==
gjson
.
JSON
{
if
s
,
ok
:=
i
.
(
string
);
ok
{
elem
:=
bot
.
ConvertObjectMessage
(
m
,
true
)
str
=
s
mid
:=
bot
.
SendPrivateMessage
(
userId
,
&
message
.
SendingMessage
{
Elements
:
elem
})
if
mid
==
-
1
{
return
Failed
(
100
)
}
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
return
Failed
(
100
)
if
str
==
""
{
return
Failed
(
100
)
}
elem
:=
bot
.
ConvertStringMessage
(
str
,
false
)
mid
:=
bot
.
SendPrivateMessage
(
userId
,
&
message
.
SendingMessage
{
Elements
:
elem
})
if
mid
==
-
1
{
return
Failed
(
100
)
}
return
OK
(
MSG
{
"message_id"
:
mid
})
}
}
// https://cqhttp.cc/docs/4.15/#/API?id=set_group_card-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D%E7%89%87%EF%BC%88%E7%BE%A4%E5%A4%87%E6%B3%A8%EF%BC%89
// https://cqhttp.cc/docs/4.15/#/API?id=set_group_card-%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%90%8D%E7%89%87%EF%BC%88%E7%BE%A4%E5%A4%87%E6%B3%A8%EF%BC%89
...
...
coolq/bot.go
View file @
06fccbd9
...
@@ -93,7 +93,7 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int
...
@@ -93,7 +93,7 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int
if
i
,
ok
:=
elem
.
(
*
message
.
ImageElement
);
ok
{
if
i
,
ok
:=
elem
.
(
*
message
.
ImageElement
);
ok
{
gm
,
err
:=
bot
.
Client
.
UploadGroupImage
(
groupId
,
i
.
Data
)
gm
,
err
:=
bot
.
Client
.
UploadGroupImage
(
groupId
,
i
.
Data
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Warnf
(
"警告: 群 %v 消息图片上传失败
."
,
groupId
)
log
.
Warnf
(
"警告: 群 %v 消息图片上传失败
: %v"
,
groupId
,
err
)
continue
continue
}
}
newElem
=
append
(
newElem
,
gm
)
newElem
=
append
(
newElem
,
gm
)
...
...
server/http.go
View file @
06fccbd9
...
@@ -239,7 +239,7 @@ func (s *httpServer) SendPrivateMessage(c *gin.Context) {
...
@@ -239,7 +239,7 @@ func (s *httpServer) SendPrivateMessage(c *gin.Context) {
c
.
JSON
(
200
,
s
.
bot
.
CQSendPrivateMessage
(
uid
,
gjson
.
Parse
(
msg
)))
c
.
JSON
(
200
,
s
.
bot
.
CQSendPrivateMessage
(
uid
,
gjson
.
Parse
(
msg
)))
return
return
}
}
c
.
JSON
(
200
,
s
.
bot
.
CQSendPrivateMessage
(
uid
,
gjson
.
Result
{
Type
:
gjson
.
String
,
Str
:
msg
}
))
c
.
JSON
(
200
,
s
.
bot
.
CQSendPrivateMessage
(
uid
,
msg
))
}
}
func
(
s
*
httpServer
)
SendGroupMessage
(
c
*
gin
.
Context
)
{
func
(
s
*
httpServer
)
SendGroupMessage
(
c
*
gin
.
Context
)
{
...
@@ -249,7 +249,7 @@ func (s *httpServer) SendGroupMessage(c *gin.Context) {
...
@@ -249,7 +249,7 @@ func (s *httpServer) SendGroupMessage(c *gin.Context) {
c
.
JSON
(
200
,
s
.
bot
.
CQSendGroupMessage
(
gid
,
gjson
.
Parse
(
msg
)))
c
.
JSON
(
200
,
s
.
bot
.
CQSendGroupMessage
(
gid
,
gjson
.
Parse
(
msg
)))
return
return
}
}
c
.
JSON
(
200
,
s
.
bot
.
CQSendGroupMessage
(
gid
,
gjson
.
Result
{
Type
:
gjson
.
String
,
Str
:
msg
}
))
c
.
JSON
(
200
,
s
.
bot
.
CQSendGroupMessage
(
gid
,
msg
))
}
}
func
(
s
*
httpServer
)
SendGroupForwardMessage
(
c
*
gin
.
Context
)
{
func
(
s
*
httpServer
)
SendGroupForwardMessage
(
c
*
gin
.
Context
)
{
...
...
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