Skip to content

Send message immediately after verifying a possibility #13

@aitorres

Description

@aitorres

The handle_text_messages function handles the bot's responses to a given text message, if any. The bot can respond in three different ways: either sending a fox image if the message mentions a fox, sending a random dog picture if the message mentions a sad word or emoji, or sending a random dog picture (possibly of a given breed) if the message otherwise mentions dogs.

Right now, the method checks for all these possibilities and after checking everything, messages back. However, this is doing unnecessary checks at times: for example, if my message contains a fox word or image, I should reply immediately without checking if there are sad words or breed names.

Fixing this issue requires reordering the statements in the handle_text_messages method so that:

  • If has_fox_emoji evaluates to True right after assigning it, call and return with the method send_fox_picture (instead of doing it by the end of the function)
  • Check for breeds
  • Assign is_sad_message and if it evaluates to True right after assigning it, call and return this instead of doing it by the end of the function
  • Finally, perform the rest of the checks and if any of them evaluate to True, call and return this

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions