Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channels with spaces in their name? #3

Closed
Mycah opened this issue Nov 8, 2022 · 4 comments
Closed

Channels with spaces in their name? #3

Mycah opened this issue Nov 8, 2022 · 4 comments

Comments

@Mycah
Copy link

Mycah commented Nov 8, 2022

I'm trying to connect to channels with spaces in their name and constantly get errors.

$ python ./main.py --telegram-channel Channel\ Name

Init program at Tue Nov  8 19:54:38 2022


> Authorized!

> Collecting data from Telegram Channel -> Channel Name
> ...

Traceback (most recent call last):
  File "/home/xxx/telegram/telegram-api/./main.py", line 161, in <module>
    entity_attrs = loop.run_until_complete(
  File "/home/xxx/miniconda3/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/xxx/telegram/telegram-api/api/__init__.py", line 57, in get_entity_attrs
    return await client.get_entity(source)
  File "/home/xxx/miniconda3/lib/python3.9/site-packages/telethon/client/users.py", line 335, in get_entity
    result.append(await self._get_entity_from_string(x))
  File "/home/xxx/miniconda3/lib/python3.9/site-packages/telethon/client/users.py", line 574, in _get_entity_from_string
    raise ValueError(
ValueError: Cannot find any entity corresponding to "Channel Name"

I've tried with quotes and with \, same error.

I also created a text file with the channel names using --batch-file, and it fails in the same manner.

@estebanpdl
Copy link
Owner

The channel name that you are adding is not actually the name in the URL. You need to select only the channel's name that is visible in the URL. https://t.me/ChannelName. Telegram's API only recognizes the official name, again, the one that is in the URL.

@Mycah
Copy link
Author

Mycah commented Nov 8, 2022

Is there a way to find that within the client? I only have invite links (which don't have channel names either), and can't see any way to find them using the web ui or desktop app.

fyi i used telethon to to do this:

async for dialog in client.iter_dialogs():
    if dialog.is_channel:
        print(f'{dialog.id}:{dialog.title}')

It only gave me the same titles i see in the apps.

@estebanpdl
Copy link
Owner

Why dont you click on the channel's name using the desktop app (above number of subscribers)? This will open a pop-up. There, you can see something like t.me/channelname. Using the client, you will need to find in docs the class GetChannelsRequest or GetFullChannelRequest. Those will return data from the requested channel, but you need either the channel name (without spaces) or the channel id.

@Mycah
Copy link
Author

Mycah commented Nov 8, 2022

I stupidly got my phone number banned, I guess trying to login too much. I'll try those options once I can connect again. I did look in the info for the channel, etc and couldn't find any t.me links, but now that I'm locked out I can't confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants