fix(chatbot): resolve channel sender AttributeError and fix empty repai command crash - #135
Open
FPSensor wants to merge 2 commits into
Open
fix(chatbot): resolve channel sender AttributeError and fix empty repai command crash#135FPSensor wants to merge 2 commits into
FPSensor wants to merge 2 commits into
Conversation
…Bot_replies Resolved an issue in the chatBot_replies event handler where messages sent by channels caused an AttributeError: 'Channel' object has no attribute 'bot'. Replaced the direct attribute access with getattr() to safely verify the sender's bot status without crashing the event loop.
…epai Fixed a crash in the repai command when executed without arguments. The previous implementation raised an IndexError and subsequently caused a MessageIdInvalidError by attempting to edit the original message using eod in contexts lacking edit permissions. Replaced the error notification mechanism with a standard reply() to ensure safe execution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses two critical runtime errors in
chatbot.pythat cause event loop crashes and fill console logs with unnecessary exceptions.🐛 Bug Fixes & Changes Made
1. Fix
AttributeErroron Channel Messages (chatBot_replies)Channelentity as the sender rather than aUser. BecauseChannelobjects do not possess a.botattribute, callingif sender.bot:raisesAttributeError: 'Channel' object has no attribute 'bot'.getattr(sender, 'bot', False)and added a check to verifysenderexists before evaluating.2. Fix
MessageIdInvalidError/IndexErroron Empty.repai.repaiwithout a reply target or additional text triggers anIndexErrorwhen attempting to split the command args. The subsequentexceptblock attempted to edit the command message usingeod(), which threw atelethon.errors.rpcerrorlist.MessageIdInvalidErrorin environments without edit permissions on the original message.eod()helper call withevent.reply()in the exception handler to safely alert the user without raising RPC errors.🧪 Testing
.repaiwith no arguments, verified the user receives the missing args prompt via reply without crashing.chatBot_repliesactive; verified noAttributeErroris logged.