Giter VIP home page Giter VIP logo

telegram-id's Introduction

How to get an id to use on Telegram Messenger

The ultimate guide

Attention

This guide aims on bot developers. If you don't develop Telegram Chatbots or don't use Telegram CLI, this guide is not for you. Don't expect to get phone numbers or to join groups by their id. Both are impossible.

Telegram Web

Available on https://web.telegram.org

Follow the steps displayed to log in the app.

Web User ID

It's not possible to find the user ID using this method. So, the easiest way to do it is talking to @userinfobot. If you need to find somebody else's ID, forward a message to the bot.

This bot is not mine! Use it on your own risk!

Web Group ID

Click on the group you want and see the url displayed on your browser.

If it's a public group, you can simply use it's @name as an id.

If it's private group, the url must be like:

https://web.telegram.org/#/im?p=g331054

If this is the case, then the group ID is -331054. Always negative!

For private super groups the url must be like:

https://web.telegram.org/#/im?p=s1041843721_16434430556517118330

If this is the case, then the group ID whois be 1041843721. But it's important to know that super group IDs are always a 13 characters negative integer, so the correct ID is -1001041843721.

Web Channel ID

Click on the channel you want and see the url displayed on your browser.

If it's a public group, the ID is @name of the group.

If it's a private group then the url must be similar to:

https://web.telegram.org/#/im?p=c1018013852_555990343349619165

If this is the case, then the channel ID would be 1018013852. It's important to know that channel's IDs are always negative and 13 characters long! So add -100 to it, making the correct ID -1001018013852.

Telegram-CLI

The best way I found to get ids is using Telegram-CLI.

It's available on https://github.com/vysheng/tg

Install and run it. I recommend using bot mode -b, but it's optional.

Run Telegram CLI:

bin/telegram-cli -k tg-server.pub -b

Wait for it do load and then paste a bot token.

The output must be similar to this:

root@prod:/usr/src/tg# bin/telegram-cli -k tg-server.pub -b
change_user_group: can't find the user telegramd to switch to
Telegram-cli version 1.4.0, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 2.1.0
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/root/.telegram-cli]
[/root/.telegram-cli] created
[/root/.telegram-cli/downloads] created
hash: 

CLI User ID

To get a user id, ask the user to send any message do the bot and observe it on Telegram CLI window.

The message must appear similar to this:

[11:07]  Gabriel R F »»» /start

Then, on Telegram CLI, type:

user_info Gabriel_R_F

Note that spaces are replaced by _.

The output will be something like this:

User Gabriel R F @GabrielRF (#9083329):
        phone: (null)
        offline (was online recently)

There you go! The user id, on this example, is 9083329.

CLI Group ID

Add the bot to the group. On Telegram CLI, a message will be printed.

[11:12]  test Gabriel R F added user test

Then, on Telegram CLI, type

chat_info test

Where test is the group's name. Note that spaces are replaced by _.

The output on Telegram CLI will be similar to:

Chat test updated admin members
Chat test (id 148228539) members:
                test invited by Gabriel R F at [2016/03/29 11:12:30]
                Gabriel R F invited by Gabriel R F at [2016/03/29 11:11:18] admin

So, the id for the example group is -148228539.

Group ids are always a negative integer, so remember to add the - while using it on the Telegram API.

CLI Channel ID

Finally, to get a channel id, add the bot as a channel administrator.

On Telegram CLI type:

channel_info test

where test is the channel's name. The output must be like this:

Channel test (id 1035716040):
                2 participants, 2 admins, 0 kicked

Here is the trick. Every channel id is a 13 characters negative integer. So the id for this channel is -1001035716040 and not 1035716040 as printed.

Questions?

Talk to me on Telegram Messenger! @GabrielRF

telegram-id's People

Contributors

gabrielrf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.