Code Monkey home page Code Monkey logo

tg-secret-santa-bot's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tg-secret-santa-bot's Issues

Join command doesn't work in this case

A friend of mine clicked join button after we created a /newsanta but the bot doesn't let him to be added.
I don't know why but it seems it's not working only with him.

I summarize the use case below.

  1. he taps join
  2. the bot redirect him to the private chat.
  3. He taps /start
  4. The bot replies with this:

[Forwarded from Secret Santa bot πŸ€«πŸŽ…πŸΌπŸŽ]
Hello "name"!
I can help you organize a Secret Santa πŸ€«πŸŽ…πŸΌπŸŽ in your group chats :)
Just add me to a chat and use /newsanta to start a new Secret Santa.

Source code here

instead of

πŸŽ„ You joined "name" 's Secret Santa!
Now wait for "name" to start it. You will receive your match here, in this chat

Improve handling of scenario where creating match pairs requires too many attempts

The "retry to generate the secret santa pairs" logic should be inside the "start match" button handler. The utilities' function should raise a TooManyAttempts exception and the handler callback should handle it and retry the draft if necessary. Maybe we should also set a max number of retries, and notify the user (and maybe post in the log channel) if that number is reached (to avoid to also block the bot for everyone)

Handle "Message to edit not found" errors

We receive them when the secret santa message has been deleted and /commands (or private chats buttons) are used

There should be a decorator catching them. Then, what to do?

Ideas:

If command: answer "the secret santa message has been deleted, therefore the secret santa has been canceled"

If private chat button: answer "the secret santa message has been deleted, therefore the secret santa has been canceled"

Allow the santa creator to set forbidden matches

Allow the santa creator to set forbidden matches. Strictly related to #9

The secret santa message in the group should have an inline button/deeplink that allows anyone to consult the list of forbidden matches. When used, the list will be returned in private chat, and the secret santa creator will see a button to edit it

If the creator wants to edit it, the bot will provide an inline keyboard with the participants. They will be able to pick one participant, and then another one from the same list. Once two items are picked, the bot will add them to the list and will show the list again with the edit button.

We should make sure to be able to limit the number of forbidden matches based on the current participants count in a way that an hamiltonian path is found, but it can happen directly when the secret santa is started and the matching process fails too many times: at this point we will warn the creator that the current constraints make it impossible to execute a draw

Modularize handlers

All handlers should be in a dedicated handlers/ directory where we initialize all handlers and then we import it in the main file

import handlers.santa_buttons
import handlers.private
...

dispatcher.add_handler(handlers.private.start)
dispatcher.add_handler(handlers.private.help)
dispatcher.add_handler(handlers.santa_buttons.start_match)
...

eg. handlers/private.py

def on_start_command(update, context):
  pass

start = CommandHandler("start", on_start_command)

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.