The @floatingcitybot appeared suddenly.
A Twitter bot that tweets Marvels of a Floating City by Xi Xi.1
We take paragraphs from the source material and greedily split them into groups of sentences, maximising length subject to the character limit. If this is not possible (i.e. we have very long sentences), we split by delimiter instead.
State is maintained by Twitter, so we check what the last tweet was, find it in our array of text groups and tweet the next element. If there is no last tweet, start from the start. If the last tweet is the last text group in our array, we've finished, so do nothing (as opposed to restarting).
Requires the standard Twitter API environment variables. Generate them with fionn/twitter-authenticator.
Run src/tweetify.py
to print each text group.
Run src/main.py
to tweet once and exit.
Add the remote with git remote add heroku https://git.heroku.com/app-name.git
and use git push heroku
to deploy.
Footnotes
-
As translated by Linda Jaivin and Geremie Barmé, sourced from China Heritage and reproduced (with minor corrections) in
data/floating_city_en.md
. ↩