From c65ae8dc3dc0975f5386a64c4631ba6bd7732eba Mon Sep 17 00:00:00 2001 From: Daniel Omoniyi Date: Sat, 2 Apr 2022 09:41:01 +0000 Subject: [PATCH 1/2] Updated code to work with the latest Telegram update --- add_member.py | 12 ++++++++++-- get_data.py | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/add_member.py b/add_member.py index 779ae49c..1cb8b247 100644 --- a/add_member.py +++ b/add_member.py @@ -143,10 +143,10 @@ def get_group_by_id(groups, group_id): target_group_entity = current_client['target_group_entity'] try: - print('add member: ' + user['user_id']) + print('Adding member: ' + user['username']) user_to_add = InputPeerUser(int(user['user_id']), int(user['access_hash'])) client(InviteToChannelRequest(target_group_entity, [user_to_add])) - print('Add member '+ user['user_id'] +' success') + print('Added member '+ user['username'] +' successfully ;-)') count_add += 1 print('sleep: ' + str(120 / total_client)) time.sleep(120 / total_client) @@ -162,6 +162,14 @@ def get_group_by_id(groups, group_id): continue except UserPrivacyRestrictedError: print("Error Privacy") + except FloodWaitError as e: + print("Error Fooling cmnr") + traceback.print_exc() + print("remove client: " + current_client['phone']) + client.disconnect() + filter_clients.remove(current_client) + + continue except: print("Error other") # break diff --git a/get_data.py b/get_data.py index e7b093df..062fbd2d 100644 --- a/get_data.py +++ b/get_data.py @@ -4,6 +4,8 @@ from telethon.tl.functions.messages import GetDialogsRequest from telethon.tl.types import InputPeerEmpty, UserStatusOffline, UserStatusRecently, UserStatusLastMonth, \ UserStatusLastWeek +from telethon.tl.types import ChannelParticipantsSearch +from telethon.tl.functions.channels import GetParticipantsRequest import json from datetime import datetime, timedelta @@ -65,7 +67,22 @@ def get_data_user(client, group): group_id = str(group.id) print(group_id) - all_participants = client.get_participants(group, aggressive=True) + while_condition = True + my_filter = ChannelParticipantsSearch('') + offset = 0 + all_participants = [] + + while while_condition: + participants = client(GetParticipantsRequest(channel=group, offset= offset, filter = my_filter, limit=200, hash=0)) + + all_participants.extend(participants.users) + offset += len(participants.users) + + print(len(participants.users)) + + if len(participants.users) < 1 : + while_condition = False + results = [] today = datetime.now() last_week = today + timedelta(days=-7) From 062d9534a1f62f963eaec9c64a961575ee1ce01b Mon Sep 17 00:00:00 2001 From: Daniel Omoniyi Date: Sat, 2 Apr 2022 11:01:08 +0000 Subject: [PATCH 2/2] Update README.md --- README.md | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a993bdf3..e51103f8 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # addmember-telegram -Use `python 3` to add member from Group A to Group B (migrate member of your group) +Use `python 3` to add member from Group A to Group B (migrate members of your group) ## Require * Environment of python 3 (Linux, Window) -* Need about 20 accounts to run (Avoid block account Telegram) -* Each account need in Source Group and Target Group -* Notice you region phone -* Your group is Supper group +* Need about 20 accounts to run (Switches accounts automatically when blocked) +* Each account needs to be in Source Group and Target Group +* Notice your region phone +* Your group must be a Super group https://www.wikihow.com/Convert-a-Telegram-Group-to-a-Supergroup-on-PC-or-Mac @@ -37,10 +37,10 @@ Copy file config.json from config.example.json ] } ``` -`group_target` and `group_source`: after run get_data.py and check file in data/group -`accounts`: list account Telegram; each phone, create app in https://my.telegram.org/apps and have api_id, api_hash +`group_target` and `group_source`: after running get_data.py, check files in data/group +`accounts`: list your Telegram accounts; and for each accounts/phone, create an app in https://my.telegram.org/apps and copy the `api_id` and `api_hash` into the config file. -* Step 3: After have file `config.json`, run `python init_session.py`, enter phone and the code you received +* Step 3: After setting up your `config.json` file, run `python init_session.py`, enter phone and the code you received ![Init session](images/step1.png) @@ -63,16 +63,27 @@ After run get data, check again file in data/group and edit file config to chang * Step 5: run `python add_member.py` to add member from `group_source` to `group_target` Logic: - * after add 1 member, sleep 2 minutes - * each account add 35 member --> sleep 15 minutes - * Remove account when Exception Flood - * Break if don't have account + * after adding 1 member, sleep 2 minutes + * after each account adds 35 members --> sleep 15 minutes + * Remove account when there is a Flood Wait Error + * Break if there are no more accounts -Note: If your account blocked, get link https://web.telegram.org/#/im?p=@SpamBot and chat /start to see time released +Note: If your account gets blocked, go to https://web.telegram.org/#/im?p=@SpamBot and chat /start to see the time the ban would be lifted ![Get data](images/block.png) Done! ## Ps: -Because some people interesting my repository create some issue, inbox Telegram. I don't have time to solve it, so I update your script to be good. I will open issue and try to resolved it. But some thing about basic language `python`, please search Internet before create issue! Thanks! +This repo is now actively being maintained and updated by: +south1907 and DanielTheGeek. + +Create a new issue if you have legit issues and we will do our best to resolve them. + +## Contributing: +* Fork the repo on Github +* Clone the repo using `git clone addmember-telegram` +* Make changes and stage the files: `git add .` +* Commit the changes: `git commit -m "Changed a few things"` +* Push the changes to your Github repo: `git push -u origin main` +* Submit a pull request.