-
-
Save TheHercules/d2c0125bbb6621e0f51f5386b296cf80 to your computer and use it in GitHub Desktop.
Some random gist k
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| if sys.version_info[0] < 3 or sys.version_info[1] < 6: | |
| LOGGER.error("You MUST have a python version of at least 3.6!") | |
| quit(1) | |
| from telethon import TelegramClient, events | |
| from async_generator import aclosing | |
| from telethon.tl.functions.channels import InviteToChannelRequest | |
| rom telethon.tl.functions.channels import GetParticipantsRequest | |
| from telethon.tl.types import ChannelParticipantsSearch | |
| api_id=os.environ['API_KEY'] | |
| api_hash=os.environ['API_HASH'] | |
| bot = TelegramClient('userbot', api_id, api_hash) | |
| bot.start() | |
| @bot.on(events.NewMessage(outgoing=True,pattern=".transfer")) | |
| async def transfer(e): | |
| offset = 0 | |
| limit = 100 | |
| all_participants = [] | |
| while True: | |
| participants = bot(GetParticipantsRequest( | |
| e.chat_id, ChannelParticipantsSearch(''), offset, limit, hash=0 | |
| )) | |
| if not participants.users: | |
| break | |
| all_participants.extend(participants.users) | |
| offset += len(participants.users) | |
| bot(InviteToChannelRequest(ID_TO_ADD, [all_participants] )) | |
| bot.run_until_disconnected() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment