- Python 3
- Django 3.0+ as backend framework
- PostgreSQL for database
Requires python 3.12+
create a python virtual environment for project
Install dependency package from Ubuntu repository
sudo apt install python3-pip python3-dev libpq-dev postgresql postgresql-contrib
Create a database name
karaka
in PostgreSQL. To ease development, we connect PostgreSQL via Unix socket. This method let you access database without specifying username and password in project's config.sudo -u postgres createuser --superuser $USER sudo -u postgres createdb karaka --owner $USER
Install Poetry . We use it to manage Python dependencies for this project.
Create a Python virtual environment for this project. There are many tools for this. You can also use Poetry (but please not use Pipenv).
Go to the source folder, activate the virtual environment.
(venv)$ poetry install --no-root
to install Python packages.
Run:
./runserver.py
Register a Telegram bot to get token.
Add to .secrets.toml file. Example
[default]
TELEGRAM_TOKEN = 'TOKEN_THAT_TELEGRAM_GAVE_YOU'
API_USERS = [
['abc', '123456']
]
pybabel extract alarmbot/*.py -o locales/karaka.pot pybabel compile -d locales -l vi -D karaka
POST /users/
{
'username': 'someone',
'first_name': '',
'last_name': '',
'language_code': 'vi'
}
with username
being Telegram username.
POST /users/[username]/message
{
'message': 'Your farm is on fire!'
}