Changelog - Version 5.4 (2025-09-20)
Version Information
This is the largest update that we’ve done to date – the many changes in the following new version take into account 90% of community-requested changes.
- Updated version from 5.3 to 5.4
- Improved version and system identifier handling
- Enhanced environment variable reloading and management
New Features & Major Changes
SSH Management
- Introduced
SSHConnectionManager
class for robust SSH connection pooling and command execution - Centralized SSH credentials and host management via environment variables
- Improved error handling and connection cleanup for SSH operations
Logging System Improvements
- Refined logger setup to prevent duplicate handlers
- Improved log directory creation and management
- More detailed and consistent startup and event logging
Twitch & Spotify Integration
- Expanded Twitch EventSub and API event handling
- Improved Twitch token refresh logic and error handling
- Enhanced Spotify token management and error reporting
- Removed Spotify token refresh logic and associated scheduled tasks from the bot, as token management has been migrated to a centralized system.
- More robust handling of Twitch and Spotify API credentials
- Enhanced the
!songrequest
command to support YouTube links; the bot will now automatically find the corresponding track on Spotify and add it to the queue. - Added support for direct Spotify track links to the
!songrequest
command, allowing users another method to queue specific songs. - Added an automated pre-ad warning system; the bot will now notify the chat 5 minutes prior to an upcoming ad break.
- Implemented a chat notification to inform viewers whenever a scheduled ad break has been snoozed.
Websocket & External Service Enhancements
- Added & expanded websocket event handlers for Fourthwall, Ko-fi, Patreon, and weather data
- Improved integration with tipping services (StreamElements, StreamLabs)
- More modular websocket and event processing functions
- Refactored StreamElements token management. The bot no longer handles token refreshes on reconnection; this process is now automatically managed by the web dashboard’s OAuth2 login flow, simplifying connection logic.
- Enhanced HypeRate heart rate monitoring with persistent websocket connection, improved error handling, and automatic reconnection for reliable real-time data.
Command & Event Handler Refactoring
- Refactored and expanded command handler structure for maintainability
- Improved global variable initialization and usage across commands
- More modular and organized event and command processing
- Expanded support for custom commands and user interaction features
- Enhanced custom commands using the
(count)
variable. Users can now specify a number in the command message (e.g.,!cmd 5
) to increment the count by that amount, while the command defaults to incrementing by 1 if no number is given. - Enhanced custom commands using the
(usercount)
variable. Users can now specify a number in the command message (e.g.,!cmd 5
) to increment the per-user count by that amount, while the command defaults to incrementing by 1 if no number is given. - Added a new chat response variable,
(userstreak)
, for channel point redemptions. This variable tracks and displays a user’s uninterrupted claim streak for a reward, which resets if another user claims it. - Added a
!skip
command for the song request system, allowing moderators to skip the current track. - Added owner-only custom commands with cooldowns and moderator/streamer override. Members can have custom commands that only the named owner may run, each with a cooldown. Moderators or the streamer can still run or override these commands when needed.
- Overhauled lurk command with community-requested timer toggle functionality
- Added configurable timer option that can be enabled/disabled via website
- When timer is enabled: Shows accumulated lurk time and resets timer on subsequent uses
- When timer is disabled: Simple lurk acknowledgment without time tracking
- Enhanced lurk time display to include years and improved calculation precision for long durations
- Optimized code by creating a reusable
format_lurk_time()
function to eliminate duplication across!lurk
,!lurking
,!lurklead
, and!unlurk
commands
- Added a new
!userslurking
command that displays the count of users currently lurking - Added a new
!gamble
command allowing users to bet points on games including coinflip, blackjack, and roulette.
Backend & Technical Improvements
- Improved environment variable reloading with
reload_env_vars()
- More robust MySQL connection handling and error management
- Expanded and improved data structure initialization for runtime state
- Enhanced signal handling for graceful shutdown (SIGTERM, SIGINT)
- Improved error handling and logging throughout the codebase
- Implemented a secure
safe_math
function for custom commands to prevent arbitrary code execution by safely evaluating only basic arithmetic operations. - Enhanced the security of the existing
fetch_api_response
function; it now converts returned JSON data to a string to mitigate potential vulnerabilities in custom commands. - Optimized the
check_stream_online()
function to reduce Twitch API calls by conditionally calling the channels endpoint only when the stream is offline. - Optimized the
channel_point_rewards()
function to useINSERT ... ON DUPLICATE KEY UPDATE
for better database performance. - Optimized the
known_users()
function to use batch database inserts and reduce round trips for better performance when handling moderators and VIPs. - Optimized the
check_premium_feature()
function to parallelize independent API calls usingasyncio.gather
, reducing execution time. - Optimized the
make_stream_marker
function with input validation, timeout handling, enhanced error logging, and simplified error handling for better reliability. - Optimized the
track_watch_time
function to use batch database operations, reducing query count from O(n) to O(1) for better performance when tracking watch time for multiple active users. - Optimized the
return_the_action_back
function to use dynamic SQL and reduce code duplication for better maintainability. - Optimized ad settings caching to refresh every minute, ensuring up-to-date information while maintaining performance benefits.
- Fixed snooze feature in ad system to prevent sending duplicate messages when ads are snoozed and upcoming notifications are checked.
- Cleaned up unnecessary
global
declarations in module-level and function scopes for better code organization and adherence to Python best practices. - Optimized the
subscribe_to_events
function to use concurrent API calls withasyncio.gather
for faster Twitch EventSub subscriptions, replacing sequential loops. - Fixed the condition for
channel.chat.user_message_hold
EventSub subscription by correcting the user_id field to resolve validation errors.
Bug Fixes
- Fixed issues with logger handler duplication
- Improved error handling for API and websocket failures
- Fixed and improved timed message and scheduled task management
- Resolved a bug that could cause timed messages to spam the chat, ensuring they now adhere to their configured schedules.
- Addressed minor issues in command and event processing logic
- Fixed AI Song Request Confirmation: Addressed an issue where the AI Talking Module would incorrectly confirm song requests made in natural language. The AI will now respond by reminding the user it is a chatbot and will direct them to use the proper
!songrequest
command to queue music. - Improved Spotify Song Request Accuracy: Fixed an issue where the song request feature would sometimes queue an instrumental version of a track. The logic has been updated to better prioritize the original, non-instrumental version.
- Fixed !convert Command API Tracking: Migrated API usage tracking from file-based to database-based system to resolve file path errors and improve reliability
- Removed unnecessary warning log in
periodic_watch_time_update
function to prevent log spam when no active users are found.
Backend Structure Updates
- Added/expanded data structures for SSH, websocket, and event management
- Improved asynchronous task management by storing looped tasks (e.g., ad checks, timed messages) in a named dictionary. This allows for more granular control, including the ability to cancel specific tasks by name.
- Improved code organization and modularity for future development
Thank you for your feedback and support!
As always, your feedback is appreciated. Please report any issues or suggestions in the #get-support channel on our Discord server. You can also submit feedback directly on our website: https://botofthespecter.com/feedback.php