Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-plugin-act
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
3rdeye
koishi-plugin-act
Commits
c627a968
Commit
c627a968
authored
Oct 05, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
half
parent
420d8bd3
Pipeline
#6078
failed with stage
in 1 minute and 19 seconds
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
200 additions
and
172 deletions
+200
-172
README.md
README.md
+2
-2
package-lock.json
package-lock.json
+147
-145
package.json
package.json
+4
-4
src/index.ts
src/index.ts
+4
-2
src/playbook/Show.ts
src/playbook/Show.ts
+5
-5
src/plugin.ts
src/plugin.ts
+38
-14
No files found.
README.md
View file @
c627a968
...
@@ -44,7 +44,7 @@ export interface Config {
...
@@ -44,7 +44,7 @@ export interface Config {
### 说明
### 说明
*
`adminContext`
一个上下文函数,设置管理员接口作用域。如
`(ctx) => ctx.private('1111111111')`
为只对 QQ 号是 1111111111 的私聊消息有效
。
*
`adminContext`
管理员接口作用域
。
*
`autoChangeName`
公演开始之前是否修改每个演员机器人的群名片。推荐开启。
*
`autoChangeName`
公演开始之前是否修改每个演员机器人的群名片。推荐开启。
...
@@ -60,4 +60,4 @@ export interface Config {
...
@@ -60,4 +60,4 @@ export interface Config {
*
`groupId`
目标群。
`playbookFilename`
是公演剧本文件,需要在服务器放好。后面的参数可以以 人物名=帐号 的形式指定特定的人物,否则随机分配。
*
`groupId`
目标群。
`playbookFilename`
是公演剧本文件,需要在服务器放好。后面的参数可以以 人物名=帐号 的形式指定特定的人物,否则随机分配。
*
例:
`act.create 11111111 play1 幽幽子=2222222`
在群 11111111 创建一个公演,剧本是 play1,位于
`/path/to/playbookPathPrefix/play1.json`
,同时指定人物幽幽子为 2222222 扮演。
*
例:
`act.create 11111111 play1 幽幽子=2222222`
在群 11111111 创建一个公演,剧本是 play1,位于
`/path/to/playbookPathPrefix/play1.json`
,同时指定人物幽幽子为 2222222 扮演。
*
`.delete <groupId:number>`
停止公演。
*
`.delete <groupId:number>`
停止公演。
\ No newline at end of file
package-lock.json
View file @
c627a968
This diff is collapsed.
Click to expand it.
package.json
View file @
c627a968
...
@@ -7,10 +7,11 @@
...
@@ -7,10 +7,11 @@
"
source-map-support
"
:
"
^0.5.19
"
"
source-map-support
"
:
"
^0.5.19
"
},
},
"peerDependencies"
:
{
"peerDependencies"
:
{
"
koishi
-adapter-onebot
"
:
"
^3.1.0
"
,
"
koishi
"
:
"
^4.0.0-alpha.8
"
,
"
koishi-core
"
:
"
^3.13.0
"
"
@koishijs/plugin-onebot
"
:
"
^4.0.0-alpha.7
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@koishijs/plugin-onebot
"
:
"
^4.0.0-alpha.7
"
,
"
@types/lodash
"
:
"
^4.14.172
"
,
"
@types/lodash
"
:
"
^4.14.172
"
,
"
@types/mustache
"
:
"
^4.1.2
"
,
"
@types/mustache
"
:
"
^4.1.2
"
,
"
@types/node
"
:
"
^16.4.11
"
,
"
@types/node
"
:
"
^16.4.11
"
,
...
@@ -21,8 +22,7 @@
...
@@ -21,8 +22,7 @@
"
eslint
"
:
"
^7.32.0
"
,
"
eslint
"
:
"
^7.32.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.0
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.0
"
,
"
koishi-adapter-onebot
"
:
"
^3.1.0
"
,
"
koishi
"
:
"
^4.0.0-alpha.8
"
,
"
koishi-core
"
:
"
^3.13.0
"
,
"
load-json-file
"
:
"
^6.2.0
"
,
"
load-json-file
"
:
"
^6.2.0
"
,
"
lodash
"
:
"
^4.17.21
"
,
"
lodash
"
:
"
^4.17.21
"
,
"
moment
"
:
"
^2.29.1
"
,
"
moment
"
:
"
^2.29.1
"
,
...
...
src/index.ts
View file @
c627a968
...
@@ -3,7 +3,9 @@ import type { Context } from 'koishi-core';
...
@@ -3,7 +3,9 @@ import type { Context } from 'koishi-core';
import
{
Config
,
MyPlugin
}
from
'
./plugin
'
;
import
{
Config
,
MyPlugin
}
from
'
./plugin
'
;
export
{
Config
}
from
'
./plugin
'
;
export
{
Config
}
from
'
./plugin
'
;
export
const
name
=
'
act-index
'
;
export
const
name
=
'
act-index
'
;
const
plugin
=
new
MyPlugin
();
export
const
schema
=
plugin
.
schema
;
export
function
apply
(
ctx
:
Context
,
config
:
Config
)
{
export
function
apply
(
ctx
:
Context
,
config
:
Config
)
{
ctx
.
plugin
(
new
MyPlugin
()
,
config
);
ctx
.
plugin
(
plugin
,
config
);
}
}
src/playbook/Show.ts
View file @
c627a968
import
{
Playbook
}
from
'
./Playbook
'
;
import
{
Playbook
}
from
'
./Playbook
'
;
import
type
{
CQBot
}
from
'
koishi-adapter
-onebot
'
;
import
type
{
OneBotBot
}
from
'
@koishijs/plugin
-onebot
'
;
import
moment
,
{
Moment
}
from
'
moment
'
;
import
moment
,
{
Moment
}
from
'
moment
'
;
export
enum
ShowStatus
{
export
enum
ShowStatus
{
...
@@ -10,7 +10,7 @@ export enum ShowStatus {
...
@@ -10,7 +10,7 @@ export enum ShowStatus {
export
class
Show
{
export
class
Show
{
status
:
ShowStatus
=
ShowStatus
.
Idle
;
status
:
ShowStatus
=
ShowStatus
.
Idle
;
private
characterBotMap
=
new
Map
<
number
,
CQ
Bot
>
();
private
characterBotMap
=
new
Map
<
number
,
OneBot
Bot
>
();
// eslint-disable-next-line @typescript-eslint/no-empty-function
// eslint-disable-next-line @typescript-eslint/no-empty-function
onFinish
:
(
message
:
string
,
show
:
Show
)
=>
void
=
()
=>
{};
onFinish
:
(
message
:
string
,
show
:
Show
)
=>
void
=
()
=>
{};
private
step
=
0
;
private
step
=
0
;
...
@@ -30,7 +30,7 @@ export class Show {
...
@@ -30,7 +30,7 @@ export class Show {
private
getPerformingBots
()
{
private
getPerformingBots
()
{
return
Array
.
from
(
this
.
characterBotMap
.
values
());
return
Array
.
from
(
this
.
characterBotMap
.
values
());
}
}
useCharacter
(
id
:
number
,
bot
:
CQ
Bot
)
{
useCharacter
(
id
:
number
,
bot
:
OneBot
Bot
)
{
this
.
characterBotMap
.
set
(
id
,
bot
);
this
.
characterBotMap
.
set
(
id
,
bot
);
}
}
isCharacterFull
()
{
isCharacterFull
()
{
...
@@ -38,8 +38,8 @@ export class Show {
...
@@ -38,8 +38,8 @@ export class Show {
this
.
characterBotMap
.
has
(
c
.
id
),
this
.
characterBotMap
.
has
(
c
.
id
),
);
);
}
}
async
autoCharacters
(
bots
:
CQ
Bot
[])
{
async
autoCharacters
(
bots
:
OneBot
Bot
[])
{
let
availableBots
:
CQ
Bot
[]
=
[];
let
availableBots
:
OneBot
Bot
[]
=
[];
const
botNameMap
=
new
Map
<
string
,
string
>
();
const
botNameMap
=
new
Map
<
string
,
string
>
();
for
(
const
bot
of
bots
)
{
for
(
const
bot
of
bots
)
{
if
(
!
(
bot
.
type
&&
bot
.
type
.
startsWith
(
'
onebot
'
)))
{
if
(
!
(
bot
.
type
&&
bot
.
type
.
startsWith
(
'
onebot
'
)))
{
...
...
src/plugin.ts
View file @
c627a968
import
'
source-map-support/register
'
;
import
'
source-map-support/register
'
;
import
type
{
Context
,
Session
}
from
'
koishi-core
'
;
import
{
Context
,
Schema
,
Session
}
from
'
koishi
'
;
import
{
Show
}
from
'
./playbook/Show
'
;
import
{
Show
}
from
'
./playbook/Show
'
;
import
{
Playbook
}
from
'
./playbook/Playbook
'
;
import
{
Playbook
}
from
'
./playbook/Playbook
'
;
import
{
plainToClass
}
from
'
class-transformer
'
;
import
{
plainToClass
}
from
'
class-transformer
'
;
import
loadJsonFile
from
'
load-json-file
'
;
import
loadJsonFile
from
'
load-json-file
'
;
import
type
{
CQBot
}
from
'
koishi-adapter-onebot
'
;
import
{
MaybeArray
}
from
'
koishi
'
;
const
selectors
=
[
'
user
'
,
'
guild
'
,
'
channel
'
,
'
self
'
,
'
private
'
,
'
platform
'
,
]
as
const
;
type
SelectorType
=
typeof
selectors
[
number
];
type
SelectorValue
=
boolean
|
MaybeArray
<
string
|
number
>
;
type
BaseSelection
=
{
[
K
in
SelectorType
as
`$
${
K
}
`
]?:
SelectorValue
};
export
interface
Selection
extends
BaseSelection
{
$and
?:
Selection
[];
$or
?:
Selection
[];
$not
?:
Selection
;
}
export
interface
Config
{
export
interface
Config
{
adminContext
:
(
ctx
:
Context
)
=>
Context
;
adminContext
:
Selection
;
autoChangeName
:
boolean
;
autoChangeName
:
boolean
;
dropHelp
:
boolean
;
dropHelp
:
boolean
;
playbookPathPrefix
:
string
;
playbookPathPrefix
:
string
;
...
@@ -20,20 +39,25 @@ export class MyPlugin {
...
@@ -20,20 +39,25 @@ export class MyPlugin {
shows
=
new
Map
<
number
,
Show
>
();
shows
=
new
Map
<
number
,
Show
>
();
name
=
'
act
'
;
name
=
'
act
'
;
schema
:
Schema
<
Config
>
=
Schema
.
object
({
adminContext
:
Schema
.
any
(
'
管理员接口作用域。
'
),
autoChangeName
:
Schema
.
boolean
(
'
公演开始之前是否修改每个演员机器人的群名片。推荐开启。
'
,
).
default
(
true
),
playbookPathPrefix
:
Schema
.
string
(
'
公演剧本存放路径。公演剧本的文件名是 `/path/to/playbookPathPrefix/name.json` 对应于 name 剧本。
'
,
).
default
(
'
./playbooks
'
),
dropHelp
:
Schema
.
boolean
(
'
是否删除 `help` 命令,避免社死 (?)
'
).
default
(
false
,
),
});
apply
(
ctx
:
Context
,
config
:
Config
)
{
apply
(
ctx
:
Context
,
config
:
Config
)
{
this
.
ctx
=
ctx
;
this
.
ctx
=
ctx
;
this
.
config
=
{
this
.
config
=
Schema
.
validate
(
config
,
this
.
schema
);
adminContext
:
(
ctx
)
=>
ctx
.
private
(),
autoChangeName
:
false
,
dropHelp
:
false
,
playbookPathPrefix
:
'
./playbooks
'
,
...
config
,
};
if
(
this
.
config
.
dropHelp
)
{
if
(
this
.
config
.
dropHelp
)
{
ctx
.
command
(
'
help
'
).
dispose
();
ctx
.
command
(
'
help
'
).
dispose
();
}
}
this
.
adminCtx
=
this
.
c
onfig
.
adminContext
(
ctx
);
this
.
adminCtx
=
this
.
c
tx
.
select
(
this
.
config
.
adminContext
);
const
showComamnd
=
this
.
adminCtx
const
showComamnd
=
this
.
adminCtx
.
command
(
'
act [groupId:number]
'
,
'
获取公演状态
'
)
.
command
(
'
act [groupId:number]
'
,
'
获取公演状态
'
)
.
usage
(
'
不带参数获取所有正在公演的群,带参数则获取特定群。
'
)
.
usage
(
'
不带参数获取所有正在公演的群,带参数则获取特定群。
'
)
...
@@ -110,9 +134,9 @@ export class MyPlugin {
...
@@ -110,9 +134,9 @@ export class MyPlugin {
}
catch
(
e
)
{
}
catch
(
e
)
{
return
`无法加载剧本文件
${
playbookPath
}
:
${
e
.
toString
()}
`
;
return
`无法加载剧本文件
${
playbookPath
}
:
${
e
.
toString
()}
`
;
}
}
const
bots
:
CQBot
[]
=
(
this
.
ctx
.
bots
.
filter
(
const
bots
:
OneBotBot
[]
=
this
.
ctx
.
bots
.
filter
(
(
b
)
=>
b
.
type
&&
b
.
type
.
startsWith
(
'
onebot
'
),
(
b
)
=>
b
.
type
&&
b
.
type
.
startsWith
(
'
onebot
'
),
)
as
unknown
)
as
CQ
Bot
[];
)
as
OneBot
Bot
[];
const
show
=
new
Show
(
groupId
,
playbook
,
this
.
config
.
autoChangeName
);
const
show
=
new
Show
(
groupId
,
playbook
,
this
.
config
.
autoChangeName
);
for
(
const
specificCharacter
of
specificCharacters
)
{
for
(
const
specificCharacter
of
specificCharacters
)
{
const
[
characterName
,
botId
]
=
specificCharacter
.
split
(
'
=
'
);
const
[
characterName
,
botId
]
=
specificCharacter
.
split
(
'
=
'
);
...
...
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