Commit 75573db7 authored by nanahira's avatar nanahira

migrate

parent 7a665bd0
Pipeline #6057 passed with stages
in 1 minute and 35 seconds
{
"name": "koishi-plugin-fortune",
"version": "1.0.1",
"version": "1.0.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "koishi-plugin-fortune",
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",
"dependencies": {
"source-map-support": "^0.5.20"
......@@ -20,7 +20,7 @@
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"koishi-core": "^3.14.2",
"koishi": "^4.0.0-alpha.8",
"moment": "^2.29.1",
"mustache": "^4.2.0",
"prettier": "^2.4.1",
......@@ -29,9 +29,6 @@
"typescript": "^4.4.3",
"webpack": "^5.56.0",
"webpack-cli": "^4.8.0"
},
"peerDependencies": {
"koishi-core": "^3.14.2"
}
},
"node_modules/@babel/code-frame": {
......@@ -211,6 +208,43 @@
"node": ">= 8.0.0"
}
},
"node_modules/@koishijs/core": {
"version": "4.0.0-alpha.8",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-alpha.8.tgz",
"integrity": "sha512-0SSweBTdXfSeD1IlWeBiAKDWD7MYGqHlhhuKAAstZDQm+Hh5oyX5oaZBhTUxbwwDjk//HwYH9AeLqqHTgVZYWw==",
"dev": true,
"dependencies": {
"@koishijs/utils": "^5.0.0-alpha.4",
"fastest-levenshtein": "^1.0.12"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/@koishijs/utils": {
"version": "5.0.0-alpha.4",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.0.0-alpha.4.tgz",
"integrity": "sha512-cB1mUh3iLQKVHd8O9Lbdm/8LPmQ/VtiO+DlnAZXwbyczSIBu3HJiQo5t9pjy4LFcOoboEO4iCfbqBXpA2L/JHg==",
"dev": true,
"dependencies": {
"supports-color": "^8.1.0"
}
},
"node_modules/@koishijs/utils/node_modules/supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
......@@ -7804,12 +7838,6 @@
"@types/koa": "*"
}
},
"node_modules/@types/lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz",
"integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==",
"dev": true
},
"node_modules/@types/mime": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
......@@ -9815,51 +9843,26 @@
"node": ">= 0.8"
}
},
"node_modules/koishi-core": {
"version": "3.14.2",
"resolved": "https://registry.npmjs.org/koishi-core/-/koishi-core-3.14.2.tgz",
"integrity": "sha512-32Zh35DL+ok8DNeNri4amIpt6Njf2lQ+Zgt5wNH5nq5BdUvPSEc4jAQhtcwxnrGvdVrl8n5QIuCZfkdY5tMk6w==",
"node_modules/koishi": {
"version": "4.0.0-alpha.8",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-alpha.8.tgz",
"integrity": "sha512-Q8Zp+K/P8woCHQRHOOWzSYDE1twJo/Frm5wcUDXMuhYySZtX6ci31ciVE+KSIh230yD30wYpWRbo1xhwTzepvg==",
"dev": true,
"dependencies": {
"@koa/router": "^10.1.1",
"@types/koa__router": "^8.0.8",
"@types/lru-cache": "^5.1.1",
"@koishijs/core": "^4.0.0-alpha.8",
"@koishijs/utils": "^5.0.0-alpha.4",
"@types/koa": "*",
"@types/koa__router": "*",
"@types/ws": "^7.4.7",
"axios": "^0.21.4",
"fastest-levenshtein": "^1.0.12",
"koa": "^2.13.1",
"koa-bodyparser": "^4.3.0",
"koishi-utils": "^4.3.0",
"lru-cache": "^6.0.0"
"koa-bodyparser": "^4.3.0"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/koishi-utils": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/koishi-utils/-/koishi-utils-4.3.0.tgz",
"integrity": "sha512-MV799odIPx2xWIcI4kIFFUmZotKUwejBo/ChYTZ3reQNZ0VGpvUghA4+oMm4m6qOgXlJsUiUc84kbSwOPrYWmw==",
"dev": true,
"dependencies": {
"supports-color": "^8.1.0"
}
},
"node_modules/koishi-utils/node_modules/supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/levn": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
......@@ -11453,6 +11456,36 @@
"path-to-regexp": "^6.1.0"
}
},
"@koishijs/core": {
"version": "4.0.0-alpha.8",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-alpha.8.tgz",
"integrity": "sha512-0SSweBTdXfSeD1IlWeBiAKDWD7MYGqHlhhuKAAstZDQm+Hh5oyX5oaZBhTUxbwwDjk//HwYH9AeLqqHTgVZYWw==",
"dev": true,
"requires": {
"@koishijs/utils": "^5.0.0-alpha.4",
"fastest-levenshtein": "^1.0.12"
}
},
"@koishijs/utils": {
"version": "5.0.0-alpha.4",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.0.0-alpha.4.tgz",
"integrity": "sha512-cB1mUh3iLQKVHd8O9Lbdm/8LPmQ/VtiO+DlnAZXwbyczSIBu3HJiQo5t9pjy4LFcOoboEO4iCfbqBXpA2L/JHg==",
"dev": true,
"requires": {
"supports-color": "^8.1.0"
},
"dependencies": {
"supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}
}
}
},
"@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
......@@ -14650,12 +14683,6 @@
"@types/koa": "*"
}
},
"@types/lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz",
"integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==",
"dev": true
},
"@types/mime": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz",
......@@ -16167,42 +16194,21 @@
"koa-compose": "^4.1.0"
}
},
"koishi-core": {
"version": "3.14.2",
"resolved": "https://registry.npmjs.org/koishi-core/-/koishi-core-3.14.2.tgz",
"integrity": "sha512-32Zh35DL+ok8DNeNri4amIpt6Njf2lQ+Zgt5wNH5nq5BdUvPSEc4jAQhtcwxnrGvdVrl8n5QIuCZfkdY5tMk6w==",
"koishi": {
"version": "4.0.0-alpha.8",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-alpha.8.tgz",
"integrity": "sha512-Q8Zp+K/P8woCHQRHOOWzSYDE1twJo/Frm5wcUDXMuhYySZtX6ci31ciVE+KSIh230yD30wYpWRbo1xhwTzepvg==",
"dev": true,
"requires": {
"@koa/router": "^10.1.1",
"@types/koa__router": "^8.0.8",
"@types/lru-cache": "^5.1.1",
"@koishijs/core": "^4.0.0-alpha.8",
"@koishijs/utils": "^5.0.0-alpha.4",
"@types/koa": "*",
"@types/koa__router": "*",
"@types/ws": "^7.4.7",
"axios": "^0.21.4",
"fastest-levenshtein": "^1.0.12",
"koa": "^2.13.1",
"koa-bodyparser": "^4.3.0",
"koishi-utils": "^4.3.0",
"lru-cache": "^6.0.0"
}
},
"koishi-utils": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/koishi-utils/-/koishi-utils-4.3.0.tgz",
"integrity": "sha512-MV799odIPx2xWIcI4kIFFUmZotKUwejBo/ChYTZ3reQNZ0VGpvUghA4+oMm4m6qOgXlJsUiUc84kbSwOPrYWmw==",
"dev": true,
"requires": {
"supports-color": "^8.1.0"
},
"dependencies": {
"supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}
}
"koa-bodyparser": "^4.3.0"
}
},
"levn": {
......
{
"name": "koishi-plugin-fortune",
"version": "1.0.2",
"version": "2.0.0",
"description": "Koishi 的算卦插件",
"main": "dist/index.js",
"typings": "dist/src/index.d.ts",
......@@ -28,7 +28,7 @@
"source-map-support": "^0.5.20"
},
"peerDependencies": {
"koishi-core": "^3.14.2"
"koishi": "^4.0.0-alpha.8"
},
"devDependencies": {
"@stdlib/random-base-mt19937": "^0.0.5",
......@@ -39,7 +39,7 @@
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"koishi-core": "^3.14.2",
"koishi": "^4.0.0-alpha.8",
"moment": "^2.29.1",
"mustache": "^4.2.0",
"prettier": "^2.4.1",
......
import 'source-map-support/register';
import { Context } from 'koishi-core';
import { Context } from 'koishi';
import { Config, MyPlugin } from './plugin';
export { Config } from './plugin';
......
import 'source-map-support/register';
import { Context } from 'koishi-core';
import { Context, Schema } from 'koishi';
import { pickOne } from './random';
import moment from 'moment';
import Mustache from 'mustache';
......@@ -19,6 +19,14 @@ export class MyPlugin {
private render(template: string, view: any) {
return Mustache.render(template, view, null, { escape: (v) => v });
}
schema: Schema<Config> = Schema.object({
header: Schema.string('占卜结果的标题,会出现在结果首部。'),
masterKey: Schema.string(
'占卜随机密钥。占卜结果会由 **日期** **用户ID** **masterKey** 唯一确定。',
),
useDatabase: Schema.boolean('从数据库获取用户名。').default(false),
results: Schema.array(Schema.string(), '所有可能的占卜结果。').required(),
});
private getResult(userId: string, name: string) {
if (!userId) {
return '获取用户信息失败。';
......@@ -42,7 +50,7 @@ export class MyPlugin {
if (ctx.database && this.config.useDatabase) this.useDatabase = true;
});
this.ctx = ctx;
this.config = config;
this.config = Schema.validate(config, this.schema);
ctx
.command('fortune', '进行占卜')
.usage('占卜结果每天固定。')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment