Follow

update: telegram-cli tg-cli

Setting up Telegram CLI on the Raspberry Pi

This tutorial was completed on a clean install of Raspbian but will also work on other Linux based operating systems. You will need to make a few changes to the tutorial but will work.

If you need to install Raspbian, then you can learn how to install a clean copy of Raspbian here.

1. Before we begin the process of installing the Telegram CLI (Command Line Interface) to our Raspberry Pi, we must first run an update and upgrade to ensure our Raspberry Pi is running the latest versions. Run the following two commands to update the Raspberry Pi.

sudo apt update sudo apt upgrade

2. With our Raspberry Pi now up to date, we can now install all the libraries we need to utilize the Telegram CLI. Run the following three commands on your Raspberry Pi to install all the required packages.

sudo apt install -y libreadline-dev libconfig-dev libssl-dev sudo apt install -y lua5.2 liblua5.2-dev sudo apt install -y libevent-dev libjansson-dev libpython-dev libssl1.0-dev make git

3. Now that we have all the libraries that we need to run the Telegram CLI we can proceed to clone the repository from GitHub. We need to use –recursive as we require Git to clone the remote repositories that the Telegram CLI GitHub references.

Run the following two commands on your Raspberry Pi to begin the cloning process.

cd ~ git clone --recursive github.com/kenorb-contrib/tg.g

4. To get the Telegram CLI to compile on our Raspberry Pi, we will first have to modify one of the source code files. Run the following command on your Raspberry Pi to begin editing the file.

nano ~/tg/tgl/mtproto-utils.c

5. Within this file we want to press CTRL + W then type in BN2ull and then press ENTER. That should take you to the following block of code.

static unsigned long long BN2ull (TGLC_bn *b) { if (sizeof (unsigned long) == 8) { return TGLC_bn_get_word (b); } else if (sizeof (unsigned long long) == 8) { assert (0); // As long as nobody ever uses this code, assume it is broken. unsigned long long tmp; /* Here be dragons, but it should be okay due to be64toh */ TGLC_bn_bn2bin (b, (unsigned char *) &tmp); return be64toh (tmp); } else { assert (0); } }

6. Within this block of code, we want to find and replace two occurrences of assert(0) as shown below.

Find both

assert(0);

Replace with

//assert(0);

You can now save the file by pressing CTRL + X then Y and then hitting ENTER.

7. Now that we have cloned the Telegram CLI to our Raspberry Pi and made changes to the source code, we will now need to run the configuration script and compile it.

To do this we can simply run the following three commands on our Raspberry Pi, the first changes the directory to the Telegram directory, the second configures the Telegram CLI for compiling, and finally, the make command compiles it.

cd ~/tg ./configure make

source: pimylifeup.com/raspberry-pi-te

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.