The Most Valuable Skill Every Software Developer Should Have

Through the years in my journey as a programmer, I have learned that there’s a set of skills that help on a day to day basis when working on projects. Thanks to the vast information we have on the…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Telegram CLI Cheatsheet

This article contains a collection of useful information and commands for working with Telegram CLI.

The executable of Telegram CLI is called telegram-cli. It starts up an interactive command interpreter in which you type Telegram commands.

Note that you can also execute all of these commands in a one-off fashion without entering the interactive mode of Telegram CLI. For this, use the -e option when you start Telegram CLI:

It is advised to also specify the -W option when you execute commands via the -e option, in order to make sure all the required data has been loaded before executing your commands:

You can also get all the output in JSON format with the --json option:

A list with all the command-line options for the Telegram CLI executable can be printed with:

Here are some things that you need to know about Telegram CLI to better understand the subsequent commands of the cheatsheet.

As explained in my other article about Telegram Basics, there are four peer types in Telegram, namely, users, bots, groups, and channels.

Furthermore, users can be private or public, bots are always public, groups are divided into basic groups and supergroups, where basic groups are always private and supergroups can be private or public, and finally, channels can be private or public.

Remember that public vs. private comes down to having or not having a username. A username makes a peer publicly accessible.

Now, Telegram CLI looks at these peer types a bit differently. Namely:

Here is an overview:

In Telegram, when you upgrade a group from a basic group to a supergroup (remember that every group is by default a basic group, as explained in Telegram Basics), then you actually create a new peer for the supergroup, and the old one for the basic group just sticks around.

The Chat version of MyGroup remains in the state immediately before the group was upgraded to a supergroup. This version is usually not accessed anymore, but it just sticks around as its own peer. The Channel version, on the other hand, is the new supergroup version of MyGroup, and it will contain all the new messages and members. This is the version that you will usually use from now on.

One consequence of this is that if you fetch all the messages from the Channel version of MyGroup with the history command, you get only the messages up to the point where the group has been upgraded to a supergroup. The remaining messages (from creation of the group until the upgrade to a supergroup) are present only in the Chat version of MyGroup.

The old Chat version of a group is usually accessible in Telegram CLI by appending #1 to the group name. That is, for example, MyGroup#1.

In the following cheatsheet commands, the <peer> option identifies the user, bot, group, or channel to which the command applies.

The value of <peer> can be one of the following:

These two options are equivalent.

For example, if you have a supergroup with a display name of Crypto Bay Toronto and a username of cryptobayto,then the following two commands are equivalent:

Just remember this:

Best is, to just use the auto-complete feature of Telegram CLI.

Tip:

You can use the auto-complete feature to get an overview of all the available display names and usernames. The following lists the display names of all the known users and bots:

And to display all the corresponding usernames, type:

This lists the peer display names, and some other information, of the most recently active conversations (most recently active conversation at the bottom).

This is more or less what you see on the home screen of most Telegram apps, but in reverse order (newest conversation at the bottom, and oldest on top).

You can also specify the number of conversations to list like this:

The default value for limit is 100.

The <text> parameter is the text to send. It may or may not be enclosed in single or double quotes. The following values for <text> are equivalent.

However, if you use single or double quotes, you can also insert newlines with \n. For example, you can do something like this:

This sends the following message:

Note: you can send messages like this to any user and bot, and to any group that you are a member of, but not to channels in which you are merely a subscriber, but not an admin. This is because only admins of a channel can send messages to this channel.

This prints the last chunk of messages that have been sent to/from this peer. The limit option defines the number of messages to be printed (the default seems to be 40).

Important: this also marks all the messages with this peer as read.

For example:

The following options also work:

The last option (using only the hash) is probably the preferred one.

Note that this is the only way to join a basic group other than being added by somebody else, as joining via username is not available for basic groups (because basic groups are always private and cannot have a username).

The rest is the same as above (join a basic group via an invite link).

Note that this works for both, private and public, supergroups and channels, as long as the supergroup or channel has generated an invite link.

This invalidates any previously created invite link for this basic group.

This invalidates any previously created invite link for this supergroup or channel.

You can also do:

This prints only the line corresponding to the specified command.

This is the equivalent of “How to get out of Vim” for Telegram CLI.

Add a comment

Related posts:

7 Basic Things I Learned About Writing from Copywriting Pro Gary Halbert

These are just 7 of many lessons I learned reading “The Boron Letters,” a treasure trove of copywriting lessons.

Reworking Dragon Stealing in WnD Reborn

This balance update redistributes the odds of being picked to better suit the rarity distribution of dragon ranks. When dragons were minted, they were assigned a rank between 5–8. Each rank…

Lauren Underwood

Lauren is a nurse from Naperville, Illinois who is stepping forward to run for office representing the Illinois 14 district. Her priorities include fighting for families, strong jobs, smart…