telegram(1)

NAME
telegram - Command-line interface for http://telegram.org. Uses readline interface.

SYNOPSIS
telegram [-hvNRfBEwW] [-k public-key] [-l log-level] [-L log-file] [-c config-file] [-p prefix] [-s lua-script]

DESCRIPTION
telegram is a CLI for telegram (http://telegram.org) with an embedded lua interpreter.

Documentation for Telegram API is available here: http://core.telegram.org/api

Documentation for MTproto protocol is available here: http://core.telegram.org/mtproto

OPTIONS

-h  prints a help message.

-u username
    specify username.

-k public-key
    specify server public key. By default public key is stored in the same folder named tg-server.pub or in /etc/telegram/server.pub, if it's not, specify where to find it:

-v  verbose.

-l [1-3]
    log level.

-L log-file
    log net file.

-N  message num mode.

-c config-file
    specify config file.

-p prefix
    specify prefix.

-R  register mode.

-f  sync from start.

-B  enable binlog.

-E  disable auto accept

-w  allow weak random

-s  specify lua script. Refer to the SCRIPT section for more information about scripting.

-W  wait dialog list

All those options can be set automatically using the config file (~/.telegram/config). You can refer to the config.sample file that comes with the source. Example: log_level = 0;

msg_num = TRUE;

COMMANDS
Client support TAB completion and command history. Peer refers to the name of the contact or dialog and can be accessed by TAB completion. For user contacts peer name is Name <underscore> Lastname with all spaces changed to underscores. For chats it is it's title with all spaces changed to underscores For encrypted chats it is <Exсlamation mark> <underscore> Name <underscore> Lastname with all spaces changed to underscores. If two or more peers have same name, <sharp>number is appended to the name. (for example A_B, A_B#1, A_B#2 and so on) You can see message numbers (msg-seqno) starting client with -N The default download dir is ~/.telegram/downloads. The download dir can be set in the main.c line 68 #define DOWNLOADS_DIRECTORY "downloads"

  SUPPORTED COMMANDS

Messaging

    •   msg <peer> Text - sends message to this peer

    •   fwd <user> <msg-seqno> forward message to user.

    •   chat_with_peer <peer> starts one on one chat session with this peer. /exit or /quit to end this mode. /history to show history and /read to mark as read the messages.

    •   add_contact <phone_number> <first_name> <last_name> tries to add contact to contact-list by phone

    •   rename_contact <user> <first-name> <last-name> tries to rename contact. If you have another device it will be a fight

    •   mark_read <peer> mark read all received messages with peer

    •   delete_msg <msg-seqno> remove a message

    •   status_online/status_offline appear online to others or not

    •   fwd <peer> <msg-seqno> forward a message to the peer specified

Multimedia

    •   send_photo <peer> <photo-file-name> sends photo to peer

    •   send_video <peer> <video-file-name> sends video to peer

    •   send_text <peer> <text-file-name> sends text file as plain messages

    •   load_photo/load_video/load_video_thumb/load_document/load_document_thumb/load_audio <msg-seqno> loads photo/video to download dir

    •   view_photo/view_video/view_video_thumbnail/view_document/view_document_thumb/view_audio <msg-seqno> loads photo/video to download dir and starts system default viewer (xdg-open on some system)
Group chat options

    •   chat_info <chat> prints info about chat

    •   chat_add_user <chat> <user> add user to chat

    •   chat_del_user <chat> <user> remove user from chat

    •   rename_chat <chat> <new-name>

    •   creacte_group_chat <user> <chat-topic> creates a groupchat with user, use char_add_user to add more users
Search

    •   search <peer> pattern - searches pattern in messages with peer

    •   global_search pattern - searches pattern in all messages
Secret chat

    •   create_secret_chat <user> creates secret chat with this user

    •   visualize_key <secret_chat> prints visualization of encryption key. You should compare it to your partner's one
Stats and various info

    •   user_info <user> prints info about user

    •   history <peer> [limit] prints history (and marks it as read). Default limit = 40

    •   dialog_list prints info about your dialogs

    •   contact_list prints info about users in your contact list

    •   suggested_contact prints info about contacts, you have max common friends

    •   stats just for debugging

    •   show_license prints contents of GPLv2

    •   help prints a help page
Options

    •   set <param> <param-value> Possible <param> values are:

        •   debug_verbosity - just as it sounds. Debug verbosity

        •   log_level - level of logging of new events. Lower is less verbose:

                •   Level 1: prints info about read messages

                •   Level 2: prints line, when somebody is typing in chat

                •   Level 3: prints line, when somebody changes online status

        •   msg_num - enables/disables numeration of messages

        •   alert - enables/disables alert sound notifications

    •   quit/safe_quit exit the program

SCRIPTS
You can extend the program by writting a lua script. An example script come with the source (test.lua). The callbacks available are:

•   on_msg_receive (msg)

•   on_our_id (id)

•   on_secret_chat_created (peer)

•   on_user_update (user)

•   on_chat_update (user)

•   on_get_difference_end ()

•   on_binlog_replay_end () To get more info about the parameters of those functions you can use the vardump() function in the test.lua.

ERRORS AND TROUBLESHOOTING
Report or check the Github issues (https://github.com/vysheng/tg/issues)

SEE ALSO
lua(1) xdg-open(1)

AUTHOR
vysheng (https://github.com/vysheng)

Big thanks for the help of all the people contributing on Github.