Discoggin: an IF bot for Discord
Friday, July 4, 2025 (updated 1 day later)
Comments: 2 (plus live) (latest 1 day later)
Tagged: discoggin, discord, bots, if, interactive fiction, terps, interpreters, inform, ink, yarnspinner
Here's a new toy: a Discord bot that plays IF games.
Say you've got a group of people who want to play an IF game together. You'd log into the IFTF Discord and go to the #zarfbot-9000
channel. (That's where the bot is currently running.)
Type /games to see a list of available games, then /select GAME to select one. Or if you want to install one off the IF Archive, say, you could type a command like
/install https://ifarchive.org/if-archive/games/zcode/huntdark.z5
(These are regular Discord slash commands. Hit / in the #zarfbot-9000
channel to see a list of bot commands. You'll have to scroll down to "Discoggin-IF", mind you. The IFTF Discord has a couple of different bots installed.)
After selecting or installing a game, type /start to start it up. Or maybe the game is already running! If someone else installed it, they might have been in the middle of a session. This is meant for social play, so you can jump back in and continue seamlessly where the last player left off. Type /recap to see the last few commands.
What are commands? Simple: type >GET LAMP
. No slash; that's a regular channel message starting with the >
character. The bot will accept the command and respond. It ignores non->
messages, so you can freely discuss the game with your friends in the channel.
From Lost Pig by Admiral Jota.
Note that anybody in the channel can give a game command. There's no built-in "driver" system. This is a friendly Discord; the code of conduct is linked in the #rules
channel. Chill with your friends and work out a scheme that works for the group.
That's it! But I bet you have questions.
Why?
I was inspired by ClubFloyd, which has been meeting on IFMud every week for most of twenty years to group-play IF games.
There's nothing wrong with a MUD. But Discord is a lot more popular these days; more people know how to use it.
What game formats are supported?
The bot can handle Inform games (Z-code and Glulx), Ink games, and YarnSpinner games.
For the choice-based formats, you'll see numbered selections. Type a command like >#3
to select a choice. This also works for hyperlink-based Glulx games.
The bot supports only plain text, a bit of text styling (italics and bold), and hyperlinks. No graphics, not even for Glulx games that include graphics.
What other slash commands does the bot understand?
See the README file. The most interesting ones are:
- /status : Display the current status line.
- /recap COUNT : Recap the last few commands (max of 10).
- /files : List save files (and other data files) recorded in this session.
- /forcequit : Shut down a game if it's gotten stuck for some reason, or if it doesn't accept
>QUIT
. (You will then need to /start it again.)
What if the game is waiting for a keystroke?
You can type >space
, >return
, or a key name like >A
.
Can I save my position?
The bot autosaves every turn. You can take a break, or even /select a different game, and then come back to your existing session. You'll be where you left off.
If you want to do a manual >SAVE
, that will work too. Enter the save filename as the next command: >inside-house
. Use the slash command /files to see the list of manual save files.
Can I save a transcript?
The standard >SCRIPT ON
command should work for Inform games. However, I haven't yet implemented a way to download transcripts.
Really, the correct plan is for the bot to save a transcript of every game, like Lectrote does. (Without requiring a >SCRIPT
command.) Then it could generate a two-column transcript -- game output and channel discussion -- like ClubFloyd does.
I should warn you that I've started implementing this plan. That means that the bot is recording discussion in the #zarfbot-9000
channel! Anything you say there may be archived for posterity as part of the active game's transcript.
Are there bugs?
Certainly! But I'm not aware of many, because the bot hasn't gotten serious testing yet. Perhaps this post will uncork the flood.
The biggest known bug is that Whoops, misread some tests last month! UNDO
doesn't work in Z-code games.UNDO
works fine.
The choice-based formats don't support UNDO
, SAVE
, or RESTORE
.
Some games don't test properly for lack of graphics. For example, Alabaster throws a lot of "graphics call not supported" errors. This is technically a bug in the game, not the bot, but I realize that cuts no ice.
Can I get this bot on my Discord?
I am not currently allowing public installations of the bot. The back end is running on a machine I own. (A Mac Mini in my office, in fact.) It's not a big load on the machine or my home network -- but if lots of people started playing games, it would become a big load.
However, the bot is open source. You're welcome to run your own copy and install it wherever you want. It's fairly easy to set up the bot if you're familiar with Python. See the README for instructions.
Unfortunately the game interpreters are more of a hassle. They're open-source too, but they're variously written in C, JS/Node, and C#/.NET. So there's a bit of an adventure there, no pun intended.
What about TADS, Hugo, Alan...?
Adding these formats won't be entirely easy. Allow me to get technical.
To support a game format, the bot needs an interpreter with two features:
The first part is easy. Most parser IF tools support Glk. (The popular Gargoyle interpreter has almost every current IF system as a Glk-enabled component. There's fiddly details but I'll skip them.)
The second part is more of a pain. The traditional IF interpreter expects you to start up a game and play for a while. Saves are a manual process. (It was the 80s, remember!) The interpreter keeps all its state in memory.
But the Discord bot doesn't want to run persistent interpreter processes. It could have dozens or even hundreds of "live" game sessions. It's only playing one at a time; the rest are saved in the background. Therefore, the bot only launches an interpreter when a player command arrives! The interpreter's job is:
- Load the game file;
- Silently restore the last position;
- Receive the player command from the bot (as a JSON message);
- Carry out that command;
- Send the game output for that turn to the bot (JSON again);
- Silently autosave the new position;
- Shut down.
This all happens in a moment. By the time you see the game response, the interpreter has already autosaved and exited.
Most IF interpreters don't support this style of play. I added the capability to Glulxe and Bocfel, back when I was working on iPhone IF apps. (Mobile games don't have this one-turn-at-a-time style, but they must autosave -- players insist on it.) That covers Glulx and Z-code games. But other formats will be more work.
But what about Twine? Surely you can support Twine.
Oh, geez, I wish.
Ink and YarnSpinner are components which generate text. They were designed to be plugged into a game framework. Their save systems are completely accessible and modular. So it was very easy to write wrappers to fit them into the bot framework.
(Okay, YarnSpinner's save system required some tweaking -- I don't think it intended for the game to save at every single choice point. But I got it working.)
Twine was not designed to be a component. Or rather, it was designed to be a component of a web page. It interacts with its environment through JavaScript and DOM manipulation.
In other words, it doesn't really make sense to talk about the plain-text output of a Twine game. The game is intertwi-, um, let's say entangled, with its story format. And the format is all about macros, which are Javascript calls.
One could imagine a Twine story format which is deliberately limited to plain text-and-choice interactions. (Like the WritingFantasy format limits you to what works in a printable book.) It would have variables and a bit of formatting, but no macros. Then you could have a tool like Gordian which converts that format to work with the Discord bot.
But you couldn't take an arbitrary playable Twine game and shove it in there. It would have to be written for that style.
Why is it called "Discoggin"?
Man, I don't know.
I suspect people are going to call it "the zarfbot", because that's the channel name. Oh well. Someday I'll write a second bot, and then you'll I'll be sorry.
Comments from Mastodon
@zarfeblong oh this is great! there used to be a number of bots for Z-games but Discord changed their bot API and the bots broke.
Comments from Mastodon (live)
Please wait...
This comment thread exists on Mastodon. (Why is this?) To reply, paste this URL into your Mastodon search bar:
@zarfeblong Oh neat! I joined a ClubFloyd playthrough once, but for some reason was never able to make Mud stuff a habit...