def join_channel(client: TelegramClient, channel) -> bool:
    """Join channel. Returns whether client joined or not."""
    try:
        client(channels.JoinChannelRequest(channel))

    except errors.RPCError:
        return False

    # Verify if client joined channel or not
    chat = client(channels.GetChannelsRequest([channel])).chats[0]

    return not chat.left and not chat.restricted
Example #2
0
def join(client, channel):
    request = channels.JoinChannelRequest(channel)
    request.resolve(client, telethon.utils)
    client(request)