Skip to content

elsadarwin/blencongbot

 
 

Repository files navigation

User Guide

Command List

/quote - Get random quote from our database

/who - BlencongBot short intro

Development Guide

How to set up your machine

  1. Setup your Python virtual environment. There are two ways to do this. One is via virtualenvwrapper and the other one is via pyenv. If you decided to use virtualenvwrapper, here are the steps you may follow:

    1. Make sure you have Python on your system.

    2. Install virtualenvwrapper to make it easier working with virtualenv. We need virtualenv because Blencongbot uses Python 3, whereas most systems still use Python 2. Virtualenv makes it easy to manage different Python versions along with their libraries. There are many ways to install virtualenvwrapper. One of the easiest ways is to use Pip.

      pip install virtualenvwrapper

      Pip is the default package manager for Python. It should already be installed if you have Python >= 2.7.9 or Python >= 3.4 on your system.

    3. Configure your virtualenvwrapper as described in their docs.

    4. Make sure you have Python 3 installed on your system. This can be done in many ways. For instance, in OSX, you may install it with Homebrew

      brew install python3

      UPDATE: Homebrew's python3 is already updated to Python 3.5. Since we're using Python 3.4, you might want to use pyenv instead.

    5. Create a Python 3 virtual environment and clone this repository.

      mkvirtualenv -p /path/to/python3/binary name_of_your_virtualenv
      git clone git@github.com:blencong/blencongbot.git /path/to/your/blencongbot/project/directory
    6. Activate the virtual environment you've just created.

      workon name_of_your_virtualenv

    If you'd like to use pyenv instead, here are the steps you may follow:

    1. Install pyenv and its pyenv-virtualenv plugin. Configure them as written in their docs.

    2. Install Python 3.4 with pyenv, create virtual environment, and clone this repository.

      pyenv install 3.4.3
      pyenv virtualenv 3.4.3 name_of_your_virtualenv
      git clone git@github.com:blencong/blencongbot.git /path/to/your/blencongbot/project/directory
    3. Activate the virtual environment you've just created.

      pyenv activate name_of_your_virtualenv
  2. Navigate to the directory where you've cloned this repo and install all its dependencies.

    cd /path/to/your/blencongbot/project/directory
    pip install -r requirements.txt

    Dependencies are all listed in requirements.txt. To re-generate this file (after you've installed new packages), simply run pip freeze > requirements.txt. For Linux users, if you have a problem installing the dependencies (PyYaml in particular), install the package python3-dev or python3-devel first.

  3. Create .env file under the project root directory. It contains the configuration variables for the application. Sample .env file can be found in .env.example.

  4. Run the app

    python manage.py runserver
    # or
    ./manage.py runserver
  5. The app is now running! Try to play around with it by simulating a webhook request. For instance, try this:

    curl --data '{"update_id": 12345,"message":{"text":"/who","chat":{"id":-12345},"message_id":1}}' --header "Content-Type: application/json" http://127.0.0.1:5000/<YOUR TELEGRAM BOT TOKEN IN .ENV>

    You should get an OK response.

    As you can see, the url endpoint is determined by the TELEGRAM_BOT_TOKEN config variable. This is actually recommended by Telegram.

About

Telegram Bot for Blencong Group

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%