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
0feb8753
Commit
0feb8753
authored
Oct 05, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate
parent
c627a968
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
12 deletions
+22
-12
package.json
package.json
+1
-1
src/index.ts
src/index.ts
+2
-2
src/playbook/Show.ts
src/playbook/Show.ts
+12
-7
src/plugin.ts
src/plugin.ts
+3
-2
webpack.config.js
webpack.config.js
+4
-0
No files found.
package.json
View file @
0feb8753
{
{
"name"
:
"koishi-plugin-act"
,
"name"
:
"koishi-plugin-act"
,
"version"
:
"
1.0.3
"
,
"version"
:
"
2.0.0
"
,
"description"
:
"A plugin playing acts in QQ groups"
,
"description"
:
"A plugin playing acts in QQ groups"
,
"main"
:
"dist/index.js"
,
"main"
:
"dist/index.js"
,
"dependencies"
:
{
"dependencies"
:
{
...
...
src/index.ts
View file @
0feb8753
import
'
source-map-support/register
'
;
import
'
source-map-support/register
'
;
import
type
{
Context
}
from
'
koishi
-core
'
;
import
type
{
Context
}
from
'
koishi
'
;
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
'
;
const
plugin
=
new
MyPlugin
();
const
plugin
=
new
MyPlugin
();
export
const
schema
=
plugin
.
schema
;
export
const
schema
=
plugin
.
schema
;
export
function
apply
(
ctx
:
Context
,
config
:
Config
)
{
export
function
apply
(
ctx
:
Context
,
config
:
Config
)
{
...
...
src/playbook/Show.ts
View file @
0feb8753
import
{
Playbook
}
from
'
./Playbook
'
;
import
{
Playbook
}
from
'
./Playbook
'
;
import
type
{
OneBotBot
}
from
'
@koishijs/plugin-onebot
'
;
import
type
{
OneBotBot
}
from
'
@koishijs/plugin-onebot
/lib/bot
'
;
import
moment
,
{
Moment
}
from
'
moment
'
;
import
moment
,
{
Moment
}
from
'
moment
'
;
export
enum
ShowStatus
{
export
enum
ShowStatus
{
...
@@ -23,7 +23,7 @@ export class Show {
...
@@ -23,7 +23,7 @@ export class Show {
for
(
const
character
of
playbook
.
characters
)
{
for
(
const
character
of
playbook
.
characters
)
{
character
.
playFun
=
async
(
line
,
text
)
=>
{
character
.
playFun
=
async
(
line
,
text
)
=>
{
const
bot
=
this
.
characterBotMap
.
get
(
character
.
id
);
const
bot
=
this
.
characterBotMap
.
get
(
character
.
id
);
await
bot
.
$
sendGroupMsg
(
this
.
groupId
,
text
,
true
);
await
bot
.
internal
.
sendGroupMsg
(
this
.
groupId
,
text
,
true
);
};
};
}
}
}
}
...
@@ -42,16 +42,17 @@ export class Show {
...
@@ -42,16 +42,17 @@ export class Show {
let
availableBots
:
OneBotBot
[]
=
[];
let
availableBots
:
OneBotBot
[]
=
[];
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
.
adapter
.
platform
!==
'
onebot
'
)
{
continue
;
continue
;
}
}
const
groups
=
await
bot
.
$
getGroupList
();
const
groups
=
await
bot
.
internal
.
getGroupList
();
const
matchGroup
=
groups
.
find
((
g
)
=>
g
.
group
I
d
===
this
.
groupId
);
const
matchGroup
=
groups
.
find
((
g
)
=>
g
.
group
_i
d
===
this
.
groupId
);
if
(
matchGroup
)
{
if
(
matchGroup
)
{
availableBots
.
push
(
bot
);
availableBots
.
push
(
bot
);
botNameMap
.
set
(
botNameMap
.
set
(
bot
.
selfId
.
toString
(),
bot
.
selfId
.
toString
(),
(
await
bot
.
$getGroupMemberInfo
(
this
.
groupId
,
bot
.
selfId
)).
nickname
,
(
await
bot
.
internal
.
getGroupMemberInfo
(
this
.
groupId
,
bot
.
selfId
))
.
nickname
,
);
);
}
}
}
}
...
@@ -109,7 +110,11 @@ export class Show {
...
@@ -109,7 +110,11 @@ export class Show {
for
(
const
character
of
this
.
playbook
.
characters
)
{
for
(
const
character
of
this
.
playbook
.
characters
)
{
const
bot
=
this
.
characterBotMap
.
get
(
character
.
id
);
const
bot
=
this
.
characterBotMap
.
get
(
character
.
id
);
try
{
try
{
await
bot
.
$setGroupCard
(
this
.
groupId
,
bot
.
selfId
,
character
.
name
);
await
bot
.
internal
.
setGroupCard
(
this
.
groupId
,
bot
.
selfId
,
character
.
name
,
);
}
catch
(
e
)
{
}
catch
(
e
)
{
return
`Change name for
${
bot
.
selfId
}
${
return
`Change name for
${
bot
.
selfId
}
${
character
.
name
character
.
name
...
...
src/plugin.ts
View file @
0feb8753
...
@@ -5,6 +5,7 @@ import { Playbook } from './playbook/Playbook';
...
@@ -5,6 +5,7 @@ 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
{
MaybeArray
}
from
'
koishi
'
;
import
{
MaybeArray
}
from
'
koishi
'
;
import
type
{
OneBotBot
}
from
'
@koishijs/plugin-onebot/lib/bot
'
;
const
selectors
=
[
const
selectors
=
[
'
user
'
,
'
user
'
,
...
@@ -38,7 +39,7 @@ export class MyPlugin {
...
@@ -38,7 +39,7 @@ export class MyPlugin {
adminCtx
:
Context
;
adminCtx
:
Context
;
shows
=
new
Map
<
number
,
Show
>
();
shows
=
new
Map
<
number
,
Show
>
();
name
=
'
act
'
;
name
=
'
act
-main
'
;
schema
:
Schema
<
Config
>
=
Schema
.
object
({
schema
:
Schema
<
Config
>
=
Schema
.
object
({
adminContext
:
Schema
.
any
(
'
管理员接口作用域。
'
),
adminContext
:
Schema
.
any
(
'
管理员接口作用域。
'
),
autoChangeName
:
Schema
.
boolean
(
autoChangeName
:
Schema
.
boolean
(
...
@@ -135,7 +136,7 @@ export class MyPlugin {
...
@@ -135,7 +136,7 @@ export class MyPlugin {
return
`无法加载剧本文件
${
playbookPath
}
:
${
e
.
toString
()}
`
;
return
`无法加载剧本文件
${
playbookPath
}
:
${
e
.
toString
()}
`
;
}
}
const
bots
:
OneBotBot
[]
=
this
.
ctx
.
bots
.
filter
(
const
bots
:
OneBotBot
[]
=
this
.
ctx
.
bots
.
filter
(
(
b
)
=>
b
.
type
&&
b
.
type
.
startsWith
(
'
onebot
'
)
,
(
b
)
=>
b
.
adapter
.
platform
===
'
onebot
'
,
)
as
OneBotBot
[];
)
as
OneBotBot
[];
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
)
{
...
...
webpack.config.js
View file @
0feb8753
...
@@ -25,4 +25,8 @@ module.exports = {
...
@@ -25,4 +25,8 @@ module.exports = {
},
},
path
:
path
.
resolve
(
__dirname
,
"
dist
"
),
path
:
path
.
resolve
(
__dirname
,
"
dist
"
),
},
},
externals
:
{
'
koishi
'
:
'
koishi
'
,
'
@koishijs/plugin-onebot/lib/bot
'
:
'
@koishijs/plugin-onebot/lib/bot
'
,
}
};
};
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