Skip to content

Commit

Permalink
feat: ヘルプ埋め込みからドキュメントサイトのリファレンスに飛べるように (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2en authored Feb 26, 2023
1 parent b74c595 commit 02d09dd
Show file tree
Hide file tree
Showing 37 changed files with 71 additions and 19 deletions.
5 changes: 5 additions & 0 deletions src/model/meme-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export interface MemeTemplate<
> {
commandNames: readonly string[];
description: string;
/**
* はらちょドキュメントサイト(haracho.approvers.dev):
* 各ミームリファレンスのページ名を指定する。
*/
pageName: string;
flagsKeys?: readonly FLAGS_KEY[];
optionsKeys?: readonly OPTIONS_KEY[];
requiredPositionalKeys?: readonly REQ_POSITIONAL_KEY[];
Expand Down
3 changes: 2 additions & 1 deletion src/service/command/channel-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const SCHEMA = {
export class ChannelInfo implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'チャンネル秘書艦',
description: '指定したチャンネルの情報を調べてくるよ'
description: '指定したチャンネルの情報を調べてくるよ',
pageName: 'channel-info'
};

readonly schema = SCHEMA;
Expand Down
6 changes: 6 additions & 0 deletions src/service/command/command-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ export interface SentMessage {
export interface HelpInfo {
title: string;
description: string;
/**
* はらちょドキュメントサイト(haracho.approvers.dev):
* 各コマンドリファレンスのページ名を指定する。
* 例: !ping コマンドのリファレンスが `haracho.approvers.dev/commands/ping` にある場合は `ping` を docId に指定する。
*/
pageName: string;
}

export interface CommandResponder<S extends Schema> {
Expand Down
3 changes: 2 additions & 1 deletion src/service/command/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export class DebugCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'デバッガーはらちょ',
description:
'メッセージIDを渡すと、同じチャンネル内にあればそれをコードブロックとして表示するよ'
'メッセージIDを渡すと、同じチャンネル内にあればそれをコードブロックとして表示するよ',
pageName: 'debug'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/dice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const SCHEMA = {
export class DiceCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'ダイスロール',
description: '賽子が振れるみたいだよ'
description: '賽子が振れるみたいだよ',
pageName: 'dice'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/guild-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ const SCHEMA = {
export class GuildInfo implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'ギルド秘書艦',
description: '限界開発鯖の情報を持ってくるよ'
description: '限界開発鯖の情報を持ってくるよ',
pageName: 'guild-info'
};
readonly schema = SCHEMA;

Expand Down
4 changes: 3 additions & 1 deletion src/service/command/gyokuon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export class GyokuonCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'こるくの玉音放送',
description:
'VC内にこるくの玉音放送を再生するよ。引数無しで即起動。どの方式でもコマンド発行者がVCに居ないと動かないよ。'
'VC内にこるくの玉音放送を再生するよ。引数無しで即起動。どの方式でもコマンド発行者がVCに居ないと動かないよ。',
// 音声機能関連の機能は voice/ 以下にドキュメントを置いているため
pageName: 'voice/colk'
};
readonly schema = SCHEMA;

Expand Down
5 changes: 4 additions & 1 deletion src/service/command/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const SCHEMA = {
export class HelpCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'はらちょヘルプ',
description: 'こんな機能が搭載されてるよ'
description: 'こんな機能が搭載されてるよ',
pageName: 'help'
};
readonly schema = SCHEMA;

Expand All @@ -36,6 +37,7 @@ export class HelpCommand implements CommandResponder<typeof SCHEMA> {
private buildField({
title,
description,
pageName,
names,
params
}: Readonly<HelpInfo & Schema>): EmbedPage {
Expand All @@ -52,6 +54,7 @@ export class HelpCommand implements CommandResponder<typeof SCHEMA> {
const patterns = patternsWithDesc.map(([pattern]) => pattern);
return {
title,
url: `https://haracho.approvers.dev/references/commands/${pageName}`,
description: `${description}
\`${names.join('/')}${['', ...patterns].join(' ')}\`
${argsDescriptions}`
Expand Down
3 changes: 2 additions & 1 deletion src/service/command/judging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const SCHEMA = {
export class JudgingCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: JUDGING_TITLE,
description: 'プログラムが適格かどうか判定してあげるよ'
description: 'プログラムが適格かどうか判定してあげるよ',
pageName: 'judge'
};
readonly schema = SCHEMA;

Expand Down
4 changes: 3 additions & 1 deletion src/service/command/kaere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ export class KaereCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'Kaere一葉',
description:
'VC内の人類に就寝を促すよ。引数なしで即起動。どの方式でもコマンド発行者がVCに居ないと動かないよ'
'VC内の人類に就寝を促すよ。引数なしで即起動。どの方式でもコマンド発行者がVCに居ないと動かないよ',
// 音声機能関連の機能は voice/ 以下にドキュメントを置いているため
pageName: 'voice/kaere'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/kokusei-chousa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const SCHEMA = {
export class KokuseiChousa implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: '国勢調査',
description: '限界開発鯖の人類の数、Botの数とBot率を算出するよ。'
description: '限界開発鯖の人類の数、Botの数とBot率を算出するよ。',
pageName: 'kokusei'
};
readonly schema = SCHEMA;

Expand Down
4 changes: 3 additions & 1 deletion src/service/command/meme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const SCHEMA = {
export class Meme implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'ミーム構文機能',
description: '何これ……引数のテキストを構文にはめ込むみたいだよ'
description: '何これ……引数のテキストを構文にはめ込むみたいだよ',
pageName: 'meme'
};
readonly schema = SCHEMA;

Expand Down Expand Up @@ -87,6 +88,7 @@ export class Meme implements CommandResponder<typeof SCHEMA> {
if (argv.help) {
await message.reply({
title: meme.commandNames.map((name) => `\`${name}\``).join('/'),
url: `https://haracho.approvers.dev/references/commands/meme/${meme.pageName}`,
description: meme.description
});
return;
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/clang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const clang: MemeTemplate<
> = {
commandNames: ['clang', 'c'],
description: '〜の天才\n9つの〜を操る',
pageName: 'clang',
requiredPositionalKeys: positionalKeys,
errorMessage: 'エラーの天才\n9つの引数エラーを操る',
generate({ requiredPositionals: { domain, way } }) {
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/dousurya.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const dousurya: MemeTemplate<
> = {
commandNames: ['dousurya', 'dousureba'],
description: '限界みたいな鯖に住んでる〜はどうすりゃいいですか?',
pageName: 'dousurya',
requiredPositionalKeys: positionalKeys,
errorMessage: 'どうしようもない。',
generate(args) {
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/failure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const failure: MemeTemplate<
> = {
commandNames: ['failure', 'fail'],
description: `「〜〜〜」\n「わかりました。それは一般に失敗と言います、ありがとうございます」\n* \`-k <失敗部分> <説明>\` で失敗部分を変更できます。 \n [元ネタ](${sourceLink})`,
pageName: 'failure',
optionsKeys: failureOption,
requiredPositionalKeys: positionalKeys,
errorMessage:
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/hukueki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const hukueki: MemeTemplate<
> = {
commandNames: ['hukueki'],
description: 'ねぇ、将来何してるだろうね\n〜はしてないといいね\n困らないでよ',
pageName: 'hukueki',
requiredPositionalKeys: positionalKeys,
errorMessage: '服役できなかった。',
generate(args) {
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/kenjou.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const kenjou: MemeTemplate<
commandNames: ['kenjou'],
description:
'[健常者エミュレーター](https://healthy-person-emulator.memo.wiki/)の構文ジェネレーター。\n健常者エミュレーターWikiにありそうなタイトルを指定すればうまくいきます。',
pageName: 'kenjou',
requiredPositionalKeys: positionalKeys,
errorMessage:
'はらちょのミーム機能を使うときは引数を忘れない方がいい - 健常者エミュレータ事例集Wiki',
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/koume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const koume: MemeTemplate<
> = {
commandNames: ['koume'],
description: '〜と思ったら〜♪\n\n〜でした〜♪\n\n引数は2つ必要です。',
pageName: 'koume',
requiredPositionalKeys: positionalKeys,
errorMessage:
'MEMEを表示しようと思ったら〜♪ 引数が足りませんでした〜♪ チクショー!!',
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/lolicon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const lolicon: MemeTemplate<
> = {
commandNames: ['lolicon'],
description: 'だから僕は〜を辞めた',
pageName: 'lolicon',
requiredPositionalKeys: positionalKeys,
errorMessage: 'こるくはロリコンをやめられなかった。',
generate(args, author) {
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/moeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const moeta: MemeTemplate<
> = {
commandNames: ['moeta', 'yuki'],
description: `「久留米の花火大会ね、寮から見れたの?」\n「うん ついでに〜が燃えた」\n${source}`,
pageName: 'moeta',
requiredPositionalKeys: positionalKeys,
errorMessage: source,
generate(args) {
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const positionalKeys = ['context'] as const;
export const n: MemeTemplate<never, never, (typeof positionalKeys)[number]> = {
commandNames: ['n'],
description: '〜Nった',
pageName: 'n',
requiredPositionalKeys: positionalKeys,
errorMessage: 'このままだと <@521958252280545280> みたいに留年しちゃう....',
generate(args) {
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/nigetane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const nigetane: MemeTemplate<
> = {
commandNames: ['nigetane'],
description: '… 〜から悪くないって、… (from Arcaea "Final Verdict")',
pageName: 'nigetane',
requiredPositionalKeys: positionalKeys,
errorMessage: '……手遅れなのは頭(おつむ)からなのかな。',
generate: ({ requiredPositionals: { reason } }) => template(reason)
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/nine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const nine: MemeTemplate<never, never, (typeof positionalKeys)[number]> =
{
commandNames: ['nine'],
description: '〇〇は〇〇が9割',
pageName: 'nine',
requiredPositionalKeys: positionalKeys,
errorMessage: '人は引数ミスが9割',
generate({ requiredPositionals: { subject, entity } }) {
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/ojaru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const ojaru: MemeTemplate<
commandNames: ['ojaru'],
description:
'あっぱれおじゃる様!見事ミーム構文を使いこなされました!`-g`オプションを使用なさってデンボの口調の変更も可能でございます!',
pageName: 'ojaru',
flagsKeys: ojaruFlags,
requiredPositionalKeys: positionalKeys,
errorMessage:
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/syakai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const syakai: MemeTemplate<
> = {
commandNames: ['syakai'],
description: '「首相、~に否定的な考え ― 『社会が変わってしまう』」',
pageName: 'syakai',
requiredPositionalKeys: positionalKeys,
errorMessage: '極めて慎重に検討すべき課題だ',
generate(args) {
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/takopi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const takopi: MemeTemplate<
commandNames: ['takopi'],
description:
'「〜、出して」\n`-f` で教員と自分の名前の位置を反対にします。\n`-c <教員の名前> <出すもの>`で教員の名前も変更可能です。',
pageName: 'takopi',
flagsKeys: takopiFlags,
optionsKeys: takopiOptions,
requiredPositionalKeys: positionalKeys,
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/tsureteike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const tsureteike: MemeTemplate<
commandNames: ['tsureteike', 'hunt'],
description:
'「この中に〜はいるか 連れて行け」\nex.) `!tsureteike プログラマ Rustは知っているか? ゲームですか? 錆のこと? 🦀`',
pageName: 'tsureteike',
requiredPositionalKeys: positionalKeys,
errorMessage: '構文ミスだ、問答無用で連れて行け',
generate({ requiredPositionals }) {
Expand Down
1 change: 1 addition & 0 deletions src/service/command/meme/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const web3: MemeTemplate<never, never, (typeof positionalKeys)[number]> =
{
commandNames: ['web3'],
description: '「いちばんやさしい〜の教本」',
pageName: 'web3',
requiredPositionalKeys: positionalKeys,
errorMessage: 'TCP/IP、SMTP、HTTPはGoogleやAmazonに独占されています。',
generate(args) {
Expand Down
4 changes: 3 additions & 1 deletion src/service/command/party.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export class PartyCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'Party一葉',
description:
'VC内の人類に押しかけてPartyを開くよ。引数なしで即起動。どの方式でもコマンド発行者がVCに居ないと動かないよ'
'VC内の人類に押しかけてPartyを開くよ。引数なしで即起動。どの方式でもコマンド発行者がVCに居ないと動かないよ',
// 音声機能関連の機能は voice/ 以下にドキュメントを置いているため
pageName: 'voice/party'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const SCHEMA = {
export class PingCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'Ping',
description: '現在のレイテンシを表示するよ。'
description: '現在のレイテンシを表示するよ。',
pageName: 'ping'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/role-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const SCHEMA = {
export class RoleCreate implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'ロール作成',
description: 'ロールを作成するよ'
description: 'ロールを作成するよ',
pageName: 'role-create'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/role-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const SCHEMA = {
export class RoleInfo implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'ロール秘書艦',
description: '指定したロールの情報を調べてくるよ'
description: '指定したロールの情報を調べてくるよ',
pageName: 'role-info'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/role-rank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const SCHEMA = {
export class RoleRank implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'ロール数ランキング',
description: '各メンバーごとのロール数をランキング形式で表示するよ'
description: '各メンバーごとのロール数をランキング形式で表示するよ',
pageName: 'role-rank'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/stfu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export class SheriffCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: '治安統率機構',
description:
'はらちょがうるさいときに治安維持するためのコマンドだよ。最新メッセージから 50 件以内のはらちょのメッセージを指定の個数だけ削除するよ。'
'はらちょがうるさいときに治安維持するためのコマンドだよ。最新メッセージから 50 件以内のはらちょのメッセージを指定の個数だけ削除するよ。',
pageName: 'stfu'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/typo-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ const SCHEMA = {
export class TypoReporter implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: '今日のTypo',
description: '「〜だカス」をTypoとして一日間記録するよ'
description: '「〜だカス」をTypoとして一日間記録するよ',
pageName: 'typo'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/user-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export class UserInfo implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'ユーザー秘書艦',
description:
'指定したユーザーの情報を調べてくるよ。限界開発鯖のメンバーしか検索できないから注意してね。'
'指定したユーザーの情報を調べてくるよ。限界開発鯖のメンバーしか検索できないから注意してね。',
pageName: 'user-info'
};
readonly schema = SCHEMA;

Expand Down
3 changes: 2 additions & 1 deletion src/service/command/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const SCHEMA = {
export class GetVersionCommand implements CommandResponder<typeof SCHEMA> {
help: Readonly<HelpInfo> = {
title: 'はらちょバージョン',
description: '現在の私のバージョンを出力するよ。'
description: '現在の私のバージョンを出力するよ。',
pageName: 'version'
};
readonly schema = SCHEMA;

Expand Down

0 comments on commit 02d09dd

Please sign in to comment.