Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-plugin-adapter-wecom
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
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
3rdeye
koishi-plugin-adapter-wecom
Commits
c1ea2edb
Commit
c1ea2edb
authored
Mar 18, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update behavior of broadcast
parent
00e20f8a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
src/bot.ts
src/bot.ts
+19
-4
No files found.
src/bot.ts
View file @
c1ea2edb
...
...
@@ -339,7 +339,11 @@ export class WeComBot extends Bot<BotConfig> {
return
this
.
sendPrivateMessage
(
channelId
,
content
);
}
async
sendPrivateMessage
(
userId
,
content
)
{
async
sendPrivateMessage
(
userId
:
string
,
content
:
string
,
extraUsers
:
string
[]
=
[],
)
{
const
session
=
await
this
.
session
({
content
,
subtype
:
'
private
'
,
...
...
@@ -347,6 +351,7 @@ export class WeComBot extends Bot<BotConfig> {
channelId
:
userId
,
});
if
(
!
session
?.
content
)
return
[];
const
userIds
=
[
userId
,
...
extraUsers
];
const
chain
=
segment
.
parse
(
session
.
content
);
const
messageIds
:
string
[]
=
[];
let
isMarkdown
=
false
;
...
...
@@ -361,8 +366,8 @@ export class WeComBot extends Bot<BotConfig> {
const
content
=
data
.
content
.
trim
();
messageIds
.
push
(
isMarkdown
?
await
this
.
sendMarkdownMessage
(
content
,
[
userId
]
)
:
await
this
.
sendTextMessage
(
content
,
[
userId
]
),
?
await
this
.
sendMarkdownMessage
(
content
,
userIds
)
:
await
this
.
sendTextMessage
(
content
,
userIds
),
);
break
;
case
'
image
'
:
...
...
@@ -381,7 +386,7 @@ export class WeComBot extends Bot<BotConfig> {
break
;
}
messageIds
.
push
(
await
this
.
sendMediaMessage
(
type
,
filename
,
buffer
,
[
userId
]
),
await
this
.
sendMediaMessage
(
type
,
filename
,
buffer
,
userIds
),
);
break
;
default
:
...
...
@@ -396,6 +401,16 @@ export class WeComBot extends Bot<BotConfig> {
return
messageIds
;
}
async
broadcast
(
channels
:
(
string
|
[
string
,
string
])[],
content
:
string
,
delay
=
this
.
app
.
options
.
delay
.
broadcast
,
)
{
const
userIds
=
channels
.
map
((
c
)
=>
(
typeof
c
===
'
string
'
?
c
:
c
[
0
]));
if
(
!
userIds
.
length
)
return
[];
return
this
.
sendPrivateMessage
(
userIds
[
0
],
content
,
userIds
.
slice
(
1
));
}
async
deleteMessage
(
channelId
:
string
,
messageId
:
string
)
{
const
token
=
await
this
.
getToken
();
if
(
!
token
)
{
...
...
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