|Petra Lamborn b5181efd7c Let's not have that word||1 year ago|
|.gitignore||2 years ago|
|Readme.md||2 years ago|
|bot.py||2 years ago|
|wl.txt||1 year ago|
(”Robot for an Esperanto dictionary”)
This is my first bot for either Twitter or Mastodon, and my first python program in a long time. It’s not perfect, but it works.
The bot takes its wordlist from the utf-8 version of the above-linked dictionary, editing out the section headings and other elements that do not fit the pattern “(English) = (Esperanto).”, e.g:
Bed (river) = kuŝujo.
A handful of words I’d rather not have appear are removed, along with the first entry which for posterity reads:
A = indefinite article, not used in Esperanto.
This is a very important feature of the language! It just doesn’t fit the formulae I use.
Obviuosly you’re more likely to use this to make your own bot, but supposing you were going to deploy an exact copy this is what you would do:
bot.pyto change the
api_base_urlto the URL of your instance.
pip3 install --user Mastodon.py.
vortaro.secretin the same directory as
python3 bot.py, or equivalent. If all is successful it will print to
stdoutas well as tooting.
I run the bot via
cron. Remember: if you have a line like
0 * * * * /usr/bin/python3 /home/petra/vortaro/bot.py
in your crontab, it’s not going to run the bot in the right directory to find the files it needs; instead it will fail silently. Personally I use a wrapper script that
cds into the directory.