-
Notifications
You must be signed in to change notification settings - Fork 0
Development #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development #35
Conversation
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
…into development
✅ Windows Build SuccessfulExecutable: Build Status
Download the artifacts from the workflow run to test before merging. Once merged to |
There was a problem hiding this 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_readymethod 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_eventfunction is duplicated in bothrestart_twitch_if_neededandstartupwith 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.
| # 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}") |
Copilot
AI
Nov 25, 2025
There was a problem hiding this comment.
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.
| # 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}") |
| # Give the test connection time to fully release the EventSub server port | ||
| await asyncio.sleep(0.3) |
Copilot
AI
Nov 25, 2025
There was a problem hiding this comment.
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.
| # Give the test connection time to fully release the EventSub server port | ||
| await asyncio.sleep(0.3) |
Copilot
AI
Nov 25, 2025
There was a problem hiding this comment.
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.
🐳 Docker Image Built SuccessfullyImage: 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-3af4c76Access at: http://localhost:8069 The Docker image will be published to the GitHub Container Registry when merged to |
No description provided.