A modular, command driven Twitter bot, currently only generating visualizations of L-Systems, though easily adaptable for more interesting purposes.
- Configurable poll time (not using streaming api (yet))
- Can send media tweets (w/ image attachments)
- Keeps track of last processed tweet ID (to avoid duplicates)
- Adds proper source tweet ID for replies
Overall tweet syntax is:
Example tweet to generate an L-System visualization (note: the bot is not running 24/7 at the moment):
The overall format for the
lsys command is:
header is a comma separated list of:
- CSS hex color string
- Number of iterations
- Start angle
- Rotation angle
A ruleset is a comma separated list of single letter rule IDs an
their replacements. The ruleset must contain a rule named
the start rule (axiom, also see above example).
s=f-f-f-fs defines a rule named
s which is iteratively
Other rule symbols are:
f- forward (draw line)
-- rotate left
+- rotate right
[- store state (e.g. for branching)
]- pop state (end branch)
Run-length encoding can be used for multiple consecutive symbols (to
save precious char counts), e.g.
5+ expands to
+++++. Only the
9 can be used for this purpose.
Furthermore, the symbols
e can be used as markers or for more
complex, mutually recursive replacements and each also execute an
implicit forward motion. The symbols
z are similar too, but
do not incl. a forward motion.
For security reasons the bot will refuse to execute systems expanding to more than 1 million symbols.
If there're any syntax errors, you'll most likely get a text-only reply telling you so, or if the error is more subtle, receive an image based on default values for the ones which were unspecified or contained errors (e.g. header settings, missing rules).
launch-sample.sh and add your Twitter API details (see
below). Save file as
launch.sh, then launch via:
In the REPL kick off with:
;; start bot w/ 60s poll interval ;; (shorter periods will trigger Twitter's API rate limit) (def bot (run state 60000)) ;; `bot` is a control channel, which should be closed to stop the bot (close! bot)
Create Twitter app credentials
- Go to: https://apps.twitter.com/
- Create new app (don't need callback URL)
- Copy Consumer key/secret & Access token/secret into
- Change the bot user name
Copyright © 2015 Karsten Schmidt
Distributed under the Apache Software License 2.0.