Skip to content

[ahokusa] Migrate to TypeScript and ChannelLimitedBot, add #tsgbot-games support#1127

Merged
hakatashi merged 6 commits intomasterfrom
copilot/add-channel-limited-bot
Jan 16, 2026
Merged

[ahokusa] Migrate to TypeScript and ChannelLimitedBot, add #tsgbot-games support#1127
hakatashi merged 6 commits intomasterfrom
copilot/add-channel-limited-bot

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 7, 2026

Migrates ahokusa bot to TypeScript and integrates ChannelLimitedBot for #tsgbot-games channel support per #1099.

Changes

Key Implementation Details

The bot handles both wake-word game initialization and in-thread gameplay:

class AhokusaBot extends ChannelLimitedBot {
  protected override readonly wakeWordRegex = /^(|寿( [3456])?|||   |@ahokusa\b)/;
  protected override readonly allowedChannels = [process.env.CHANNEL_SANDBOX!, process.env.CHANNEL_GAMES!];

  protected override async onWakeWord(message: GenericMessageEvent, channel: string): Promise<string | null> {
    // Game initialization logic
  }

  private async onThreadMessage(event: MessageEvent) {
    // In-thread move processing (上下左右wasdhjkl commands, もう一度, 不成立, etc.)
  }
}

Tests updated to TypeScript with added coverage for 千矢スライドパズル variant.

Original prompt

This section details on the original issue you should resolve

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

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

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

crossword bot

character-quiz bot

achievement-quiz bot

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 7, 2026 16:02
Co-authored-by: hakatashi <3126484+hakatashi@users.noreply.github.com>
Co-authored-by: hakatashi <3126484+hakatashi@users.noreply.github.com>
Co-authored-by: hakatashi <3126484+hakatashi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for ahokusa bot in #tsgbot-games channel [ahokusa] Migrate to TypeScript and ChannelLimitedBot, add #tsgbot-games support Jan 7, 2026
Copilot AI requested a review from hakatashi January 7, 2026 16:09
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 52.02703% with 142 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.16%. Comparing base (9b97029) to head (11c8552).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
ahokusa/index.ts 52.20% 141 Missing ⚠️
lib/slackUtils.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1127      +/-   ##
==========================================
- Coverage   26.16%   26.16%   -0.01%     
==========================================
  Files         205      205              
  Lines       18060    18056       -4     
  Branches     3877     3873       -4     
==========================================
- Hits         4726     4724       -2     
- Misses      12683    12719      +36     
+ Partials      651      613      -38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@hakatashi hakatashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

動作確認済み。なお、競争力の高いBOTではないと判断したのでゲーム進行中のsandboxへの通知は実装しなかった

image image

@hakatashi hakatashi marked this pull request as ready for review January 8, 2026 01:50
@hakatashi hakatashi requested a review from kurgm as a code owner January 8, 2026 01:50
Copilot AI review requested due to automatic review settings January 8, 2026 01:50
@tsg-ut-gemini-assistant
Copy link
Copy Markdown
Contributor

えへ~

ありがとう!

レビューさせてもらうにゃ!

🔍️🔍️🔍️️

Copy link
Copy Markdown
Contributor

@tsg-ut-gemini-assistant tsg-ut-gemini-assistant Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

うにゃ!このプルリクエストは ahokusa ボットをTypeScriptに移行して、ChannelLimitedBot を使うようにする変更だにゃ。全体的にうまく移行できていると思うにゃ!

🔍 General Feedback

  • ChannelLimitedBot の機能と重複するチェックがいくつかあったにゃ。もっと ChannelLimitedBot を活用すると、コードがもっときれいになると思うにゃ!
  • userinvert の戻り値に ! (非nullアサーション)を使うのは、ちょっと危険な場合があるにゃ。ちゃんと値があるか確認する方が安全だにゃ。
  • console.trace() はデバッグにはいいけど、本番環境では注意が必要だにゃ。

Comment thread ahokusa/index.ts
Comment thread ahokusa/index.ts
Comment thread ahokusa/index.ts
Comment thread ahokusa/index.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the ahokusa slide puzzle bot from JavaScript to TypeScript and integrates it with the ChannelLimitedBot framework to enable multi-channel support for both #CHANNEL_SANDBOX and #tsgbot-games.

Key Changes:

  • Complete TypeScript rewrite with proper type annotations and interfaces
  • Class-based architecture extending ChannelLimitedBot for channel management
  • Replaced file-based state persistence with in-memory state management
  • Added test coverage for 千矢スライドパズル variant

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ahokusa/index.ts New TypeScript implementation with AhokusaBot class extending ChannelLimitedBot, game logic preserved with improved type safety
ahokusa/index.test.ts Migrated tests to TypeScript with modern import syntax and added 千矢スライドパズル test case
ahokusa/index.js Removed legacy JavaScript implementation
ahokusa/index.test.js Removed legacy JavaScript test file
lib/slackUtils.ts Added ThreadBroadcastMessageEvent import and type assertion for thread_broadcast messages to preserve optional bot_id field

Comment thread ahokusa/index.ts
Comment thread ahokusa/index.ts Outdated
Comment thread lib/slackUtils.ts
Comment thread ahokusa/index.test.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hakatashi hakatashi enabled auto-merge January 8, 2026 02:03
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jan 8, 2026

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@hakatashi
Copy link
Copy Markdown
Member

レビュー来ないのでマージしちゃうよん

@hakatashi hakatashi disabled auto-merge January 16, 2026 16:14
@hakatashi hakatashi merged commit 4f730e1 into master Jan 16, 2026
4 of 5 checks passed
@hakatashi hakatashi deleted the copilot/add-channel-limited-bot branch January 16, 2026 16:15
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.

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

3 participants