Skip to main content

poetrybot is a Telegram bot to quote poems between friends.

Project description

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 poetrybot.web.

Installation

  1. Create your bot using Telegram @BotFather.

  2. Install (preferably inside a virtualenv) the bot using:

    pip install poetrybot
  3. 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_TOKEN is used to authenticate to the REST API used to manage the bot. Full specification is in the docs/openapi.yml file. Just create a long enough random string, for example using pwgen -sy 50.

  4. Launch the bot:

    poetrybot
  5. To use the REST API install a WSGI HTTP Server, for example gunicorn, and then:

    gunicorn poetrybot.web.wsgi:app
  6. 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 Dockerfile.

Usage

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.

The /quote command used without parameters will make the bot to quote a random poem, but optionally the author and the argument can be specified:

  • /quote returns a random poem;

  • /quote AUTHOR returns a random poem by AUTHOR.

    AUTHOR is 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 ARGUMENT returns a random poem by AUTHOR about ARGUMENT.

    ARGUMENT is, like AUTHOR, case insensitive and can be part of a word. about is, instead, case sensitive;

  • /quote about ARGUMENT returns a random poem about ARGUMENT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poetrybot-0.2.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

poetrybot-0.2.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file poetrybot-0.2.0.tar.gz.

File metadata

  • Download URL: poetrybot-0.2.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.1 Linux/6.1.0-3-amd64

File hashes

Hashes for poetrybot-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cfec4d2e9c43949ef7740031425434f8aac8a8c6bf02075dc964e067e8bb7534
MD5 0c0a840975f1a610479e1bea9e277809
BLAKE2b-256 7b270e151d0d9c9dc65538885cc6f6308a53bcc865f1fd04123540af8a6ec5b1

See more details on using hashes here.

File details

Details for the file poetrybot-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: poetrybot-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.1 Linux/6.1.0-3-amd64

File hashes

Hashes for poetrybot-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a11362cd28609a259a6e71662809b172b5d48c6c76983959e14033ca65ba5262
MD5 39b23a0ff7949c369ddcab1b2992ac20
BLAKE2b-256 d43144c823622a34f6d53bb6234ca383f706bc364c01c3e7245eccc0c6698d18

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page