Adds support for Telegram to Pidgin, Adium, Finch and other Libpurple based messengers.
Clone or download
BenWiederhake Stop using -Werror
We fixed this over a year ago, even before the current version (1.3.1) was published.
No idea why it never made it into master.  Sorry.
Latest commit f686f8a Jul 31, 2018
Permalink
Failed to load latest commit information.
AppStream AppStream: import translations from Transifex. Thanks to samant! Mar 13, 2017
imgs Better icons Nov 24, 2014
po Import translations from Transifex. Thanks to eischmann, raven, savant! Mar 13, 2017
rpm Increase version to 1.3.1 Apr 9, 2017
telegram-adium Increase version to 1.3.1 Apr 9, 2017
test build: properly clean up Aug 8, 2016
tgl @ e1ac3fb Stop using -Werror Jul 31, 2018
.gitignore Fix gitignore patterns for *.mo Feb 18, 2016
.gitmodules Use correct repository Mar 23, 2016
.travis.yml Slim down combinations Jan 1, 2016
AUTHORS Update AUTHORS Nov 29, 2015
CHANGELOG.md Increase version to 1.3.1 Apr 9, 2017
COPYING Add COPYING file Oct 2, 2015
HACKING.BUILD.md Allow out-of-vcs builds Mar 23, 2016
HACKING.md Minor typos Aug 8, 2016
Makefile.in Silence warnings about bad .po files Apr 10, 2017
Makefile.mingw Compile tgp-info on Windows Sep 2, 2016
Makefile.tgl.mingw tgl Windows Makefile no longer needs scheme version Sep 2, 2016
README.md Replace outdated documentation by links May 11, 2018
autogen.sh Let autogen.sh take care of the .nsi Feb 18, 2016
commit.h.gen Allow out-of-vcs builds Mar 23, 2016
config.h.in Remove superfluous -lm flag. Oct 7, 2015
config.h.mingw Add proper copyright headers Dec 30, 2015
config.h.tgl.mingw Add proper copyright headers Dec 30, 2015
configure Increase version to 1.3.1 Apr 9, 2017
configure.ac Increase version to 1.3.1 Apr 9, 2017
gen-origtar Allow out-of-vcs builds Mar 23, 2016
install-sh Updated to use subdirectory. Fixed buffer overflow in date format Nov 12, 2014
m4_ax_check_openssl.m4 Fix compilation with openssl Dec 31, 2015
m4_ax_check_zlib.m4 Updated to use subdirectory. Fixed buffer overflow in date format Nov 12, 2014
m4_ax_pkg_config.m4 Build telegram-purple and libtgl without OpenSSL (skip when bisecting). Oct 4, 2015
msglog.c Improve logging of peer flags Dec 8, 2015
msglog.h Improve logging of peer flags Dec 8, 2015
telegram-base.c Merge branch 'master' into dev-1.3.0 Mar 20, 2016
telegram-base.h Update copyright strings Dec 5, 2015
telegram-purple.c Merge branch 'EionRobb-group-typing-notifications' into dev-1.4.0 Mar 13, 2017
telegram-purple.h Increase default file size download threshold Mar 13, 2017
telegram-purple.nsi Update nsi file to reflect changes in po/LINGUAS Apr 10, 2017
telegram-purple.nsi.awk Auto-generate .nsi via awk script Feb 18, 2016
telegram-purple.nsi.awk-in Auto-generate .nsi via awk script Feb 18, 2016
tg-server.tglpub Avoid the PEM issue. Oct 4, 2015
tgp-2prpl.c Fix clang warnings. Aug 1, 2016
tgp-2prpl.h Auto-load audio, video and animated messages up to 8mb Apr 2, 2016
tgp-blist.c Fix crash on duplicated peer name in peer tree Feb 11, 2017
tgp-blist.h Handle contacts added on different devices Jan 24, 2016
tgp-chat.c Merge branch 'EionRobb-group-typing-notifications' into dev-1.4.0 Mar 13, 2017
tgp-chat.h Merge branch 'EionRobb-group-typing-notifications' into dev-1.4.0 Mar 13, 2017
tgp-ft.c Cleanup and add a few notes Feb 7, 2016
tgp-ft.h Remove dead code and unused functions Nov 21, 2015
tgp-info.c Include pull request #302 by EionRobb Mar 2, 2017
tgp-info.h Display chat and channel icons, refactor image loading code Feb 10, 2016
tgp-msg.c Include autoloading for all types of documents and improve document c… Mar 13, 2017
tgp-msg.h Fix code style Jun 30, 2016
tgp-net.c Merge branch 'dev-1.2.3' into dev-1.3.0 Dec 19, 2015
tgp-net.h Remove dead code and unused functions Nov 21, 2015
tgp-request.c Emphasize that just the contact will be deleted, not the dialogue lis… Jan 25, 2016
tgp-request.h Support deleting contacts, handle deletions of chats and channels Jan 24, 2016
tgp-structs.c Support sending code tags and improve inline image handling Mar 27, 2016
tgp-structs.h Experimental support for channel history Mar 23, 2016
tgp-timers.c timer_alarm: Set fd to -1 to avoid warnings on tgl_timer_delete Dec 2, 2015
tgp-timers.h Rewritten to use libtgl Nov 11, 2014
tgp-utils.c Fix auto-joining chats Dec 18, 2015
tgp-utils.h Remove code duplication Nov 23, 2015

README.md

Telegram-Purple Unofficial (Beta)

Telegram-purple is a Libpurple protocol plugin that adds support for the Telegram messenger.

I keep getting many questions about this plugin in my E-mail, so I've created a telegram group chat for telegram-purple related discussions or questions.

Installation

If you are just interested in using the plugin you probably want to use one of the following binary distributions. Please note that I do not control most of those package sources and the version may lag behind.

If your platform is not supported or you want to contribute by testing or development, scroll down to "Building form Source".

OSX (Adium)

  1. Download and execute the [Telegram-Adium bundle] (https://github.com/majn/telegram-purple/releases/download/v1.3.0/telegram-adium-1.3.0.AdiumLibpurplePlugin.zip)
  2. Restart Adium

Windows

Eion Robb provides a binary for Windows users:

  1. Download and execute the setup from http://eion.robbmob.com/telegram/
  2. Restart Pidgin

Fedora (22, 23)

The package is available in the Fedora 22 and 23 testing repositories:

 dnf config-manager --set-enabled updates-testing
 dnf install purple-telegram

Arch Linux (AUR)

https://aur.archlinux.org/packages/telegram-purple/

Debian

You have to build it from source. For more information, see the dev-1.4.0 branch.

Building From Source

Below, you will find the instructions for how to build the libpurple protocol plugin from source.

1. Clone

This repository has submodules, so you need to clone recursively.

    git clone --recursive https://github.com/majn/telegram-purple
    cd telegram-purple

1b. Cloning if you're a packager

If you are unsure about whether you need this, then you are not a packager and don't have any use for this.

If you need an "orig-tarball", it can be generated by make dist. Note that this automatically generates an appropriate version number like 1.2.4-58-g8e3cebf. You can truncate the git suffix (-g8e3cebf). If the -58 part exists, it means that you're using a development version, which is probably not what you want. If you still want to package this, please leave the commit number (i.e., 58) intact, as this indicates that this version is in fact much further than just 1.2.4.

2. Fetch all dependencies

Fedora
    sudo dnf install gcc gettext libgcrypt-devel libwebp-devel libpurple-devel zlib-devel
Debian / Ubuntu

Please see the dev-1.4.0 branch.

OpenSUSE
    sudo zypper install gcc glib glib-devel libpurple libpurple-devel zlib-devel libwebp-devel

And the development files for gcrypt, probably gcrypt-devel or something. (FIXME)

3. Compile and install

If libwebp is not available, you can disable sticker support by calling ./configure --disable-libweb instead. Please note that this is usually not necessary.

    ./configure
    make
    sudo make install

Pulling Updates

This repository contains submodules, and a simple pull just won't be enough to update all the submodules’ files. Pull new changes with:

    git pull
    git submodule sync # just in case the configuration has changed 
    git submodule update --recursive

Usage

First Login

The username is your current phone number, including your full country prefix. For Germany, this would be '+49', resulting in a user name like '+49151123456'. Telegram will verify your phone number by sending you a code via SMS. You will be prompted for this code, once that happens.

Buddy List

Like in the official Telegram apps, the displayed buddy list consists of all active conversations.

Foreign Users

Foreign users, like for example people you only know through a group chat but never had any conversation with, will not be part of your buddy list by default. You can add those users to the buddy list by clicking on "Add contact..." in the users context menu.

Using secret chats

You can use Telegram secret chats with this plugin, they will show up as a new buddy with a '!' in front of the buddy name.

One caveat of secret chats in Telegram is that they can only have one endpoint, this is a limitation of the protocol. This means that if you create a secret chat in Pidgin you will not be able to use that chat on your phone. You will be asked whether to accept each secret chat, so you can always choose to accept the chat on a different device if you want. You can set a default behavior for dealing with secret chats (Accept or Decline) in the account settings, if you don't want that prompt to appear every time.

Self destructive messages will be ignored, since I don't know any way to delete them from the conversation and the history.

Confirming the key authenticity

Click on the buddy in the buddy list and click on "Show Info" to visualize the key fingerprint.

Initiate secret chats

To initiate a secret chat from Pidgin, click on a Buddy in the Buddy List and hit "Start Secret Chat"

Deleting secret chats

If you delete a secret chat from the buddy list, it will be terminated and no longer be usable.

Unicode Emojis for Pidgin

The Telegram phone applications for iOS and Android make use of standardized Unicode smileys (called Emojis). Pidgin does not display those smileys natively, but you can install a custom smiley theme like (https://github.com/stv0g/unicode-emoji) or (https://github.com/VxJasonxV/emoji-for-pidgin) and activate it under Settings > Themes > Smiley Theme.

Code-Tags

Since 1.3.0 it is possible to write messages in monospaced fonts using the markdown backtick syntax.

Example
``` if (true) {
    // do smth 
}```
Result
if (true) {
    // do smth
}

Building the Adium Plugin

Compiling with XCode is a little bit problematic, since it requires you to compile Adium first to get the necessary framework files. My advice is to just use the prebuilt bundle, but if you really want to do it, follow these steps:

  1. Get the Adium source, compile it with XCode and copy the build output into telegram-adium/Frameworks/Adium. It should contain at least Adium.framework, AdiumLibpurple.framework and AIUitilies.framework

  2. Open the Adium source code, go to ./Frameworks and copy libglib.framework and libpurple.framework into telegram-adium/Frameworks/Adium

  3. Build the tgl submodule and delete libtgl.so from libs/ (it should only contain libtgl.a)

  4. Install libwebp, libgcrypt and gnupg with homebrew:

    brew install webp brew install libgcrypt libgpg-error

  5. If you already downloaded libwebp/libgcrypt in previous builds make sure that the binaries are up-to-date

    brew update brew upgrade webp libgcrypt

  6. Install with homebrew and move it into the appropriate directory so that XCode can find them. Note that the versions might differ, use the one that is

    mkdir -p ./telegram-adium/Frameworks/Adium cp /usr/local/Cellar/webp/0.4.3/lib/libwebp.a ./telegram-adium/Frameworks cp /usr/local/Cellar/libgcrypt/1.6.4/lib/libgcrypt.20.dylib ./telegram-adium/Frameworks/Adium cp /usr/local/Cellar/libgpg-error/1.20_1/lib/libgpg-error.0.dylib ./telegram-adium/Frameworks/Adium

  7. Update the paths in the dylibs, to assure that the resulting binary will load them form within the bundle.

    cd ./telegram-adium/Frameworks/Adium install_name_tool -id "@loader_path/../Resources/libgcrypt.20.dylib" ./libgcrypt.20.dylib install_name_tool -id "@loader_path/../Resources/libgpg-error.0.dylib" ./libgpg-error.0.dylib install_name_tool -change "/usr/local/lib/libgpg-error.0.dylib" "@loader_path/../Resources/libgpg-error.0.dylib" ./libgcrypt.20.dylib

  8. Build the XCode-Project and execute the created bundle

Building the Debian Package

See https://github.com/majn/telegram-purple/tree/dev-1.4.0#building-the-debian-package

Discussion / Help

Custom pubkeys

As we want to avoid OpenSSL, it has become necessary to replace the PEM file format. This means that if you use a custom pubkey (which you really REALLY shouldn't be doing), you have to adapt, sorry.

We no longer ship tg-server.pub (old format), but instead tg-server.tglpub (new format). If you have a .pub and want to continue using telegram-purple, please use this (hopefully highly portable) tool: pem2bignum

You can also write your own conversion tool if you prefer. The format is really simple:

  1. e, the public exponent, encoded as big endian 32 bit fixed length (e.g. 0x00 01 00 01 for 65537)
  2. n_len, the length of n in bytes, encoded as big endian 32 bit fixed length (e.g. 0x00 00 01 00 for a 2048-bit = 256-byte key)
  3. n_raw, the raw modulus, encoded as big endian, using the previously indicated length (e.g. 0xC1 50 02 3E [248 bytes omitted] 21 79 25 1F in the case of telegram's public RSA key.)

If you are interested in developing a non-OpenSSL-licensed converter, look into insane-triangle-banana.

FAQ

  • I receive pictures in a chat, but they aren't showing up

    • A: Make sure that you don't have a plugin like "Conversation Colors" that strips HTML from messages and removes the pictures.
  • I receive RPC_CALL_FAIL_401: SESSION REVOKED

    • A: This basically means your session has been terminated but the program doesn't handle terminated sessions properly yet. You have to clean the ~/.purple/telegram-purple/$PHONENUMBER directory to fix this issue.

      For Arch Linux users that use Bitlbee you can find this directory in /var/lib/bitlbee/purple/telegram-purple/

Group chat

Telegram group chat for telegram-purple or libtgl related discussions or questions:

- https://goo.gl/VudXys

Submitting Bug Reports

IMPORTANT: if you report bugs PLEASE make sure to always include as much information as possible. This should always include at least the telegram-purple version and (if possible) commit, where you got telegram-purple from (Source build, package repository, etc.), the Pidgin version (if you use a different messenger please state that too!) and your OS Version.

If you describe some issue please be as precise as possible. Descriptions like "XY doesn't work" will not help me. Describe what you are doing what kind of issue you are experiencing: "If I click on X, Y happens, but instead I would expect Z to happen".

For error reports please include the application logs. To get Pidgin to print a log, start it from command line, specifying the -d option. ATTENTION: This log will contain personal information like your phone number, message content or contact or chat names. If you plan on uploading it somewhere public mask those entries in the log.

Bug reports regarding crashes should include a backtrace if possible, there is extended documentation available on how to get a backtrace for crashes

Empathy / libtelepathy

Empathy doesn't natively support libpurple plugins since its based on libtelepathy, but there is a compatibillity layer called telepathy-haze that can be used to execute libpurple plugins. This means that you can basically run this plugin thanks to telepathy-haze but you will usually get less features and worse usability compared to real libpurple clients. If you use Empathy (or anything else based on libtelepathy) I recommend telepathy-morse which is a connection manager written specifically for your messenger.

Authors

Telegram-Purple was written by:

- Matthias Jentsch <mtthsjntsch@gmail.com>
- Vitaly Valtman
- Ben Wiederhake <Ben.Wiederhake@gmail.com>
- Christopher Althaus <althaus.christopher@gmail.com>

Acknowledgements

This software is based on the library Libtgl, which was written by Vitaly Valtman mail@vysheng.ru and others, see (https://github.com/vysheng/tgl/)