Skip to content

[prime] Add #tsgbot-games support via ChannelLimitedBot#1171

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/add-channel-limited-bot
Draft

[prime] Add #tsgbot-games support via ChannelLimitedBot#1171
Copilot wants to merge 2 commits intomasterfrom
copilot/add-channel-limited-bot

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

Part of #1099. Refactors prime/index.js to use the ChannelLimitedBot base class, enabling the bot to run from #tsgbot-games and post an in-progress notification to #sandbox during active games.

Changes

  • PrimeBot class extending ChannelLimitedBot
    • wakeWordRegex = /^素数大富豪$/
    • onWakeWord() handles game start; returns the initial message TS so the base class can post/delete the progress message in #sandbox
    • onMessageEvent() override handles all in-game commands (number plays, factorizations, draw, pass, give up, @primebot)
  • State gains two new persisted fields: channel (game channel) and gameMessageTs (for progress message lifecycle)
  • deleteProgressMessage() called on game end (win, give up, reset)
  • All channel: process.env.CHANNEL_SANDBOX references replaced with channel: this.state.channel
// Before
module.exports = ({eventClient, webClient: slack}) => {
  eventClient.on('message', async (message) => {
    if (message.channel !== process.env.CHANNEL_SANDBOX) return;
    // ...
  });
};

// After
class PrimeBot extends ChannelLimitedBot {
  wakeWordRegex = /^$/;
  async onWakeWord(message, channel) { /* start game, return ts */ }
  async onMessageEvent(event) { /* game commands */ }
}
module.exports = (slackClients) => new PrimeBot(slackClients);

Test

  • Added jest.mock('../lib/slackUtils') and CHANNEL_GAMES = slack.fakeChannel
  • Renamed misleading shogi variable to prime
Original prompt

This section details on the original issue you should resolve

<issue_title>[prime] #tsgbot-games 対応 & ChannelLimitedBotクラスを導入</issue_title>
<issue_description>Issue #1099 の対応の一環として、 prime 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.

…support

Co-authored-by: hakatashi <3126484+hakatashi@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 1, 2026

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

Copilot AI changed the title [WIP] Add support for prime bot in #tsgbot-games channel [prime] Add #tsgbot-games support via ChannelLimitedBot Mar 1, 2026
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.

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

2 participants