Skip to content

[shogi] Introduce ChannelLimitedBot & support #tsgbot-games channel#1177

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/update-shogi-bot-for-tsgbot-games
Draft

[shogi] Introduce ChannelLimitedBot & support #tsgbot-games channel#1177
Copilot wants to merge 2 commits intomasterfrom
copilot/update-shogi-bot-for-tsgbot-games

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

The shogi bot was hardcoded to CHANNEL_SANDBOX and had no support for CHANNEL_GAMES or the cross-channel progress notification system introduced in #1099.

Changes

shogi/index.js

  • Converts the top-level function export to ShogiBot extends ChannelLimitedBot
  • wakeWordRegex covers all start patterns: 将棋, N手詰め, N手以上詰め, N手必勝将棋
  • postMessage() overridden to preserve icon_url behavior (base class uses icon_emoji)
  • state.channel tracks active game channel; state.gameMessageTs tracks the initial board post ts for progress message lifecycle
  • onWakeWord() handles game initialization and returns the initial post's ts (plugs into the progress message system)
  • onMessageEvent() calls super first (wake word + channel redirect), then handles thread commands (もう一回, 正着手, piece moves, resign, 盤面)
  • end() calls deleteProgressMessage(state.gameMessageTs) to clean up the "進行中のゲーム" notification in #sandbox on game end
class ShogiBot extends ChannelLimitedBot {
    constructor(slackClients) {
        super(slackClients);
        this.username = 'shogi';
        this.wakeWordRegex = /^(?:|\d+(?:|)|\d+(?:|))$/;
        // ...
    }

    async onWakeWord(message, channel) {
        // sets state.channel = channel, posts initial board, returns result.ts
    }
}
module.exports = (slackClients) => new ShogiBot(slackClients);

shogi/index.test.js

  • Adds jest.mock('../lib/slackUtils') (required by ChannelLimitedBot)
  • Switches test channel env var from CHANNEL_SANDBOX to CHANNEL_GAMES
Original prompt

This section details on the original issue you should resolve

<issue_title>[shogi] #tsgbot-games 対応 & ChannelLimitedBotクラスを導入</issue_title>
<issue_description>Issue #1099 の対応の一環として、 shogi BOTの改修を行う。

Slackの #tsgbot-games チャンネルからの起動に対応できるようにする。また、 lib/channelLimitedBot.ts で定義されたChannelLimitedBotクラスを利用し、起動チャンネルの指定と進行中のゲームの通知を導入する。

改修にあたっては、すでに行われた以下の3つのBOTの同様の修正の修正内容を必ず参照し、これらのスタイルを可能な限り踏襲する。

なお、対象のBOTがJavaScriptで書かれている場合は、今回の改修でTypeScriptに書き換える必要はない。このプロジェクトではJavaScriptとTypeScriptを混在させることができる。また、そのほか改修に関係ない改良を加える必要はない。

anime bot

character-quiz bot

achievement-quiz bot

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: hakatashi <3126484+hakatashi@users.noreply.github.com>
Copilot AI changed the title [WIP] Update shogi bot to support #tsgbot-games channel [shogi] Introduce ChannelLimitedBot & support #tsgbot-games channel Mar 1, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 1, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
9.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[shogi] #tsgbot-games 対応 & ChannelLimitedBotクラスを導入

2 participants