vysheng / tg

telegram-cli
GNU General Public License v2.0
6.45k stars 1.53k forks source link

Channel_info does not return channel link in json mode #1034

Open aziziphp opened 8 years ago

aziziphp commented 8 years ago

Hi channel_info returns channel public link in usual mode but not in json mod. Is there any other trick to get link of a channel in json mode?

khapota commented 8 years ago

Did you add --json?

aziziphp commented 8 years ago

yes

bogdaniy commented 8 years ago

You can use resolve_username command, and then use channel_info with channelId as argument.

aziziphp commented 8 years ago

resolve_username does not work for channel name.

ingria commented 8 years ago

It does work for public channels (the ones with usernames). Are you sure you're using the test branch?

aziziphp commented 8 years ago

Yes I am using test branch. when I try resolve_username channelname. It retruns FAIL:71: RPC_CALL_FAIL 400: USERNAME_INVALID . It's a public channel.

ingria commented 8 years ago

It must be used without @:

> resolve_username telegram
{
    "admins_count": 0,
    "peer_id": 1005640892,
    ...
    "title": "Telegram News",
    "kicked_count": 0
}
> resolve_username @telegram
{"error": "RPC_CALL_FAIL 400: USERNAME_INVALID", "result": "FAIL", "error_code": 71}
aziziphp commented 8 years ago

Now I understand what you mean. We should provide channel link and get channel name. I wanted the opposite. But I think I can change my code to adapt limitations. thank you anyway.

jasonrhaas commented 8 years ago

@codefuhrer I don't think the original question was answered. The problem is that it seems that the channel_info command has a different output if you are running in --json mode vs. without it.

For example, just running telegram-cli:

> channel_info Telegram_News
Channel [verified] [broadcast] Telegram News @telegram (#1005640892):
    about: The official Telegram on Telegram. Much recursion. Very Telegram. Wow.
    69384 participants, 0 admins, 0 kicked

If I run with telegram-cli --json:

> channel_info Telegram_News
{
    "id": "$05000000bcdcf03b76355d7faddb6a64",
    "peer_type": "channel",
    "admins_count": 0,
    "flags": 65675,
    "peer_id": 1005640892,
    "print_name": "Telegram_News",
    "title": "Telegram News",
    "kicked_count": 0,
    "participants_count": 69384
}

The first example has the channel link, @telegram. The second one does not.