GithubHelp home page GithubHelp logo

aitorres / dogpicsbot Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 4.0 541 KB

A simple Telegram bot that sends random dog pictures.

License: MIT License

Python 100.00%
api bot dog-pictures hacktoberfest telegram telegram-api telegram-api-bot telegram-bot

dogpicsbot's Introduction

Welcome to a new dimension! 🌌

I'm AndrΓ©s! Welcome to my little home here on Github.

  • πŸ”­ I’m currently working at Microsoft Vancouver as a Software Engineer.
  • πŸ’» My main (personal) programming language at the moment is Python; I also enjoy Haskell, Typescript, C# and Dart (with Flutter).
  • 🌱 My main side-project right now is a client for Mastodon built in Flutter.
  • πŸ’¬ Some interests: artificial intelligence, natural language processing, federated social networks, compilers and much more!
  • πŸ‘― I’m looking to collaborate on interesting open-source projects!

dogpicsbot's People

Contributors

aitorres avatar baspalinckx avatar dependabot[bot] avatar german1608 avatar gustavoaca1997 avatar seleregb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dogpicsbot's Issues

Reply to a sad message with a dog picture

Right now the bot recognizes certain "triggers" that make it reply with a picture of a dog, such as the word "dog" and a dog emoji.

A cute, new feature for the bot would be to recognize when a message is "sad", e.g. contains a sad emoji, or a sad face :(, or the word "sad" (or any other criteria you can come up with), and reply directly to that message with a dog picture, maybe saying "Here's a dog to make you happy!" or something like that.

Briefly:

  1. While reading new messages, the bot should recognize when a message is "sad", under any criteria (for example the one mentioned above)
  2. If a message is "sad", the bot should reply directly to that mesage (not just send a general message)
  3. The reply should have a random dog picture and a cute message such as the one suggested.

Send message immediately after verifying a possibility

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

Follow PEP 8 style guide for variables

Generally speaking, the code in bot.py does not follow PEP 8's style guide for variables (e.g. variables such as isSadMessage and HELP_MSG should be in snake_case). The code should be updated to follow PEP 8 naming conventions.

Bonus: there are some lines that are longer than 100 characters, they should also be reduced to 100 characters or less.

Refactor and merge the two "send_image" methods

The bot's two methods that take care of sending pictures (send_dog_picture and send_fox_picture) are very similar. The duplicate logic should be moved to a separate function called in both places, or otherwise refactored so that we don't duplicate code.

Besides this change, it would be a bonus if all the calls to context.bot.send_photo would reply to the received message_id :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.