Commit 2aa25028 authored by nanahira's avatar nanahira

add missing methods

parent 86882bc0
......@@ -47,6 +47,6 @@ deploy_npm:
script:
- apt update;apt -y install coreutils
- echo $NPMRC | base64 --decode > ~/.npmrc
- npm publish . || true
- npm publish . --access public && curl -X PUT "https://registry-direct.npmmirror.com/$(cat package.json | jq '.name' | sed 's/\"//g')/sync?sync_upstream=true" || true
only:
- master
......@@ -18,7 +18,14 @@ export * from 'satori-decorators/dist/src/decorators/common';
const methodDecorators = koishiRegistrar.methodDecorators();
export const { UseEvent, UseBeforeEvent, UseMiddleware } = methodDecorators;
export const {
UseEvent,
UseBeforeEvent,
UseMiddleware,
UsePreset,
UseFormatter,
UseInterval,
} = methodDecorators;
export function UseCommand<D extends string>(
def: D,
......
import { RegisterMeta, SatoriRegistrar } from 'satori-decorators';
import { BeforeEventMap, Command, Context, Next, Session } from 'koishi';
import { BeforeEventMap, Command, Context, I18n, Next, Session } from 'koishi';
import { CanBeObserved, sessionRxToPromise } from './utility/rxjs-session';
import {
CommandConfigExtended,
......@@ -145,6 +145,29 @@ export class KoishiRegistrar extends SatoriRegistrar<Context> {
return command;
},
),
UseFormatter: this.decorateMethod(
'formatter',
({ ctx }, fun: I18n.Formatter, name: string) => {
ctx.i18n.formatter(name, fun);
ctx.on('dispose', () => {
delete ctx.i18n._formatters[name];
});
},
),
UsePreset: this.decorateMethod(
'preset',
({ ctx }, fun: I18n.Renderer, name: string) => {
ctx.i18n.preset(name, fun);
ctx.on('dispose', () => {
delete ctx.i18n._presets[fun.name];
});
},
),
UseInterval: this.decorateMethod(
'interval',
({ ctx }, fun: (...args: any[]) => any, interval: number) =>
ctx.setInterval(fun, interval),
),
};
}
}
......
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