Bot that easily converts WhatsApp stickers to Telegram.
Try it » (not running anymore 🙁)
Report Bug
·
Leia em Português
Many people who migrate to Telegram, despite the huge amount of resources compared to WhatsApp, miss some stickers that are present on WhatsApp. While it's possible to create your own sticker pack on Telegram, doing so directly with WhatsApp stickers is not. With that in mind, I developed this solution that, in a simple way, allows the user to automatically create a package on Telegram with their WhatsApp stickers. As an additional feature, the created package is legitimately "owned" by the user and can be managed normally, including through the @Stickers Bot.
This project was developed only for learning. As the last bot developed by me used Node.js, I decided to use Python this time.
During development, I encountered problems such as ensuring that the bot continues to respond to messages while creating the package for a user, which was solved using multithreading with Python's concurrent.futures.ThreadPoolExecutor
.
Deploy the project was also a challenge, since Heroku has extremely peculiar ways of working.
This project uses Python as programming language, PostgreSQL as database and are free hosted on Heroku. It also uses the following resources.
- Telegram Bot API
- python-telegram-bot
- WebWhatsAPI (adapted)
To get a local copy up and running follow these simple steps.
-
Make sure you have Python ≥ 3.7 and pip.
-
You can create a new virtual environment, but it's optional
$ python3 -m venv whatsgram
$ source tutorial-env/bin/activate # Unix
$ tutorial-env\Scripts\activate.bat # Windows
Beginners tip: you'll see shell commands like this: (whatsgram) $ something
. In this case, type just something
in your Terminal. (whatsgram)
indicates the active virtual environment and $
indicates "input".
- Install dependencies
(whatsgram) $ pip install -r requirements.txt
-
Create your Telegram Bot with @BotFather and get your token.
- Clone the WhatsGram-Stickers and enter the directoy
(whatsgram) $ git clone https://github.com/hellmrf/WhatsGram-Stickers.git
(whatsgram) $ cd WhatsGram-Stickers
- Create a
credentials
folder with two files:database.ini
andTelegramApiKey.txt
that contain your Telegram Bot token:
(whatsgram) $ mkdir credentials && cd credentials
(whatsgram) $ touch database.ini
(whatsgram) $ echo "TELEGRAM_TOKEN" > TelegramApiKey.txt
If using Windows, use Explorer and Notepad (be sure to save database.ini as "All files", not "Text file (*.txt)").
database.ini
will have the following content (update to match your environment):
[postgresql]
host=localhost
database=whatsgram
user=postgres
password=postgres
- Create the necessary tables
(whatsgram) $ python whatsgramstickers/migrate.py
Just run:
(whatsgram) $ python whatsgramstickers/main.py
For the first run, you'll need to scan the QR Code on WhatsApp Web. You have 2 choices.
When the bot try to load to Whatsapp and fail, it'll take a screenshot of the browser and save to whatsgramstickers/scrsht.png
. Just open and scan!
Sometimes the first method takes an useless screenshot (just the spinner, for example). In this case...
Open whatsgramstickers/main.py
and, on line 14, set headless=False
and run once.
Chrome will open WhatsApp Web.
Log in as a normal user (make sure "keep me connected" are checked).
Go back to main.py
and set headless=True
back.
The main limitations are:
- Mobile device must be always connected to the internet.
- Stickers are uploaded in only one thread (at most two, one per user), which makes this process extremely time-consuming (see issue #7).
- Although the bot delete the messages when a new command are received, the stickers downloaded by mobile device continue eating space.
The bot doesn't respond to WhatsApp until it finishes generating a package(fixed)
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Heliton Martins - @hellmrf - helitonmrf@gmail.com
Project Link: https://github.com/hellmrf/WhatsGram-Stickers