Here is the repo of @GIFDownloader_bot which help exporting GIF, Sticker and Sticker Set from Telegram to local.
To develop and run this bot, you may require the following basic environments.
- A machine that can install
Python 3.6andFFmpeg, for exampleLinux (CentOS 7.4). - Check your security settings and ensure the port
8443is opened if you want to setup webhook with your bot. - Own a bot and get the token from @BotFather.
- Follow the installation tips.
This guidance requires CentOS 7.4. If not, you can try translate them to your system commands.
Notice: before installation, don't forget to change to root user by calling sudo su -.
1. Python3
yum -y install epel-release
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum -y install python36u
yum -y install python36u-pipCheck if it is installed successfully, run:
python3.6 -V
pip3.6 -V2. FFmpeg
rpm –import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum -y install ffmpeg ffmpeg-develCheck if it is installed successfully, run:
ffmpeg -versiongit clone https://github.com/ryanfwy/gifbot.git
It is highly recommend you to install python requirements.txt under the virtual environment.
cd gifbot
python3 -m venv .env
source .env/bin/activate
pip3 install -r requirements.txtIt requires a file global_config/protected_config.py to place your bot token.
touch global_config/protected_config.py
echo "_telegrambot_token = 'YOUR_TOKEN'" > global_config/protected_config.pyAnd your bot's locations on global_config/environment_config.py.
_base_dir = 'YOUR_ABSOLUTE_BOT_LOCATION'
_temp_dir = 'YOUR_ABSOLUTE_CACHE_LOCATION'If you want to run your bot using webhook, it requires a SSL certificate and your own domain.
mkdir .openssl && cd .openssl
openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.key -x509 -days 3650 -out cert.pem && cd ..If you want to run your bot using webhook, you should change YOUR_DOMAIN on main_run_bot.py.
import os
from global_config.environment_config import _base_dir
from telegram_bot.bot_executor import BotExecutor
if __name__ == '__main__':
cert_path = os.path.join(_base_dir, '.openssl/cert.pem')
key_path = os.path.join(_base_dir, '.openssl/private.key')
webhook_url = 'https://YOUR_DOMAIN:8443/gifbot'
BotExecutor(cert_path=cert_path,
key_path=key_path,
webhook_url=webhook_url).execute()Otherwise, if you just simply debug and test the code, overwrite main_run_bot.py like this:
from telegram_bot.bot_executor import BotExecutor
if __name__ == '__main__':
BotExecutor().execute()python3 main_run_bot.pyInstall on this way WON'T setup all the steps metioned above, such as webhook and bot entrance, but it can help you to install some basic environments quickly.
Notice: CentOS 7.4 required.
bash install_centos.shTo activate and deactivate the vitural environment, run:
# activate
source .env/bin/activate
# deactivate
deactivateThis repo has been licnesed by MIT.