Minetest Remote Chatroom API (AJAX-based chat feed)

Post Reply
User avatar
Posts: 1699
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Minetest Remote Chatroom API (AJAX-based chat feed)

by sorcerykid » Post


Minetest Remote Chatroom API
minetest_chatroom (by sorcerykid)

Minetest Remote Chatroom API allows for embedding realtime chat from a Minetest server directly onto your homepage using only Javascript/AJAX and a tiny CGILua script for the bridge.

A few pre-requisites apply to get up and running:
  • Your Web server must be hosted on the same physical box as your Minetest server.
  • You must install the corresponding mod to record the chat output to a local file.
  • You must install CGILua and configure your Web server for executing CGILua scripts.
Installation of CGILua is beyond the scope of this document, but with Luarocks it should be very straightforward:

Code: Select all

luarocks install cgilua
Once these steps are completed, then you can download the Minetest Remote Chatroom package:


The following 4 files are contained in the package, in addition to a README.txt with license information:
  • chatroom.js
    This is the Javascript library for receiving chat messages via AJAX, providing an API for dispatching events to the webpage. It must be placed in a public-facing directory of your web server. In the example below, I've chosen the "/var/www/html/lib" directory, but you can use any suitable location.

    This is the CGI-based chat bridge responsible for relaying chat messages to the client from the respective chat log. It must be placed into a public-facing directory of your web server that is configured for script execution, typically "cgi-bin". Be sure to set the correct ownership and permissions.

    This is the configuration for the chat bridge above. It must be placed into the same directory as "stream_chat.lua". For security reasons, you should also deny read-access to all files having a ".conf" extension.

    This is a sample homepage which can also serve as a barebones template for integrating the Javascript library on your site.
The following configuration options are available for the CGI script:
  • timeout - the maximum length of time that a client can remain connected to the chat bridge, or indefinite by default.
  • output_path - the location where chat output is being recorded, as configured within the "remote_chat" mod (see above).
  • banned_ips - an optional list of IP addresses that are banned from connecting to the chat bridge.
With everything installed and configured, open the "sample.html" file in your favourite editor and refer to the integration instructions.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests