Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
How to run CodeX Bot Core
This article is about building CodeX Bot core for applications development. Throughout this guide, we build an application that can provide weather forecast for different periods of time.
For simplicity, we use our modern SDK for Python. We also provide instructions how to run your own production-ready CodeX Bot server.
Install necessary tools
- Python v. 3.5.3 can be downloaded by the link (https://www.python.org/downloads/release/python-353/). Just follow installation instructions. You can use newer versions if you need.
- MongoDB (https://www.mongodb.com). Useful hint – you can run Mongo with Docker. Just follow the instructions in the next section.
- Install virtual environment for Python
apt-get install virtualenv или pip install virtualenv
- Initialize virtual environment with
virtualenv venv -p python3.
You can skip this paragraph if you do not need to run MongoDB or RabbitMQ in Docker.
- Create working directory
docker run -v mongo:/data/db -p 27017:27017 -d mongo
docker run -d --hostname my-rabbit --name some-rabbit -p 5672:5672 -p 5671:5671 -p 8080:15672 rabbitmq:3
- Copy our CodeX Bot core with
git clone https://github.com/codex-team/codex.bot.git core
- cd core
- Activate virtual environment
- Install necessary packages
pip install -r requirements.txt
- If you don't have public IP address, you can use reverse-proxy. Download Ngrok (https://ngrok.com/download)
- In separate terminal:
./ngrok http 1337
- Move configuration sample file to a new config
cp core/codexbot/globalcfg.py.sample core/codexbot/globalcfg.py
- Change default URL in core/codexbot/globalcfg.py to that from ngrok's HTTPS section. Don't forget to add https:// before.
- Create your own bot with https://telegram.me/BotFather (https://core.telegram.org/bots#6-botfather)
- Move Telegram configuration sample file to a new config
cp core/codexbot/services/telegram/config.py.sample core/codexbot/services/telegram/config.py
- Input API TOKEN from BotFather to the telegram/config.py
Now, if you did all right, the CodeX Bot core will be running. Now, it's time to make your first CodeX Bot Application.