Skip to content

Commit

Permalink
Merge pull request south1907#36 from DanielTheGeek/master
Browse files Browse the repository at this point in the history
Updated the code to work with latest Telegram updates
  • Loading branch information
south1907 authored Apr 26, 2022
2 parents ea51d77 + 062d953 commit 0baa634
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 17 deletions.
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)

Expand All @@ -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.
12 changes: 10 additions & 2 deletions add_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
19 changes: 18 additions & 1 deletion get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0baa634

Please sign in to comment.