GithubHelp home page GithubHelp logo

guilherme-vasconcelos / aqua Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 188 KB

A Telegram bot for personal utilities

License: GNU Affero General Public License v3.0

Python 100.00%
bot python3 telegram utilities

aqua's People

Contributors

dependabot[bot] avatar guilherme-vasconcelos avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

aqua's Issues

Improve the pre-commit hook

Describe your idea
The current pre-commit hook (located at hooks/pre-commit) is not completely reliable because it doesn't check for tricks such as:

  • Commented authorize;
  • authorize inside string

For instance, these two snippets would be considered OK to the current pre-commit hook:

# @authorize
def start(...):
    ...
'@authorize'
def start(...):
    ...

The task is to create a pre-commit hook that actually checks:

  • If all command handlers (i.e. files in aqua/extensions/commands) and the talk handler (aqua/extensions/talk/talk.py) are actually using a valid authorize (the authorize must be present, correctly placed and not inside a string or comment);
  • If all command handlers are described in the /help command: aqua/extensions/commands/help.py;

Extra information

  • If the new pre-commit hook is not written in bash, remember to update the GitHub workflow accordingly (.github/workflows/pre-commit.yml).
  • Only the function that has the same name as the file needs an authorize (because that's the function which is executed by the bot). For example, the function def start(...) needs an authorize if it is located inside the start.py file.
  • Internal functions (those which begin with _ such as /_invalid, which is to be merged in command-abreviations branch) should not be documented in /help or README, though they must still have an authorize.
  • https://docs.python.org/3/library/ast.html + https://docs.pytest.org/en/6.2.x/ (possibility of writing tests and using AST to verify decorators. With this it is no longer required to have a pre-commit hook. These tests will act as some kind of static analysis.)

Remindme command

  • Jobs queue: verifies once a minute for tasks to be executed. Optionally, save the queue to a file to ensure bot can still execute tasks even if server fails for a while.
  • Command: /remindme
    Example:
    /remindme 10 minute Math class
    The time until reminder must always follow the format: <'minute' | 'hour' | 'day'>

Possibility of using unambiguous abbreviations for commands

Describe your idea
E.g. use the command /l instead of /lorem.
If there are more commands that begin with l, the user should type at least the minimum required for it to be identified as a shortened version of lorem.

Extra information
Maybe a way to implement would be to create at startup time all the unambiguous abbreviations of all the methods, for instance: l, lo, lor, ....
And the ambiguous abbreviations would all be a copy of some /_ambiguous_method command.

Add persistence to Job Queue

Describe your idea
Job Queue is currently lost if Aqua turns off. While this isn't a problem for reminders that are only a few minutes after, it may be a problem for reminders scheduled to hours/days later.

Extra information
Suggestion: create a dump file once at the end of the JobQueue loop using pickle:
https://docs.python.org/3/library/pickle.html

Maybe use inspect.getsource: https://stackoverflow.com/questions/12072252/cant-get-source-code-for-a-method-declared-through-exec-using-inspect-in-pyth

Alternatively, instead of each Job having a function to be executed, they could have a type instead (e.g. send_message type), which are easier to store / load.

Create a client to talk to Aqua

Describe your idea
Currently Aqua requires you to log into Telegram, manually create your bot, manually set its token, etc.

It would be cool to have a client that does all this automatically (to allow you to talk to Aqua more easily): you log into it, then it will create the bot and put it up running for as long as the client is running, and then open Aqua's chat. This way Aqua would actually become user friendly as the user would not need to modify its config and run it manually.

Since the objective is to allow the user to talk to Aqua more easily, the client will only have Aqua's chat.

Extra information
The client could be a fork of https://github.com/telegramdesktop/tdesktop.

Probably create it in a different repo.

Before implementing this, read Telegram's client and API TOS to ensure this idea complies with everything.

Add decorator to easily specify number of arguments

Describe your idea
Instead of manually checking number of arguments in each function, add a decorator.

@num_args(0)
@authorize
def start(...):
    ...

Extra information
There are some edge cases:

  • Some functions require any number of arguments
  • However, some functions can accept a variable number of arguments but require a minimum (such as remindme, which requires at least 3)
  • Suggestion:
    • Omitting @num_args means any number of arguments
    • @num_args(X) means exactly X arguments
    • @min_num_args(X) means at least X arguments
    • @max_num_args(X) means at most X arguments

Extra commands

  • help: display available commands
  • source: link to this repository

Adapt GitHub Actions to use Poetry

Describe your idea
Adapt GitHub Actions to use Poetry and then remove requirements.txt (also remove from CONTRIBUTING.md).
Also merge bandit workflow to run in the same workflow as lint/test.

Message notifications

Describe your idea
Aqua needs a message notifications system to send messages to the user without necessarily them being an answer to something. This could be useful e.g. for some important news, custom alerts at specific times of the day, etc.

Extra information

  1. Job Queue can probably be used to implement it (maybe create some permanent flag for each job. If the job is permanent, then it will always be re-enqueued. Then create some initializer to populate the job queue with the message notifications).
  2. Add a config/message_notifications.json file in which user will be able to pick the notifications they want to receive.

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.