|Daniele Tricoli 3403b94e76||2 months ago|
|docs||3 months ago|
|extra||4 months ago|
|src/poetrybot||3 months ago|
|tests||3 months ago|
|.dockerignore||4 months ago|
|.drone.yml||5 months ago|
|.editorconfig||5 months ago|
|.flake8||5 months ago|
|.gitignore||4 months ago|
|Dockerfile||3 months ago|
|LICENSE||4 months ago|
|README.rst||3 months ago|
|poetry.lock||2 months ago|
|pyproject.toml||2 months ago|
poetrybot is a Telegram bot to quote poems between friends. It's written in Python and it is released under the EUPL 1.2 license.
Friends are defined by an allow list in which every account have to be in order to to use the bot. The management of the bot is provided by a REST API defined in the subpackage
Create your bot using Telegram @BotFather.
Install (preferably inside a virtualenv) the bot using:
pip install poetrybot
The bot uses environment variables as configuration, you have to export the following before starting it:
export AUTH_TOKEN=<my secret auth token> export DATABASE_URL=sqlite:////absolute/path/to/poetrybot.db export TELEGRAM_TOKEN=<telegram bot API key>
AUTH_TOKENis used to authenticate to the REST API used to manage the bot. Full specification is in the
docs/openapi.ymlfile. Just create a long enough random string, for example using
pwgen -sy 50.
Launch the bot:
To use the REST API install a WSGI HTTP Server, for example gunicorn, and then:
Use the REST API to insert allowed friends, poets and poems. The fastest way to look at the API is to load the API specification into https://editor.swagger.io
An alternative is to clone the repository and use the provided
To use the bot you only have to use the
/quote command. The bot can be added to one or more channels but it's not required. But remember that only friends in allow list will be able to interact with the bot.
/quote command used without parameters will make the bot to quote a random poem, but optionally the author and the argument can be specified:
/quotereturns a random poem;
/quote AUTHORreturns a random poem by
AUTHORis the name or part of the name of the poet case insensitive:
/quote Giovanni Pascoli /quote pascoli /quote ascol
will return a random poem by Giovanni Pascoli, if you don't have another poet with ascol inside the name;
/quote AUTHOR about ARGUMENTreturns a random poem by
AUTHOR, case insensitive and can be part of a word.
aboutis, instead, case sensitive;
/quote about ARGUMENTreturns a random poem about