Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major improvements #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

biagiopietro
Copy link

@biagiopietro biagiopietro commented Sep 28, 2024

Hello

I encountered in this amazing script and I thought to add some love!!!

Major improvements

Added parallelism when calling Telegram APIs

Using separated processes to call Telegram API and therefore speed up the script.

Added -o option to output in json or yaml

A new option has been added to customize the output and potentially pipe it into other commands:

  1. json
$ python3 tosint.py -t 75XXXXXX67:AXXQi_iKxxxE_mNDxxxxxxxxxzZ8t6QIHak -c -11xxxxx2 -o json
{
    "bot_info": {
        "first_name": "test",
        "username": "fancybot",
        "id": 75XXXXXX67,
        "can_read_all_group_messages": false
    },
    "chat_administrators": null,
    "created_chat_invite_link": null,
    "exported_chat_invite_link": null,
    "chat_member_count": null,
    "chat_info": null,
    "bot_chat_status": "N/A"
}
  1. yaml
$ python3 tosint.py -t 75XXXXXX67:AXXQi_iKxxxE_mNDxxxxxxxxxzZ8t6QIHak -c -11xxxxx2 -o yaml
bot_chat_status: N/A
bot_info:
  can_read_all_group_messages: false
  first_name: test
  id: 75XXXXXX67
  username: fancybot
chat_administrators: null
chat_info: null
chat_member_count: null
created_chat_invite_link: null
exported_chat_invite_link: null

Added automated tests

$ pytest --cov=tosint
<redacted>
---------- coverage: platform darwin, python 3.9.6-final-0 -----------
Name             Stmts   Miss  Cover
------------------------------------
__init__.py          2      0   100%
test_tosint.py      75      1    99%
tosint.py           83     36    57%
------------------------------------
TOTAL              160     37    77%

============================================================================================== 10 passed in 0.08s ==============================================================================================

Note: we can add automated tests and test coverage as GitHub actions to have them run on every pull request if you like.

Updated README.md

Added table of contents and section to run the solution via Docker.

Added Dockerfile

Now it's possible to run the script without necessarily having python installed.

  1. Clone the repository:
git clone https://github.com/drego85/tosint.git
  1. Build docker image:
$ docker build -t tosint .
  1. Run application (interactive mode)
$ docker run -it tosint

or

$ docker run -it tosint -t 75XXXXXX67:AXXQi_iKxxxE_mNDxxxxxxxxxzZ8t6QIHak -c -11xxxxx2

Refactoring

Refactored tosint.py to keep code clean and easy to maintain.

@biagiopietro biagiopietro force-pushed the feature/add_parallelism_tests_and_more branch 3 times, most recently from ca79610 to 5aa53b1 Compare September 28, 2024 18:59
- Added parallelism when calling Telegram APIs
- Added -o option to output in json or yaml
- Added automated tests
- Updated README.md
- Added Dockerfile
- Refactored tosint.py to keep code clean and easy to maintain
@biagiopietro biagiopietro force-pushed the feature/add_parallelism_tests_and_more branch from 5aa53b1 to 5a4531c Compare September 29, 2024 20:25
@biagiopietro
Copy link
Author

@drego85 did you have any chance to look at this?
Thanks in advance! 😄

@drego85
Copy link
Owner

drego85 commented Oct 2, 2024

Ciao, you did a great job!

You have also already implemented some of my ideas 🤗!
Next weekend I will have time to look at everything properly!

I will definitely update you...

@biagiopietro
Copy link
Author

Hey @drego85

Do you have any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants