Category: Lunamech

Programming and assorted nonsense

LunaMech has been converted to LMAV2.


19th of January 2022 at 03:12am SAST

I finally sat down and took the time to convert LunaMech over to the second version of my Matrix API. The conversion process did not take as long as I had expected. At the same time I converted my Matrix API library to parse JSON as a hash-table rather than as a plist (this is both faster and more secure and so it would be nice if Jonathans default behaviour was this...), anyway the conversion process was made quite easy because I had used a macro which I had called 'pkv' to access plist values from parsed JSON, by simply changing the definition of PKV to access a hash-table instead much of the conversion was done automatically, the rest of the conversion was adding a few missing features, changing instances of getf to 'get-key' and testing repeatedly.

Since the conversion has been complete LunaMech has experienced 0 downtime.

Ofcourse I have not updated the documentation so LunaMech is effectively totally unusable to the uninitiated despite the fact that Luna makes Matrix very usable... Oh well.

LunaMech is finally FOSS software

Source and website.

26th of August 2021 at 15:30pm SAST

I have finally taken the time to extract all the hardcoded private keys and place them in a persistent library, meaning I am able to make LunaMech FOSS. LunaMech has been running on the scyldings.com Matrix server for close to a year now and has been under constant active development. It will remain under constant active development into the future as well. As of the time of writing this entry the bot will not build from source because I wrote a new macro called 'defmodule' to wrap up the process of defining new modules, but this does not play nicely with the compiler by default which I have to fix at some point, I may even change the abstraction to a metaclass... I am not sure yet.

Right now there is only an outdated way to generate a functioning config file, obviously this code base has been in active development so I have been using a config file that was generated many moons ago and I have slowly adapted it to work with any incremental changes, but this does mean that the config generator is out of date. The documentation in the README is also out of date, regardless it does provide a general overview of the default features of the bot, that being said the fundamental design idea of communities is almost outdated now that Matrix Spaces are making solid progress.

There was some more up to date documentation that was hosted on a taiga instance, however this instance is gone and I no longer have the documentation so I will have to go through and make some new documentation.

Let me briefly explain Luna's functionality right now:

The core idea of Luna are 'communities' these are mappings of room ids to room names which maintain a list of all of the members within them and their administrators. Commands like 'ban' will ban a user from all of the rooms listed in the community, ofcourse this is becoming less relevant as Spaces progresses, however this is still in heavy use on our Homeserver, the same goes for invite. Invite is especially useful if you want invite only communities.

Luna maintains a list of communities with a file called 'communities.lisp' in a directory called config/, all persistent files for modules is also stored in this directory. The file communities.lisp is backed up roughly every 5 minutes, because Luna is effectively a naturally evolving program that was both the prototype and the product I still think that use the filesystem for persistence of the main file is a decent solution, although I could swap to Bknr.

Luna grabs messages for every 'listening-room' listed in each community and processes those messages, messages that start with '.' are assumed to be commands, however a completed command is something like '.<community-name>|<module name> <command-name> <args>', commands for modules are also invoked from within a community listening room. Once the prefix is checked the correct command is found within the global *commands* and invoked with the the arguments provided by the user. If the command is missing then its passed off to the default missing command generic which will decide whether to tell the user or not depending on their privilege.

After processing all of the messages for all of the communities and executing the functions as it should, Luna maps through all of the registered modules and hands the instance of the bot and the current sync object (I say object but its actually a list) off onto a method called 'on-sync' which every module is able to specialize, this is where much of the automatic functionality of Luna is found, because each module is able to perform actions based on the information in the sync object.

After doing this a few thousand times methods like 'on-save' are invoked so that modules can save themselves to whatever their persistent storage mechanism is, communities.lisp is also backed up.

Modules can be loaded and unloaded from Luna on the fly, loading invoked on-load-up, unloading on-module-unload. This is done either within your connected Sly session or using Lunas command invocation system.

This basic model is how all of the current functionality of Luna is implemented. Ofcourse this may change.

Anyway, hopefully I will get the time to write some developer docs and update the readme, I will host them on LunaMechs website.

Updates regarding Luna will be posted here for the foreseeable future.