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
a0c30ed4
Commit
a0c30ed4
authored
Dec 18, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better type
parent
53f5352c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
66 deletions
+69
-66
dev/index.ts
dev/index.ts
+8
-8
src/def/events.ts
src/def/events.ts
+55
-0
src/index.ts
src/index.ts
+6
-58
No files found.
dev/index.ts
View file @
a0c30ed4
...
...
@@ -107,15 +107,15 @@ app.command('dish').action(async (argv) => {
card_type
:
'
multiple_interaction
'
,
},
[
segment
(
'
main
T
itle
'
,
{
segment
(
'
main
_t
itle
'
,
{
title
:
'
晚上想吃什么?
'
,
desc
:
'
有很多好吃的呢!
'
,
}),
segment
(
'
select
L
ist
'
,
{},
[
segment
(
'
select
_l
ist
'
,
{},
[
segment
(
''
,
{
question
K
ey
:
'
main
'
,
question
_k
ey
:
'
main
'
,
title
:
'
主食
'
,
},
[
...
...
@@ -126,7 +126,7 @@ app.command('dish').action(async (argv) => {
segment
(
''
,
{
question
K
ey
:
'
meat
'
,
question
_k
ey
:
'
meat
'
,
title
:
'
肉类
'
,
},
[
...
...
@@ -138,11 +138,11 @@ app.command('dish').action(async (argv) => {
segment
(
''
,
{
question
K
ey
:
'
soup
'
,
question
_k
ey
:
'
soup
'
,
title
:
'
汤
'
,
},
[
segment
(
'
option
L
ist
'
,
{},
[
segment
(
'
option
_l
ist
'
,
{},
[
segment
(
''
,
{
id
:
'
tomato
'
,
text
:
'
番茄汤
'
}),
segment
(
''
,
{
id
:
'
mushroom
'
,
text
:
'
蘑菇汤
'
}),
segment
(
''
,
{
id
:
'
fish
'
,
text
:
'
鱼汤
'
}),
...
...
@@ -150,7 +150,7 @@ app.command('dish').action(async (argv) => {
],
),
]),
segment
(
'
submit
B
utton
'
,
{
segment
(
'
submit
_b
utton
'
,
{
text
:
'
点菜!
'
,
key
:
'
submit
'
,
}),
...
...
@@ -170,7 +170,7 @@ app.command('dish').action(async (argv) => {
});
app
.
on
(
'
bot-status-updated
'
,
(
bot
)
=>
{
console
.
log
(
`Bot
${
bot
.
s
elfI
d
}
status updated:
${
bot
.
status
}
`
);
console
.
log
(
`Bot
${
bot
.
s
i
d
}
status updated:
${
bot
.
status
}
`
);
});
app
.
start
();
src/def/events.ts
View file @
a0c30ed4
import
{
WecomEventBody
}
from
'
./def
'
;
import
{
Session
}
from
'
koishi
'
;
import
{
ChangeContact
}
from
'
./specific/ChangeContact
'
;
import
{
ApprovalInfo
}
from
'
./specific/ApprovalInfo
'
;
type
MayBeArray
<
T
>
=
T
|
T
[];
...
...
@@ -52,3 +54,56 @@ export interface CardEvent extends CardMenuEvent {
export
type
WecomEventFunction
<
T
=
{}
>
=
(
session
:
Session
&
{
wecom
:
WecomEventBody
&
T
},
)
=>
void
;
export
interface
WecomInternalEvents
{
enter_agent
:
{};
subscribe
:
{};
unsubscribe
:
{};
LOCATION
:
{
Latitude
:
number
;
Longitude
:
number
;
Precision
:
number
;
};
batch_job_result
:
{
BatchJob
:
{
JobId
:
string
;
JobType
:
string
;
ErrCode
:
number
;
ErrMsg
:
string
;
};
};
click
:
EventKeyBody
;
view
:
EventKeyBody
;
scancode_push
:
ScanCodeEventBody
;
scancode_waitmsg
:
ScanCodeEventBody
;
pic_sysphoto
:
PhotoEventBody
;
pic_photo_or_album
:
PhotoEventBody
;
pic_weixin
:
PhotoEventBody
;
location_select
:
EventKeyBody
&
{
SendLocationInfo
:
{
Location_X
:
number
;
Location_Y
:
number
;
Scale
:
number
;
Label
:
string
;
Poiname
:
string
;
};
};
share_agent_change
:
{};
share_chain_change
:
{};
template_card_event
:
CardEvent
&
{
SelectedItems
:
CardEventSelectedItems
;
};
template_card_menu_event
:
CardEvent
;
open_approval_change
:
{
ApprovalInfo
:
ApprovalInfo
;
};
change_contact
:
ChangeContact
;
}
export
type
WecomEvents
=
{
[
K
in
keyof
WecomInternalEvents
as
`wecom/
${
K
}
`
]:
WecomEventFunction
<
WecomInternalEvents
[
K
]
>
;
};
src/index.ts
View file @
a0c30ed4
...
...
@@ -11,25 +11,16 @@ import {
}
from
'
koishi
'
;
import
{
adaptMenu
,
ApprovalInfo
,
CardEvent
,
CardEventSelectedItems
,
ChangeContact
,
EventKeyBody
,
PhotoEventBody
,
ScanCodeEventBody
,
TokenReturnMessage
,
WeComAgentInfo
,
WecomEventBody
,
WecomEvent
Function
,
WecomEvent
s
,
WecomMenuDef
,
WecomSendMessageResponse
,
WeComUser
,
}
from
'
./def
'
;
import
{
Apply
,
DefinePlugin
,
DefineSchema
,
Inject
,
InjectLogger
,
PluginDef
,
...
...
@@ -50,57 +41,14 @@ declare global {
interface
Session
{
wecom
?:
WecomEventBody
;
}
interface
Events
{
'
wecom/enter_agent
'
:
WecomEventFunction
;
'
wecom/subscribe
'
:
WecomEventFunction
;
'
wecom/unsubscribe
'
:
WecomEventFunction
;
'
wecom/LOCATION
'
:
WecomEventFunction
<
{
Latitude
:
number
;
Longitude
:
number
;
Precision
:
number
;
}
>
;
'
wecom/batch_job_result
'
:
WecomEventFunction
<
{
BatchJob
:
{
JobId
:
string
;
JobType
:
string
;
ErrCode
:
number
;
ErrMsg
:
string
;
};
}
>
;
'
wecom/click
'
:
WecomEventFunction
<
EventKeyBody
>
;
'
wecom/view
'
:
WecomEventFunction
<
EventKeyBody
>
;
'
wecom/scancode_push
'
:
WecomEventFunction
<
ScanCodeEventBody
>
;
'
wecom/scancode_waitmsg
'
:
WecomEventFunction
<
ScanCodeEventBody
>
;
'
wecom/pic_sysphoto
'
:
WecomEventFunction
<
PhotoEventBody
>
;
'
wecom/pic_photo_or_album
'
:
WecomEventFunction
<
PhotoEventBody
>
;
'
wecom/pic_weixin
'
:
WecomEventFunction
<
PhotoEventBody
>
;
'
wecom/location_select
'
:
WecomEventFunction
<
EventKeyBody
&
{
SendLocationInfo
:
{
Location_X
:
number
;
Location_Y
:
number
;
Scale
:
number
;
Label
:
string
;
Poiname
:
string
;
};
}
>
;
'
wecom/share_agent_change
'
:
WecomEventFunction
;
'
wecom/share_chain_change
'
:
WecomEventFunction
;
'
wecom/template_card_event
'
:
WecomEventFunction
<
CardEvent
&
{
SelectedItems
:
CardEventSelectedItems
;
}
>
;
'
wecom/template_card_menu_event
'
:
WecomEventFunction
<
CardEvent
>
;
'
wecom/open_approval_change
'
:
WecomEventFunction
<
{
ApprovalInfo
:
ApprovalInfo
;
}
>
;
'
wecom/change_contact
'
:
WecomEventFunction
<
ChangeContact
>
;
}
}
}
declare
module
'
koishi
'
{
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface
Events
extends
WecomEvents
{}
}
@
RegisterSchema
()
export
class
WeComBotConfig
{
@
SchemaProperty
({
...
...
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