Skip to content

Conversation

@pladisdev
Copy link
Owner

No description provided.

pladisdev and others added 30 commits November 2, 2025 09:42
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pladisdev <127021507+pladisdev@users.noreply.github.com>
Co-authored-by: pladisdev <127021507+pladisdev@users.noreply.github.com>
Co-authored-by: pladisdev <127021507+pladisdev@users.noreply.github.com>
Co-authored-by: pladisdev <127021507+pladisdev@users.noreply.github.com>
Co-authored-by: pladisdev <127021507+pladisdev@users.noreply.github.com>
…4b50-93c4-0e11b13594f4

Clarify error handler ordering is correct - no changes needed
Co-authored-by: pladisdev <127021507+pladisdev@users.noreply.github.com>
Co-authored-by: pladisdev <127021507+pladisdev@users.noreply.github.com>
…47b6-b204-5bf8892748d3

Extract magic numbers to named constants in audio playback code
…4606-8149-97ceaa22873d

Use platform.system() instead of sys.platform for OS detection
Extract duplicated hex opacity calculation to utility function
Extract avatar active offset magic number into configurable setting
Fix audio reference cleanup on play() failure in popup mode
Fix race condition in popup avatar lifecycle
Copilot AI review requested due to automatic review settings November 25, 2025 22:27
@pladisdev pladisdev merged commit d2a1ba9 into main Nov 25, 2025
14 checks passed
@github-actions
Copy link

✅ Windows Build Successful

Executable: ChatYapper.exe (68.31 MB)
MSI Installer: ChatYapper-1.3.1.msi (67.65 MB)
App Version: 1.3.1
Build ID: build-v1.3.1-2025.11.25-3af4c76
Commit: 3af4c76

Build Status

  • ✅ Windows executable & MSI installer
  • 🔄 Linux build (check separate job)
  • 🔄 Docker image (check separate job)

Download the artifacts from the workflow run to test before merging.

Once merged to main, an official release will be created automatically with tag v1.3.1.

Copy link
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 increments the application version to 1.3.1 and implements improvements to Twitch bot reliability, focusing on preventing duplicate bot instances and enhancing error handling during startup and restart operations.

Key Changes

  • Added duplicate bot start prevention logic in both startup and restart flows to avoid race conditions
  • Enhanced error handling in TwitchBot's event_ready method with explicit error logging and channel joining for TwitchIO 3.x compatibility
  • Implemented port binding error suppression in the custom exception handler to reduce noise from expected duplicate start attempts

Reviewed changes

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

File Description
deployment/ChatYapper.wxs Version bump from 1.3.0 to 1.3.1
backend/modules/twitch_listener.py Added explicit channel join call in event_ready for TwitchIO 3.x and improved error logging (changed from silent pass to detailed error logging)
backend/app.py Added duplicate task prevention checks in restart_twitch_if_needed and startup, added event router debug logging, port release delays (0.3s), and OSError suppression for port binding conflicts
Comments suppressed due to low confidence (1)

backend/app.py:527

  • The route_twitch_event function is duplicated in both restart_twitch_if_needed and startup with identical implementation (including the new logging line). Consider extracting this into a module-level function or a method to eliminate code duplication and ensure consistency.
            async def route_twitch_event(e):
                logger.info(f"[EVENT ROUTER] Received event: type={e.get('type')}, user={e.get('user')}, text={e.get('text', '')[:50]}")
                event_type = e.get("type", "")
                if event_type == "moderation":
                    await handle_moderation_event(e)
                else:
                    # Default to chat event handler
                    await handle_event(e)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment on lines +334 to +336
# Join the channel to start receiving messages (required in TwitchIO 3.x)
await self.join_channels([self.channel_name])
logger.info(f"Joined channel: {self.channel_name}")
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The join_channels() call may be redundant since initial_channels is already passed to the Bot constructor (line 324). In TwitchIO 2.x and potentially 3.x, the bot should automatically join channels specified in initial_channels. This manual join could result in duplicate join attempts. Consider verifying if this is truly required for TwitchIO 3.x, or add version-specific logic to only call this for TwitchIO 3.x if needed.

Suggested change
# Join the channel to start receiving messages (required in TwitchIO 3.x)
await self.join_channels([self.channel_name])
logger.info(f"Joined channel: {self.channel_name}")
# Only join manually for TwitchIO 3.x; 2.x and earlier join via initial_channels
if self._major == 3:
await self.join_channels([self.channel_name])
logger.info(f"Joined channel: {self.channel_name}")

Copilot uses AI. Check for mistakes.
Comment on lines +516 to +517
# Give the test connection time to fully release the EventSub server port
await asyncio.sleep(0.3)
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

Magic number: The sleep duration 0.3 seconds lacks explanation. Consider adding a comment explaining why this specific duration is needed for port release, or extract it as a named constant (e.g., PORT_RELEASE_DELAY = 0.3) to improve maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines +1616 to +1617
# Give the test connection time to fully release the EventSub server port
await asyncio.sleep(0.3)
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

Magic number: The sleep duration 0.3 seconds lacks explanation. Consider adding a comment explaining why this specific duration is needed for port release, or extract it as a named constant (e.g., PORT_RELEASE_DELAY = 0.3) to improve maintainability and consistency with the identical sleep at line 517.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

🐳 Docker Image Built Successfully

Image: ghcr.io/pladisdev/chat-yapper:pr-3af4c76
Tag: pr-3af4c76

Test this PR with Docker:

docker pull ghcr.io/pladisdev/chat-yapper:pr-3af4c76

docker run -d \
  --name chat-yapper-pr \
  -p 8069:8008 \
  -e TWITCH_CLIENT_ID=your_id \
  -e TWITCH_CLIENT_SECRET=your_secret \
  ghcr.io/pladisdev/chat-yapper:pr-3af4c76

Access at: http://localhost:8069

The Docker image will be published to the GitHub Container Registry when merged to main.

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.

2 participants