Thomas Deeb, Software Developer



TRBot

Technologies: C#, C, vJoy, uinput, VSCodium, Git

Summary

TRBot is software that allows playing games through text. This extends to WebSockets and services such as IRC, XMPP, Twitch, and Matrix, allowing players to remotely control games via chat. The goal of TRBot is to lower the barrier of entry for hosting collaborative play streams and provide avenues to improve the experience. TRBot is free software licensed under the AGPL 3.0.

Technical Underpinnings

TRBot contains a very fast parser that converts text into inputs. The parser can handle extremely long input strings and convert them to very precise inputs that it then processes. TRBot can be configured to run directly in the terminal, or over a WebSocket, IRC, XMPP, Matrix, or any Twitch channel.

After parsing chat messages, TRBot carries out the inputs by sending them through a virtual joystick (vJoy on Windows, custom uinput controllers on GNU/Linux). Several SDL2 and controller profiles are provided for quick setup. Other resources, such as ChatterBot, LiveSplitOne, and LibreTranslate integrations, are provided through Python scripts and pluggable C# code to increase user engagement and retention while tuned into the streams. TRBot supports multiplayer games and PC games, facilitated through its console-based architecture, which allows for adjusting the available inputs on the fly. Internally, TRBot utilizes multiple threads to handle each input message.

Rust Rewrite

TRBot is currently undergoing a rewrite in Rust. The new approach is implemented via a lexer similar to a full programming language and aims to be more performant and accurate, eliminate ambiguities in inputs, and allow extending the syntax. Several new syntax features have already been implemented, such as permanent holds and linking macros and repetitions with other expressions.

Impact

I've presented a 45-minute talk of TRBot at LibrePlanet 2022: Living Liberation. This talk covers the history of the project, details about how TRBot works, and its impact on gaming communities.

To date, TRBot has been used by many streamers, including Brace Yourself Games, f1ashko, Nickadabra, TwitchPlaysSpeedruns, and TheChatPlaysGames.

This project was inspired by TwitchPlays_Everything, which hosted Twitch Plays runs for various classic video games. The input syntax of their bot was more robust than anything else on Twitch, and I found it fun to see what I can do while playing complex games through text. When the channel became less active, I found that there was a lack of Twitch Plays bots with a similarly flexible syntax. I loved the unique challenges involved with playing games in this way and took it upon myself to write a new and improved, libre version, of TwitchPlays_Everything's bot. Since then, TRBot has surpassed TwitchPlays_Everything's bot's capabilities.

TRBot's logo was designed by David Revoy, known for his Pepper & Carrot webcomic, and is licensed under CC BY-SA 4.0.

Get it on Codeberg

Showcase


The Rust rewrite brings a new syntax and new features, including linking macros with other types of expressions.





An example of how TRBot can handle inputs. Inputs can be as simple or complex as the player wants.





An example of an advanced command. The multithreaded implementation allows for very accurate timings by minimizing the delay between processing the input and carrying it out.



It's also possible to control different controller ports at will. This enables multiplayer co-op and competitive games.