Major improvements
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:
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"
}
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.
- Clone the repository:
git clone https://github.com/drego85/tosint.git
- Build docker image:
$ docker build -t tosint .
- 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.
@drego85 did you have any chance to look at this? Thanks in advance! 😄
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...
Hey @drego85
Do you have any updates?