Twitter Interactive Fiction (Frotz) Bot

Hi there.

I have written a twitter bot that can be used to play Interactive Fiction games.

The bot runs a game using Frotz ( Z Machine Interpreter ) and tweets the output from the game.

Players can reply to the bot or ‘mention’ the bot with an @ symbol to send a command.

Replying with a message like ‘cmd get lamp’ will make the bot send ‘get lamp’ to the game.

The bot checks its mentions once per minute and sends a random command from any commands it received in that minute.

The bot is currently running on a raspberry pi @tweetintfict - https://twitter.com/tweetintfict

The source code for the bot can be found here: https://github.com/goshdarngames/TwitterAdventureBot

Right now it’s running the classic Colossal Cave Adventure but I’d love to run a variety of games in the future.

It would be great if you could stop by and send some commands.

2 Likes

Welcome to the forum, @goshdarngames!
Neat idea for a bot. I looked at the account and was a bit shy to send a command.

1 Like

Hey thanks!

No need to feel shy at all. I’d appreciate the help in the battle against this parser!

Choosing a random command sounds hilarious, but if anyone wants to guide the bot to the right solution, they might resort to spamming… would it be feasible to pick the most-liked command, or at least weight them by the number of likes?

1 Like

Wednesday night, I fixed the last remaining strcat() call in the dumb interface.

I went with the simplest solution just to get the bot up and running as a proof of concept.

If it gets any popularity it would be a good idea to slow down how often it sends commands and include some sort of voting.

Cool I’ve fetched the latest version so next time I start the bot it should be using that.

Is strcat () something that would make the dumb interface crash?

Thanks for your work on Frotz. It made it fairly straightforward to get the system running!

strcat() and strcpy() are very prone to being abused to cause buffer overflows. So it could have caused a crash if someone tried to abuse the bot.

Thanks. I like to keep the dumb interface up to date because it has always proved popular for stuff like this.

Oh right good to know.

I think Twitter does some input checking by default and I do some more inside Python.

The whole thing runs inside a Docker container also so hopefully there is a limit to how much damage someone can do.

If the bot itself is written in python you could use a python interpreter, which at the very least would be safe against memory overflows.

Are memory overflows a big concern when running Frotz?

I should be able to check the input for any weird characters and the system runs inside a docker container. If someone manages to somehow execute arbitrary code they’d be contained within a tiny operating system with very limited functionality. I’ll see what I can do to ensure the docker container is as limited as possible.

I chose Frotz because it was very simple to get up and running with a plain stdin / stdout interface.

Not a major concern, but if nothing else they could definitely cause a denial of service by crashing the program. Or abuse the Twitter account for their own purposes, since the bot will tweet whatever Frotz sends it.

That said, the odds of anyone actually abusing this are slim. It’s a good idea to update your Frotz, but it’s not the end of the world to keep using the current version for your prototype.

Well it’s updated now and I’ll try to remember to update it from time to time.

I have a done a bit of work to sanitize the input from the player. My main concern right now would actually be from a buggy game. If a game were to go into an infinite loop sending output then it could potentially get the twitter bot banned for sending too many messages. It will be easy enough to mitigate this risk though.

The bot is up and running stable for now so I’ll see how far Twitter can get through Adventure before taking it offline to add more features again :slight_smile:

Hi just a small update on the status of the bot.

I’ve done some work to make the bot recover properly if its internet connection goes down temporarily.

The bot is currently online playing Colossal Cave Adventure. Hopefully it is stable now.

There is one last important feature I would like to add. Currently it only mentions the most recent user when a command is sent. I’d like to make it so that if you interact with the bot it will mention you for a few commands so that it’s possible to keep up with the game if multiple people are sending commands.

After that I’ll be on the look for other games to play so if anyone has a game they’d like the bot to play that would work with dfrotz then let me know. I think it could be a neat way to showcase games.