[Windows] How to install TDL (Javascript tool for Telegram userbots and clients)

in #node6 years ago (edited)

Introduction

TDLib is a fully functional Telegram client which takes care of all networking, local storage and data consistency details. (source)

TDL is a Node.js wrapper for TDLib (Telegram Database library). (source)

Instructions for installation

The official instructions are here, but I tried to follow them and I had to do many more things to make everything work. I'll document the things I did differently so that I can do them again in the future without as many hiccups.


Image source

Installing TDLib dependencies

1. Download and install Microsoft Visual Studio 2015 or later

I tried to install MVS 2015 and it worked (but I didn't use it), but it turns out it doesn't come with C++ by default for some reason. If you want to install MVS2015 for the C++, make sure not to install the default version but click Custom, then check the right options.

However, Microsoft doesn't recommend installing MVS2015 for compiling but MVS2017. I think it's a bit bigger, but the installation ran much more smoothly than MVS2015. After installing MVS2017, you have to wait for the next window to appear. Follow the instructions here. This gif was useful:

2. Download and install gperf. Add the path to gperf.exe to the PATH environment variable.

This one was pretty straight-forward. Just go here, download it, and install it.

Add to path
Go to Computer, right click, Properties, in the left panel, there is "Advanced system settings" or something like that. In there, pick "environment variables", click on Path, edit, New and paste the address to gperf. In my case, it was C:\Program Files (x86)\GnuWin32\bin

3. Install vcpkg.

This one was easy but it took me a long time because my internet was breaking down. I followed the instructions here. Basically, it's like this:

cd directory/of/preference
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
.\vcpkg.exe install openssl:x64-windows openssl:x86-windows zlib:x64-windows zlib:x86-windows

The last line is in order to install some TDLib dependencies. Turns out vcpkg is just an installer.

4. Download and install CMake; choose "Add CMake to the system PATH" option while installing.

This one is also straight-forward. Just go here, download the "Windows win64-x64 Installer". I won't link it because versions change.

5. Install node-gyp

This one was not explained or even mentioned in the TDLib docs, but is necessary. I tried to install TDLib without it and was met with an error. I didn't copy the error, but it was basically a conditional statement saying that if there is no node-gyp, "blank" (nothing to be done), else, "blank". I had to go to node-gyp and follow the instructions.

I tried to install node-gyp without following the instructions and it ran, but I couldn't install TDLib, so I went back to the instructions and installed python 2.7.8. There, I also read that it's an option to get the "windows-build-tools". Please, read this the next time you're installing this package, because it might save you 4 hours of stumbling in the dark.

After installing MVS2017 with C++, then Python 2.7, open cmd and run:

npm config set python python2.7
npm config set msvs_version 2017
npm install -g node-gyp

Optional step: Build TDLib

I think that you're ready to install the npm package for the Javascript tool, but if you also want to install Telegram's TDLib and work it in C (I don't know C, so this is useless for me), clone https://github.com/tdlib/td.git in a directory. Go inside and run the following commands:

mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=<path to vcpkg>\scripts\buildsystems\vcpkg.cmake ..
cmake --build .

I did this step because, I dunno, I didn't think about it at first. Also, the instructions say to build the binary.

6. Install TDL

Now everything is ready. All that is left to do is go to the folder where you'll be installing the tdl node module, then do:

npm install --save tdl

Edit: I tried to run it and it didn't work. I opened an issue and it was solved. After installing the tdl module, you have to download these files and use the structure that Bannerets suggests:

.
├── index.js
├── tdjson.dll
└── zlib1.dll

Any questions you have, feel free to ask them in the comments section.

Sort:  

I upvoted your post.

Keep steeming for a better tomorrow.
@Acknowledgement - God Bless

Posted using https://Steeming.com condenser site.

Coin Marketplace

STEEM 0.25
TRX 0.11
JST 0.032
BTC 61618.64
ETH 3009.45
USDT 1.00
SBD 3.78