/quote - Get random quote from our database
/who - BlencongBot short intro
-
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:
-
Make sure you have Python on your system.
-
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.
-
Configure your virtualenvwrapper as described in their docs.
-
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. -
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
-
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:
-
Install pyenv and its pyenv-virtualenv plugin. Configure them as written in their docs.
-
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
-
Activate the virtual environment you've just created.
pyenv activate name_of_your_virtualenv
-
-
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 runpip freeze > requirements.txt
. For Linux users, if you have a problem installing the dependencies (PyYaml in particular), install the packagepython3-dev
orpython3-devel
first. -
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
. -
Run the app
python manage.py runserver # or ./manage.py runserver
-
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.