Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-plugin-pics
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-pics
Commits
fba3555b
Commit
fba3555b
authored
Dec 30, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pics component support
parent
01899cb8
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
169 additions
and
152 deletions
+169
-152
dev/extras.ts
dev/extras.ts
+3
-1
package-lock.json
package-lock.json
+144
-144
package.json
package.json
+4
-4
src/index.ts
src/index.ts
+18
-3
No files found.
dev/extras.ts
View file @
fba3555b
import
{
Awaitable
,
Context
,
Schema
}
from
'
koishi
'
;
import
{
Awaitable
,
Context
,
Schema
,
segment
}
from
'
koishi
'
;
import
{
import
{
DefinePlugin
,
DefinePlugin
,
MultiInstancePlugin
,
MultiInstancePlugin
,
...
@@ -65,6 +65,8 @@ export default class ExtrasInDev {
...
@@ -65,6 +65,8 @@ export default class ExtrasInDev {
isDefault
:
true
,
isDefault
:
true
,
// endpoint: 'https://cdn02.moecube.com:444',
// endpoint: 'https://cdn02.moecube.com:444',
});
});
ctx
.
command
(
'
pic2
'
).
action
(()
=>
segment
(
'
pics
'
));
}
}
static
using
=
[
'
pics
'
]
as
const
;
static
using
=
[
'
pics
'
]
as
const
;
...
...
package-lock.json
View file @
fba3555b
This diff is collapsed.
Click to expand it.
package.json
View file @
fba3555b
...
@@ -28,13 +28,13 @@
...
@@ -28,13 +28,13 @@
"homepage"
:
"
https://github.com/koishijs/koishi-plugin-pics
"
,
"homepage"
:
"
https://github.com/koishijs/koishi-plugin-pics
"
,
"dependencies"
:
{
"dependencies"
:
{
"
@koishijs/assets
"
:
"
^1.0.1
"
,
"
@koishijs/assets
"
:
"
^1.0.1
"
,
"
koishi-thirdeye
"
:
"
^11.1.1
4
"
,
"
koishi-thirdeye
"
:
"
^11.1.1
7
"
,
"
lodash
"
:
"
^4.17.21
"
"
lodash
"
:
"
^4.17.21
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@koishijs/plugin-console
"
:
"
^
4.7.1
"
,
"
@koishijs/plugin-console
"
:
"
^
5.0.0
"
,
"
@koishijs/plugin-database-memory
"
:
"
^2.0.1
"
,
"
@koishijs/plugin-database-memory
"
:
"
^2.0.1
"
,
"
@koishijs/plugin-sandbox
"
:
"
^2.
4
.0
"
,
"
@koishijs/plugin-sandbox
"
:
"
^2.
5
.0
"
,
"
@types/jest
"
:
"
^29.2.0
"
,
"
@types/jest
"
:
"
^29.2.0
"
,
"
@types/lodash
"
:
"
^4.14.176
"
,
"
@types/lodash
"
:
"
^4.14.176
"
,
"
@types/node
"
:
"
^16.11.4
"
,
"
@types/node
"
:
"
^16.11.4
"
,
...
@@ -57,7 +57,7 @@
...
@@ -57,7 +57,7 @@
"
ws
"
:
"
^8.3.0
"
"
ws
"
:
"
^8.3.0
"
},
},
"peerDependencies"
:
{
"peerDependencies"
:
{
"koishi"
:
"^4.10.
4
"
"koishi"
:
"^4.10.
10
"
},
},
"jest"
:
{
"jest"
:
{
"moduleFileExtensions"
:
[
"moduleFileExtensions"
:
[
...
...
src/index.ts
View file @
fba3555b
// import 'source-map-support/register';
// import 'source-map-support/register';
import
{
Context
,
Random
,
Logger
,
Bot
,
remove
}
from
'
koishi
'
;
import
{
Context
,
Random
,
Logger
,
Bot
,
remove
,
Session
,
Dict
}
from
'
koishi
'
;
import
{
PicsPluginConfig
}
from
'
./config
'
;
import
{
PicsPluginConfig
}
from
'
./config
'
;
import
_
from
'
lodash
'
;
import
_
from
'
lodash
'
;
import
{
segment
,
Quester
}
from
'
koishi
'
;
import
{
segment
,
Quester
,
Element
}
from
'
koishi
'
;
import
{
import
{
StarterPlugin
,
StarterPlugin
,
Caller
,
Caller
,
...
@@ -14,11 +14,11 @@ import {
...
@@ -14,11 +14,11 @@ import {
LifecycleEvents
,
LifecycleEvents
,
Provide
,
Provide
,
PutArgs
,
PutArgs
,
PutBot
,
PutOption
,
PutOption
,
PutRenderer
,
PutRenderer
,
Renderer
,
Renderer
,
UseCommand
,
UseCommand
,
UseComponent
,
}
from
'
koishi-thirdeye
'
;
}
from
'
koishi-thirdeye
'
;
import
{
AxiosRequestConfig
}
from
'
axios
'
;
import
{
AxiosRequestConfig
}
from
'
axios
'
;
import
{
PicAssetsTransformMiddleware
}
from
'
./middlewares/assets
'
;
import
{
PicAssetsTransformMiddleware
}
from
'
./middlewares/assets
'
;
...
@@ -322,4 +322,19 @@ export default class PicsContainer
...
@@ -322,4 +322,19 @@ export default class PicsContainer
this
.
_http
=
this
.
http
.
extend
(
this
.
config
.
httpConfig
);
this
.
_http
=
this
.
http
.
extend
(
this
.
config
.
httpConfig
);
this
.
installDefaultMiddlewares
();
this
.
installDefaultMiddlewares
();
}
}
@
UseComponent
(
'
pics
'
)
async
picsComponent
(
attrs
:
Dict
<
any
>
,
children
:
Element
[],
session
:
Session
)
{
const
tags
=
attrs
.
tags
?.
split
(
/
[
,+
\u
FF0C
\u
FF0B
\u
3001
]
/
)
||
[];
const
sourceTags
=
attrs
.
source
?.
split
(
/
[
,+
\u
FF0C
\u
FF0B
\u
3001
]
/
)
||
[];
const
result
=
await
this
.
randomPic
(
tags
,
sourceTags
);
if
(
!
result
)
{
return
attrs
.
fallback
||
''
;
}
const
segment
=
await
this
.
getSegment
(
result
.
url
);
if
(
result
.
description
)
{
segment
.
attrs
.
description
=
result
.
description
;
}
return
segment
;
}
}
}
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