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
47cb3a52
Commit
47cb3a52
authored
Aug 10, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp message sending supported. #26
parent
4941f0c3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
5 deletions
+18
-5
coolq/bot.go
coolq/bot.go
+14
-4
coolq/event.go
coolq/event.go
+1
-0
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-0
No files found.
coolq/bot.go
View file @
47cb3a52
...
...
@@ -25,6 +25,7 @@ type CQBot struct {
friendReqCache
sync
.
Map
invitedReqCache
sync
.
Map
joinReqCache
sync
.
Map
tempMsgCache
sync
.
Map
}
type
MSG
map
[
string
]
interface
{}
...
...
@@ -101,7 +102,7 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int
continue
}
if
i
,
ok
:=
elem
.
(
*
message
.
VoiceElement
);
ok
{
gv
,
err
:=
bot
.
Client
.
UploadGroupPtt
(
groupId
,
i
.
Data
,
int32
(
len
(
i
.
Data
))
)
gv
,
err
:=
bot
.
Client
.
UploadGroupPtt
(
groupId
,
i
.
Data
)
if
err
!=
nil
{
log
.
Warnf
(
"警告: 群 %v 消息语音上传失败: %v"
,
groupId
,
err
)
continue
...
...
@@ -122,7 +123,7 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
if
i
,
ok
:=
elem
.
(
*
message
.
ImageElement
);
ok
{
fm
,
err
:=
bot
.
Client
.
UploadPrivateImage
(
target
,
i
.
Data
)
if
err
!=
nil
{
log
.
Warnf
(
"警告:
好友
%v 消息图片上传失败."
,
target
)
log
.
Warnf
(
"警告:
私聊
%v 消息图片上传失败."
,
target
)
continue
}
newElem
=
append
(
newElem
,
fm
)
...
...
@@ -131,8 +132,17 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
newElem
=
append
(
newElem
,
elem
)
}
m
.
Elements
=
newElem
ret
:=
bot
.
Client
.
SendPrivateMessage
(
target
,
m
)
return
ToGlobalId
(
target
,
ret
.
Id
)
var
id
int32
if
bot
.
Client
.
FindFriend
(
target
)
!=
nil
{
id
=
bot
.
Client
.
SendPrivateMessage
(
target
,
m
)
.
Id
}
else
{
if
code
,
ok
:=
bot
.
tempMsgCache
.
Load
(
target
);
ok
{
id
=
bot
.
Client
.
SendTempMessage
(
code
.
(
int64
),
target
,
m
)
.
Id
}
else
{
return
-
1
}
}
return
ToGlobalId
(
target
,
id
)
}
func
(
bot
*
CQBot
)
InsertGroupMessage
(
m
*
message
.
GroupMessage
)
int32
{
...
...
coolq/event.go
View file @
47cb3a52
...
...
@@ -119,6 +119,7 @@ func (bot *CQBot) groupMessageEvent(c *client.QQClient, m *message.GroupMessage)
func
(
bot
*
CQBot
)
tempMessageEvent
(
c
*
client
.
QQClient
,
m
*
message
.
TempMessage
)
{
checkImage
(
m
.
Elements
)
cqm
:=
ToStringMessage
(
m
.
Elements
,
0
,
true
)
bot
.
tempMsgCache
.
Store
(
m
.
Sender
.
Uin
,
m
.
GroupCode
)
log
.
Infof
(
"收到来自群 %v(%v) 内 %v(%v) 的临时会话消息: %v"
,
m
.
GroupName
,
m
.
GroupCode
,
m
.
Sender
.
DisplayName
(),
m
.
Sender
.
Uin
,
cqm
)
tm
:=
MSG
{
"post_type"
:
"message"
,
...
...
go.mod
View file @
47cb3a52
...
...
@@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-2020080
8044635-cd20d7d43db
b
github.com/Mrs4s/MiraiGo v0.0.0-2020080
9213751-626638e899e
b
github.com/gin-gonic/gin v1.6.3
github.com/gorilla/websocket v1.4.2
github.com/guonaihong/gout v0.1.1
...
...
go.sum
View file @
47cb3a52
...
...
@@ -6,6 +6,8 @@ github.com/Mrs4s/MiraiGo v0.0.0-20200808003732-2a32e623270d h1:K9jHdcO13mLqQB0xm
github.com/Mrs4s/MiraiGo v0.0.0-20200808003732-2a32e623270d/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-20200808044635-cd20d7d43dbb h1:XLe/UreYJRT65GStA3+irRL1Ao0pHZwBtCmTc+4prwA=
github.com/Mrs4s/MiraiGo v0.0.0-20200808044635-cd20d7d43dbb/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-20200809213751-626638e899eb h1:Upu/wTiTri0hMotSR76APxFo5PQX76iD5nMfl2/Ykt4=
github.com/Mrs4s/MiraiGo v0.0.0-20200809213751-626638e899eb/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
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=
...
...
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