Skip to content

Commit

Permalink
build: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed May 9, 2024
1 parent 224af1b commit f073062
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
25 changes: 24 additions & 1 deletion libs/bot-commander/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
IStarResolveResult,
} from './types';

export { CompareFunc, FuncName, equalFunc, regex };
export { CompareFunc, FuncName, regex };

export interface IArgv<T> {
raw: mri.Argv<T>;
Expand Down Expand Up @@ -215,6 +215,29 @@ export class CommandCenter<C extends Record<string, any>> {
console.log('no handler found for', str);
}
}

help() {
let text = '';
const prefix = this.prefixes.filter(Boolean).join('、');
if (prefix) {
text += `前缀:${prefix}\n`;
}

text += '支持的命令:\n';

this.registry.handlers.forEach(([key, [_, compareFunc]]) => {
text += `- ${key}: ${compareFunc.name}\n`;
});

this.regexRegistry.handlers.forEach(([key, [_, compareFunc]]) => {
text += `- ${key}: ${compareFunc.name}\n`;
});
if (this.starHandlers) {
text += `- *: fallbackHandler\n`;
}

return text;
}
}

export class StopError extends Error {
Expand Down
21 changes: 1 addition & 20 deletions src/im/commands/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,7 @@ export function registerCommonCommand(it: IMCommandCenter) {
});

it.on('help', async ({ bot }) => {
const text = new StringBuilder();
const prefix = it.prefixes.filter(Boolean).join('、');
if (prefix) {
text.add('前缀:' + prefix);
}

text.add('支持的命令:', true);

it.registry.handlers.forEach(([key, [_, compareFunc]]) => {
text.add(`- ${key}: ${compareFunc.name}`);
});

it.regexRegistry.handlers.forEach(([key, [_, compareFunc]]) => {
text.add(`- ${key}: ${compareFunc.name}`);
});
if (it.fallbackHandler) {
text.add(`- *: fallbackHandler`);
}

await bot.replyText(text.build());
await bot.replyText(it.help());
});

it.on('ping', async ({ bot }) => {
Expand Down
2 changes: 0 additions & 2 deletions src/im/commands/opensumi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { RC_WORKFLOW_FILE } from '@/constants/opensumi';
import { markdown } from '@/github/dingtalk';
import { equalFunc } from '@opensumi/bot-commander';

import { IBotAdapter } from '../types';

Expand Down Expand Up @@ -247,6 +246,5 @@ export function registerOpenSumiCommand(it: IMCommandCenter) {
await bot.replyText('Starts generating monthly report.');
},
[],
equalFunc,
);
}

0 comments on commit f073062

Please sign in to comment.