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
04bcd2e2
Commit
04bcd2e2
authored
Aug 28, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
supported one-way friend msg. close #98
parent
0e7c30e8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
13 deletions
+22
-13
coolq/bot.go
coolq/bot.go
+16
-12
coolq/event.go
coolq/event.go
+3
-0
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-0
No files found.
coolq/bot.go
View file @
04bcd2e2
...
@@ -23,12 +23,13 @@ import (
...
@@ -23,12 +23,13 @@ import (
type
CQBot
struct
{
type
CQBot
struct
{
Client
*
client
.
QQClient
Client
*
client
.
QQClient
events
[]
func
(
MSG
)
events
[]
func
(
MSG
)
db
*
nutsdb
.
DB
db
*
nutsdb
.
DB
friendReqCache
sync
.
Map
friendReqCache
sync
.
Map
invitedReqCache
sync
.
Map
invitedReqCache
sync
.
Map
joinReqCache
sync
.
Map
joinReqCache
sync
.
Map
tempMsgCache
sync
.
Map
tempMsgCache
sync
.
Map
oneWayMsgCache
sync
.
Map
}
}
type
MSG
map
[
string
]
interface
{}
type
MSG
map
[
string
]
interface
{}
...
@@ -166,12 +167,15 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
...
@@ -166,12 +167,15 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
if
msg
!=
nil
{
if
msg
!=
nil
{
id
=
msg
.
Id
id
=
msg
.
Id
}
}
}
else
{
}
else
if
code
,
ok
:=
bot
.
tempMsgCache
.
Load
(
target
);
ok
{
if
code
,
ok
:=
bot
.
tempMsgCache
.
Load
(
target
);
ok
{
msg
:=
bot
.
Client
.
SendTempMessage
(
code
.
(
int64
),
target
,
m
)
msg
:=
bot
.
Client
.
SendTempMessage
(
code
.
(
int64
),
target
,
m
)
if
msg
!=
nil
{
if
msg
!=
nil
{
id
=
msg
.
Id
id
=
msg
.
Id
}
}
}
else
if
_
,
ok
:=
bot
.
oneWayMsgCache
.
Load
(
target
);
ok
{
msg
:=
bot
.
Client
.
SendPrivateMessage
(
target
,
m
)
if
msg
!=
nil
{
id
=
msg
.
Id
}
}
}
}
if
id
==
-
1
{
if
id
==
-
1
{
...
...
coolq/event.go
View file @
04bcd2e2
...
@@ -32,6 +32,9 @@ func ToFormattedMessage(e []message.IMessageElement, code int64, raw ...bool) (r
...
@@ -32,6 +32,9 @@ func ToFormattedMessage(e []message.IMessageElement, code int64, raw ...bool) (r
func
(
bot
*
CQBot
)
privateMessageEvent
(
c
*
client
.
QQClient
,
m
*
message
.
PrivateMessage
)
{
func
(
bot
*
CQBot
)
privateMessageEvent
(
c
*
client
.
QQClient
,
m
*
message
.
PrivateMessage
)
{
bot
.
checkMedia
(
m
.
Elements
)
bot
.
checkMedia
(
m
.
Elements
)
cqm
:=
ToStringMessage
(
m
.
Elements
,
0
,
true
)
cqm
:=
ToStringMessage
(
m
.
Elements
,
0
,
true
)
if
!
m
.
Sender
.
IsFriend
{
bot
.
oneWayMsgCache
.
Store
(
m
.
Sender
.
Uin
,
""
)
}
log
.
Infof
(
"收到好友 %v(%v) 的消息: %v"
,
m
.
Sender
.
DisplayName
(),
m
.
Sender
.
Uin
,
cqm
)
log
.
Infof
(
"收到好友 %v(%v) 的消息: %v"
,
m
.
Sender
.
DisplayName
(),
m
.
Sender
.
Uin
,
cqm
)
fm
:=
MSG
{
fm
:=
MSG
{
"post_type"
:
"message"
,
"post_type"
:
"message"
,
...
...
go.mod
View file @
04bcd2e2
...
@@ -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-2020082
5052841-d3b0f5f9e839
github.com/Mrs4s/MiraiGo v0.0.0-2020082
7162217-d7e61afdfe07
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/gorilla/websocket v1.4.2
github.com/gorilla/websocket v1.4.2
...
...
go.sum
View file @
04bcd2e2
...
@@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
...
@@ -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/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mrs4s/MiraiGo v0.0.0-20200825052841-d3b0f5f9e839 h1:TDhaPfWcubIMKDz1HU+N07SwIUjj7oVUQ7EXZBbDUxs=
github.com/Mrs4s/MiraiGo v0.0.0-20200825052841-d3b0f5f9e839 h1:TDhaPfWcubIMKDz1HU+N07SwIUjj7oVUQ7EXZBbDUxs=
github.com/Mrs4s/MiraiGo v0.0.0-20200825052841-d3b0f5f9e839/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-20200825052841-d3b0f5f9e839/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-20200827162217-d7e61afdfe07 h1:AO8HeAS3GbUIfLQHlM7sPfYYN/KsKUpTTB+gVZNvo30=
github.com/Mrs4s/MiraiGo v0.0.0-20200827162217-d7e61afdfe07/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
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=
...
...
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