Ruby
Free Ruby Twitch bot hosting.
Twitch chat is IRC, and Ruby has libraries for it. Run a command bot around the clock without leaving your own machine on.
Libraries
Libraries that run here
An IRC library
Twitch chat speaks IRC, so a general Ruby IRC library such as Cinch can connect to it. Check that the version you pick still runs on current Ruby before you build on it.
A plain socket
For a listen-and-reply bot, Ruby's TCPSocket wrapped in OpenSSL talks to Twitch chat directly, with no dependency at all.
Net::HTTP for the Helix API
Looking up streams, users and clips is HTTPS and JSON with an OAuth token, which the standard library can do.
Deploying
Getting it running
- 1
Upload your project
Drag the folder into the file manager or push it over SFTP. Gems install into a folder inside your server, so there is no need to upload a vendor directory. Keep your client secret out of the project folder.
- 2
bundle install runs for you
When a Gemfile is present, Bundler installs it before the bot starts and skips the install on later restarts until the Gemfile changes. With only the standard library there is no Gemfile and nothing to install, so the bot starts at once.
- 3
Point us at your entry file
bot.rb or main.rb. Client ID and secret go into environment variables; refreshed tokens go into a file or a SQLite row your bot writes itself.
Memory
What actually fits in 256 MB
More than a chat bot needs. Chat is small lines of text, nothing caches your viewers, and a bot in several channels stays small.
When one grows, it is state the bot keeps for itself: cooldown tables, message history, every chatter's points held in a hash. Keep the permanent parts in SQLite on your 512 MB of disk.
FAQ
Questions
Is there an official Ruby library for Twitch?
Not one we can point you to as official. That is why this page leans on IRC and plain HTTP, which Twitch documents, rather than a gem that may fall behind the platform.
Where should tokens and points live?
In SQLite or a small file the bot rewrites. Keep the current token pair in one table, updated on every refresh, and points or quotes in another.
Do gems with native extensions work?
Yes for the common ones. The image has a compiler and the headers for SQLite, PostgreSQL, MariaDB, libxml and OpenSSL, so gems such as nokogiri, pg, mysql2 and sqlite3 build when bundle install runs. The first start after you change your Gemfile takes longer while they compile; later starts skip the install.
Where should the secrets live?
In environment variables set on the server, read with ENV.fetch. A .env file uploaded with your code sits in your file manager like any other file, and Ruby does not read one by itself unless you add a gem such as dotenv for it.
More on Twitch bots
Hosting something else?
Control it from code