Telegram CLI Commands

2012mjm edited this page Dec 24, 2016 · 2 revisions

Telegram CLI basically works in some kind of interactive mode: besides arguments passed at the launch of the tg process, it is controlled by keywords that need to be entered (or sent in cases of network control) interactively after the process is launched. Usually, when tg is ready, the user enters these in the shell telegram is running in, but since tg supports listening on a port, they can be sent over network as well. (useful if the application is running in daemon mode or no access to the parent shell is given because of any reason)

This way of operation is called "interactive", because the user controls the application by commands after its launch, and commands usually give individual output.

Available commands

This is a list of all available commands in Telegram CLI. It is also available by calling the help-command in a running tg-cli-session.

  • accept_secret_chat <secret chat> Accepts secret chat. Only useful with -E option
  • add_contact <phone> <first name> <last name> Tries to add user to contact list
  • broadcast <user>+ <text> Sends text to several users at once
  • chat_add_user <chat> <user> [msgs-to-forward] Adds user to chat. Sends him last msgs-to-forward message from this chat. Default 100
  • chat_del_user <chat> <user> Deletes user from chat
  • chat_info <chat> Prints info about chat (id, members, admin, etc.)
  • chat_set_photo <chat> <filename> Sets chat photo. Photo will be cropped to square
  • chat_with_peer <peer> Interface option. All input will be treated as messages to this peer. Type /quit to end this mode
  • clear Clears all data and exits. For debug.
  • contact_list Prints contact list
  • contact_search username [limit] Searches contacts by username
  • create_group_chat <name> <user>+ Creates group chat with users
  • create_secret_chat <user> Starts creation of secret chat
  • del_contact <user> Deletes contact from contact list
  • delete_msg <msg-id> Deletes message
  • dialog_list List of last conversations
  • export_card Prints card that can be imported by another user with import_card method
  • fwd <peer> <msg-id> Forwards message to peer. Forward to secret chats is forbidden
  • fwd_media <peer> <msg-id> Forwards message media to peer. Forward to secret chats is forbidden. Result slightly differs from fwd
  • help Prints this help
  • history <peer> [limit] [offset] Prints messages with this peer (most recent message lower). Also marks messages as read
  • import_card <card> Gets user by card and prints it name. You can then send messages to him as usual
  • load_audio <msg-id> Downloads file to downloads dirs. Prints file name after download end
  • load_document <msg-id> Downloads file to downloads dirs. Prints file name after download end
  • load_document_thumb <msg-id> Downloads file to downloads dirs. Prints file name after download end
  • load_file <msg-id> Downloads file to downloads dirs. Prints file name after download end
  • load_file_thumb <msg-id> Downloads file to downloads dirs. Prints file name after download end
  • load_photo <msg-id> Downloads file to downloads dirs. Prints file name after download end
  • load_video <msg-id> Downloads file to downloads dirs. Prints file name after download end
  • load_video_thumb <msg-id> Downloads file to downloads dirs. Prints file name after download end
  • main_session Sends updates to this connection (or terminal). Useful only with listening socket
  • mark_read <peer> Marks messages with peer as read
  • msg <peer> <text> Sends text message to peer
  • quit Quits immediately
  • rename_chat <chat> <new name> Renames chat
  • rename_contact <user> <first name> <last name> Renames contact
  • restore_msg <msg-id> Restores message. Only available shortly (one hour?) after deletion
  • safe_quit Waits for all queries to end, then quits
  • search [peer] [limit] [from] [to] [offset] pattern Search for pattern in messages from date from to date to (unixtime) in messages with peer (if peer not present, in all messages) generate new key for active secret chat
  • send_audio <peer> <file> Sends audio to peer
  • send_contact <peer> <phone> <first-name> <last-name> Sends contact (not necessary telegram user)
  • send_document <peer> <file> Sends document to peer
  • send_file <peer> <file> Sends document to peer
  • send_location <peer> <latitude> <longitude> Sends geo location
  • send_photo <peer> <file> [caption] Sends photo to peer
  • send_text <peer> <file> Sends contents of text file as plain text message
  • send_typing <peer> Sends typing notification
  • send_typing <peer> Sends typing notification abort
  • send_video <peer> <file> [caption] Sends video to peer
  • set <param> <value> Sets value of param. Currently available: log_level, debug_verbosity, alarm, msg_num
  • set_password <hint> Sets password
  • set_profile_name <first-name> <last-name> Sets profile name.
  • set_profile_photo <filename> Sets profile photo. Photo will be cropped to square
  • set_ttl <secret chat> Sets secret chat ttl. Client itself ignores ttl
  • set_username <name> Sets username.
  • show_license Prints contents of GPL license
  • stats For debug purpose
  • status_online Sets status as online
  • status_offline Sets status as offline
  • user_info <user> Prints info about user (id, last online, phone)
  • view_audio <msg-id> Downloads file to downloads dirs. Then tries to open it with system default action
  • view_document <msg-id> Downloads file to downloads dirs. Then tries to open it with system default action
  • view_document_thumb <msg-id> Downloads file to downloads dirs. Then tries to open it with system default action
  • view_file <msg-id> Downloads file to downloads dirs. Then tries to open it with system default action
  • view_file_thumb <msg-id> Downloads file to downloads dirs. Then tries to open it with system default action
  • view_photo <msg-id> Downloads file to downloads dirs. Then tries to open it with system default action
  • view_video <msg-id> Downloads file to downloads dirs. Then tries to open it with system default action
  • view_video_thumb <msg-id> Downloads file to downloads dirs. Then tries to open it with system default action
  • visualize_key <secret chat> Prints visualization of encryption key (first 16 bytes sha1 of it in fact)
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.