User Tools

Site Tools


linux:telegram

This is an old revision of the document!


Installing telegram to send notification messages

Intro

If you look on internet, you will found thousands of recipes like this one: install telegram in order to send notification messages from one computer directly to your phone.

My goal with this recipe is to create a telegram_msg command that just send a text message, nothing more.

Although it might seem a simple goal, you will discover that it is not a simple one: the Telegram command line application doesn't have a “send message” combination of arguments to do so. Moreover, a combination of pipes –to simulate a writing from the console– doesn't achieve the desired result because the telegram-cli program doesn't end: it keeps cyling over and over reading nothing from the pipe.

To put things worst, the first command you have to issue in ''telegram-cli'' is contact_list. It's a known error, at least on June, 2015.

Said that, the only approximation to my goal I've seen so far today is:

  • Run telegram-cli as a daemon, and when it starts, issue a contact_list command the first time
  • After that, send the command through netcat (nc) command

Step 1: install necesary packages

$ sudo apt-get install libreadline-dev libconfig-dev libssl-dev lua5.2 liblua5.2-dev 
$ sudo apt-get install libevent-1.4-2 libevent1-dev
$ sudo apt-get install libpython3.4 libpython3.4-dev 
$ sudo apt-get install libjansson4 libjansson-dev

Step 2: download the project

It is not compulsory to have git installed in the destination machine. You can have git in another machine and use it to download the project:

git clone https://github.com/vysheng/tg.git

The project will appear in a directory called “tg”.

Afterwards you can move the project to the destination machine.

<WRAP center round important 60%> Up to date (01/07/2015), this current version does not work. I've downloaded version 1.0.5.1 instead, which works correctly. </WRAP>

Step 3: configure and build the project

Nothing special here. Go to the directory where you have downloaded the project and:

$ ./configure
$ make 

Step 4: a basic test

Make a simple confirmation that the program is working. The program is called telegram-cli and it's under the bin directory. Go there, and execute:

$ ./telegram-cli -k ../tg-server.pub

Something similar to this will appear:

rluna@gamora:~/tg-1.0.5.1/bin$ ./telegram-cli ../tg-server.pub -k ../tg-server.pub 
Telegram-cli version 1.0.5, Copyright (C) 2013-2014 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.
Telephone number (with '+' sign): 

You have to provide the telephone number of this account –normally your telephone number– but with your national prefix.

Then the sms will be requested, so it is advisable to have this phone near when doing this.

You can issue a contact_list command to check thet that this client is working:

> contact_list
....
....

Step 5: install the client

I've opted for manually install the client. I've copied the telegram-cli program under /usr/local/bin and the public key of the server under /etc, with very restricted permissions for reading.

sudo cp telegram-cli /usr/local/bin
sudo cp tg-server.pub /etc
sudo chmod g=r,o=r,u=r /etc/tg-server.pub
linux/telegram.1435780295.txt.gz · Last modified: 2022/12/02 22:02 (external edit)