Git Product home page Git Product logo

gifbot's Introduction

GIFBot

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.

  1. A machine that can install Python 3.6 and FFmpeg, for example Linux (CentOS 7.4).
  2. Check your security settings and ensure the port 8443 is opened if you want to setup webhook with your bot.
  3. Own a bot and get the token from @BotFather.
  4. Follow the installation tips.

Installation

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 -.

yum -y install epel-release
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum -y install python36u
yum -y install python36u-pip

Check if it is installed successfully, run:

python3.6 -V
pip3.6 -V
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-devel

Check if it is installed successfully, run:

ffmpeg -version

3. Repository

git 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.txt

4. Configuration

1) Setup bot token

It 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.py

And your bot's locations on global_config/environment_config.py.

_base_dir = 'YOUR_ABSOLUTE_BOT_LOCATION'
_temp_dir = 'YOUR_ABSOLUTE_CACHE_LOCATION'

2) Setup webhook (optional)

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 ..

3) Setup entrance

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()

4) Run

python3 main_run_bot.py

Quick Installation

Install 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.sh

Questions

To activate and deactivate the vitural environment, run:

# activate
source .env/bin/activate

# deactivate
deactivate

License

This repo has been licnesed by MIT.

gifbot's People

Contributors

ryanfwy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.