Given a user with credentials, this script grabs all the groups and channels for the given user, allows you to select one, and exports all users into a CSV file within the same directory. It also gives the option to add users to your groups or channels.
I have refactored this script in a non-breaking way. I found this other repository that has multiple scripts that takes code from this script and has optimized it to have some extra features like resume capabilities.
I wanted to back-port the resuming feature, but ended up refactoring pretty much the entire script. My initial intention was to only bring in whatever extra code that was in the scrapper_and_adder script. But now the script looks nowhere like what the other one looks like. The only function that I haven't touched is printCSV() ( apart from minor compatibility changes ). I couldn't find its place and am confused why it even exists in the script.
Summary :
global
function-ize logging into telegram and selecting groups
use built-in logging module
handle more Exceptions
list_users_in_group
renamed to export_users
iterate over participant list and write directly to CSV
add_users_to_group ( this is where the majority of the refactor effort went into )
add support for normal groups
add resume capability
auto-detect mode from CSV header if it contains only a single column
PS : The reason why the files don't show line-by-line changes is because the files had CRLF line-endings which I reset to LF. Navigating that changes by commit will show the changes line-by-line. After all, one should navigate each commit in a refactor one-by-one. I believe I have maintained proper contexts and written good messages in my commits.
I have refactored this script in a non-breaking way. I found this other repository that has multiple scripts that takes code from this script and has optimized it to have some extra features like resume capabilities.
I wanted to back-port the resuming feature, but ended up refactoring pretty much the entire script. My initial intention was to only bring in whatever extra code that was in the
scrapper_and_adder
script. But now the script looks nowhere like what the other one looks like. The only function that I haven't touched isprintCSV()
( apart from minor compatibility changes ). I couldn't find its place and am confused why it even exists in the script.Summary :
logging
moduleException
slist_users_in_group
export_users
add_users_to_group
( this is where the majority of the refactor effort went into )PS : The reason why the files don't show line-by-line changes is because the files had CRLF line-endings which I reset to LF. Navigating that changes by commit will show the changes line-by-line. After all, one should navigate each commit in a refactor one-by-one. I believe I have maintained proper contexts and written good messages in my commits.