Simple Telegram bot for language learning support.
lexibot
is a client/server application that provides functionality to read Telegram blogs while simultaniously learning all the foreign words used.
For now we consider only one foreign language: Japanese.
The client bot application will be a participant of a Telegram channel along with an administrator.
When the administrator shares some information with potential readers of the channel, the bot processes them and provides these features:
- List all the Japanese words in a message along with a clickable link to online dictionary for every word.
- Regularly write out a statistical report on what words are clicked the most in the channel during a set period of time.
-
Plan the implementation:
- Client bot application based on telegram API python wrapper.
- Database to store words and related information.
- A server which provides links to online dictionary and statistical reports to the client. API details here.
-
Set up local database and server.
-
Implement request processing and database entry updates on the server side.
-
Implement compilation of statistical reports from the database.
-
Provide a way to set up and deploy everything to AWS.
-
Implement bot client's features:
- channel message parsing;
- link creation;
- channel replies (links to online dictionary, statistical report on the most clickable words).
In order to try anything firstly install required python packages (we suggest using virtual environment):
pip install -r requirements.txt
Also prepare json configuration file with the following format:
{
"token": "<provide_your_token_here>",
"server": {
"ip": "<ip>",
"port": "<port>"
}
}
You will need a valid docker installation to run the database for the local server. If you want to configure the database manually, see TODO.
- Set server
ip
to 0.0.0.0 andport
to 80 in config file. - In order to prepare a database for lexibot server, execute
make run-local-db
- To run a local server, execute
make run-local-server CONFIG_PATH=<path_to_config_file>
- After you are done working with the local server, execute
make stop-local-db
to stop and destroy the database
python -m bot.main -cp <path_to_config_file>
Set additional -v
flag, if you want to see debugging logs.
Specify LANGUAGE=ru
(or en
) in the beggining of the command to use localization.
TODO
TODO
Make sure you have Sphinx package installed.
Execute make doc_html
and open docs/doc_build/html/index.html
in a browser.
ru
and en
locales are supported.
Run make l10n
to obtain required binary file, which cover existing translations.
To use modified translation run the following:
## Example for `ru`:
# extract strings to translate from the code
pybabel extract -o l10n/lexibot.pot <path_to_module1> <path_to_module2> ...
# init or update translation pot file
# init:
pybabel init -D lexibot -i l10n/lexibot.pot -l ru -d l10n
# update:
pybabel update -D lexibot -i l10n/lexibot.pot -l ru -d l10n
# then open l10n/ru/LC_MESSAGES/lexibot.po and update the translation here
# finally create binary file which will be used my the program
pybabel compile -D lexibot -i l10n/ru/LC_MESSAGES/lexibot.po -o l10n/ru/LC_MESSAGES/lexibot.mo