Twitter Interactive Fiction (Frotz) Bot

(Gosh Darn Games) #1

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
(Hanon Ondricek) #2

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
(Gosh Darn Games) #3

Hey thanks!

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

(Jesse McGrew) #4

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
(David Griffith) #5

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

(Gosh Darn Games) #6

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.

(Gosh Darn Games) #7

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!

(David Griffith) #8

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.

(Gosh Darn Games) #9

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.

#10

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.

(Gosh Darn Games) #11

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.

(Daniel Stelzer) #12

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.

(Gosh Darn Games) #13

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: