Code Monkey home page Code Monkey logo

round_robin_tasker's Introduction

dattatreya303 codecov

round_robin_tasker

A telegram bot for groups to assign a task to members in a round robin manner.

Commands supported by the bot

  1. /add_task - Create a new task
  2. /check_task - Check next turn for an existing task
  3. /list_tasks - List all active tasks in this chat
  4. /delete_task - Delete an existing task and all its data
  5. /cancel - Terminate an ongoing command
  6. /help - To know what each command does

The bot will consider only explicit replies to continue the conversation.

Contributing

Install dependencies

  • Python 3.7.2
  • Create a virtual environment: virtualenv venv && source venv/bin/activate
  • Install requirements: pip install -r requirements.txt

Generate test reports for changes

  • Run tests: pytest --junitxml test-results/pytests.xml --cov=. --cov-report xml
  • Test summary: test-results/pytests.xml
  • Coverage report: coverage.xml

Starting the server

  • Create a test bot using BotFather on Telegram.
  • Set secrets as environment variables by running the following script:
      #!/bin/sh
      export RRT_TOKEN="<test-bot-token>"
      export RRT_PERSISTENCE_PREFIX="<path-and-prefix-for-chat-data-store"
  • Start server: python bot.py

round_robin_tasker's People

Contributors

dattatreya303 avatar

Watchers

James Cloos avatar  avatar

round_robin_tasker's Issues

Add persistence to conversation handler

To make a conversationhandler persistent (save states between bot restarts) ConversationHandler(<no change>, persistent=True, name='my_name') If you want a conversationhandler to be persistent you MUST NAME IT. persistent is False by default. Adding these arguments and adding the conversationhandler to a persistence-aware updater/dispatcher will make it persistent.

Handle commands interrupting a conversation

Problem: Updates get checked through the handlers sequentially. So if a user, while in the midst of a conversation, sends a command which is processed before the concerned conversation handler by the dispatcher, it messes up the conversation (especially if its another conversation).

Possible fixes:

  1. Maintain a var in context.chat_data to identify any ongoing conversation. Check that var at the beginning of all command entry point callbacks. Proceed only if the var is empty.
  2. Maintain a var in context.chat_data to identify any ongoing conversation. Add a top-level nested conversation handler. the entry point should be any message, the timeout should be infinite, states should correspond to actual user commands. Make the entry point a command handler. First, perform the check for an ongoing conversation and if found return that state. If no ongoing conversation, return the state corresponding to the command (over a switch case preferably).
  3. Maintain a global var to identify any ongoing conversation. Send all updates to that handler only. Will require changes in the library. We will have to use a fork of the library with our changes, and not download from pip. Will need to create a separate build script.

Add /start command callback method

  • Introduce the bot and what it does.
  • Mention the test bot for experimental features
  • Show the list of commands and brief instructions
  • Mention telegram id for feedback

Add unit testing

  • Make test cases for each issue labelled with feature and bug.
  • Make it a norm to write test cases first for all future features and bugs.

Update README

The first part should be same as #13 .
Add more details about repo structure, deployment process, persistence, todos etc

Missing chat id checks on chat data context

Key checks are missing for chat id in context.chat_data in several places. This is leading to KeyErrors when starting the server or sending a command in a chat with no associated ChatData object.

Decentralise logging

A single log handler is being used right now, which belies source (class: function) of the log. Separate log handlers for each file/class would give more comprehensive information.

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.