Connecting WeChat and Telegram with ehForwarderBot | A Data Scientist's Playground (2024)

1. Why

WeChat is getting more and more bulky. The newest version on iOS is now of 230MBsize. For people who only use WeChat to “chat”, many of the features are notquite useful, such as Moments (朋友圈), Shake (摇一摇), Top Stories (看一看),Message in a Bottle (漂流瓶), etc.. I am one of these people. In addition, inits major upgrade to version 7.0.x, the interface has been re-designed to matchthe popular minimal flat design trend. The color is too bright for me. These tworeasons drove me to look for a substitute for WeChat, that has nothing but thebasic chat function, supports dark UI theme, and runs smoothly on iOS.

I noticed Telegram as it is exactly what I wanted: simple, supports dark theme,and smooth. In fact, it is so smooth that you won’t even notice it’s athird-party app instead of Apple’s own. It would be nice if I can send andreceive WeChat messages using Telegram. Fortunately, the ehForwarderBotproject works like a charm. It utilizes Web WeChat functionals. You can create arobot, authorize it with your Telegram’s token, and login to your WeChat byscanning a QR code. Then the bot will forward everything you receive to yourTelegram, in your conversion with your bot, and whatever you reply to the botwill be forwarded to WeChat, back to your friends.

The bot needs to be hosted somewhere. If we are going to use a machine of ourown, it has to - remain powered on at all times. A messaging forwarding servicethat works intermittently is no good service. Therefore I considered usingGoogle’s cloud engine. Upon registration you will get $300 credit for use, whichwill remain valid for one year or until it is exhausted, whichever is earlier.

After all this reasoning and introduction, let’s now move on to the “how to”part.

2. How

2.1 Configure Telegram
  1. search for “get_id_bot”, and get your Telegram ID

  2. search for “botfather” in Telegram

  3. type in /newbot

  4. follow the prompts to name your new bot

  5. follow the prompts to set a username for your bot

  6. you will be given a token to access the HTTP API; keep it safe

  7. send /setprivacy, and choose “disable” for your bot

  8. send /setjoingroups, and choose “enable” for your bot

  9. send /setcommands, and send the following:

    link - 将会话绑定到

    chat - 生成会话头

    recog - 回复语音消息以进行识别

    extra - 获取更多功能

2.2 Set up the Server

Register at Google Cloud. Click on “get started forfree”, add necessary info, and start your free trial. Select “compute engine”,choose “enable billing”, and create a VM instance. I personally refer the mostbasic configuration - no powerful CPU, no GPU, no big hard drive. The monthlycost is cheaper than a cup of coffee!

The created instance can be accessed via SSH (please do not try to access the IPin the pic as I have deleted it now).

Connecting WeChat and Telegram with ehForwarderBot | A Data Scientist's Playground (2)

After opening a cloud console, some dependencies need to be installed. We willuse a Docker version of ehforwarderbot, which is relatively stable than thecurrent version on Github.

sudo apt-get updatesudo apt-get -y install apt-transport-https ca-certificates curlcurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - # should print "OK"sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"sudo apt-get updatesudo apt-get -y install docker-cesudo usermod -a -G docker $USER ## log out after this step; simply close the console and reopendocker pull royx/docker-efb

Next, we create a directory to hold data for efb:

mkdir efbcd efbtouch tgdata.db

Then create another file via vi config.py, and replace the token with the token you had in Section 2.1, and the admins as your Telegram ID, also obtained in Section 2.1.

master_channel = 'plugins.eh_telegram_master', 'TelegramChannel'slave_channels = [('plugins.eh_WeChat_slave', 'WeChatChannel')]eh_telegram_master = { "token": "12345678:QWFPGJLUYarstdheioZXCVBKM", "admins": [13456782]}
2.3 Run the Bot

In your cloud console, type

docker run -d --restart=always --name=ehforwarderbot -v /efb/config.py:/opt/ehForwarderBot/config.py -v /efb/tgdata.db:/opt/ehForwarderBot/plugins/eh_telegram_master/tgdata.db royx/docker-efbdocker logs ehforwarderbot 

Scan the QR code using your WeChat’s scan function, and login. Now you candisable notifications of WeChat and only leave Telegram on!

2.4 When Things Go Wrong

There are times when WeChat increases its monitor for user accounts, and thosewhose account stay online for web WeChat might get forced to log off. In thesecases, my recommendation is to wait for a few hours or one day, and restart thebot. To restart, go to Google Cloud Computing, use SSH to connect to yourserver, stop and remove the current container first:

docker container stop ehforwarderbotdocker container rm ehforwarderbot

Next, just repeat the two steps in 2.3, and your bot will be happily running again!

3. Pros and Cons

3.1 Pros
  • Seamless messaging experience!
  • You won’t be limited by the number of devices. While WeChat only allows atmost one device other than your phone to be online, Telegram allows multipledevices to be online together. See TelegramDesktop.
  • Unlike WeChat, which is mostly used by the Chinese community, Telegram is usedby people all over the world. This means there is a huge collection ofstickers that you can use. You can even find Lord Voldemort!

Connecting WeChat and Telegram with ehForwarderBot | A Data Scientist's Playground (3)

* Telegram is open source, and all source codes can be found on GitHub. Compared to a blackbox, more transparency is always preferred.* While WeChat’s interface is relatively fixed, and you can only change the chat background, Telegram gives you the options to customize the text size, the color theme, in addition to the chat background.

3.2 Cons

The are a few caveats that need to be kept in mind while using ehforwarderbot.

  • You won’t receive notifications for WeChat video or audio calls if WeChat isnot running in the background.
  • You won’t be able to send or receive red packets; neither will you be able touse WeChat’s stickers; most of the time, emoji and Telegram’s stickers canprovide good substitutes.
  • All conversations will be forwarded to the main chat with your bot, which willsometimes cause confusions
    • the solution to this is to create new group chats for every one. Forexample, if I want to single out the chat with John Doe, whose WeChat nameis JohnDoe, I first use Telegram’s “create group” to make a group,inviting my bot to join, and name the group John Doe. Next I’ll type/link JohnDoe, and choose to link the slave chat to the new group I justset up. Now conversations with John Doe will be forwarded to this separatechat.
  • There could be delays as our messages traveled all the way to Google’s cloudservice, and then back to us, but the delay is usually within 2 seconds, whichshould not be a big problem.
Connecting WeChat and Telegram with ehForwarderBot | A Data Scientist's Playground (2024)

References

Top Articles
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 5995

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.