Tip of the day: Exempt your IP address from bans, just in case you or a fellow IRCOp accidentally GLINES you.

Special module manager block in source file

From UnrealIRCd documentation wiki
Jump to navigation Jump to search

The following is for module authors only (C programmers)

To recognize your 3rd party module in the Module manager, it needs to have two things:

  1. A proper MOD_HEADER
  2. A special module configuration block

It's best to do this by example, so here we go:

Adding the necessary information in the .c file

#include "unrealircd.h"

ModuleHeader MOD_HEADER
  = {
        "third/testmod", /* name */
        "1.0.0", /* version */
        "This is a short description of the module", /* description */
        "Bram Matthys (Syzop)", /* author */
        "unrealircd-6",
    };

MOD_INIT()
{
    return MOD_SUCCESS;
}

/*** <<<MODULE MANAGER START>>>
module
{
        // THE FOLLOWING FIELDS ARE MANDATORY:

        // Documentation, as displayed in './unrealircd module info nameofmodule', and possibly at other places:
        documentation "https://www.example.org/";

        // This is displayed in './unrealircd module info ..' and also if compilation of the module fails:
        troubleshooting "In case of problems, check the FAQ at ... or e-mail me at ...";

        // Minimum version necessary for this module to work, this can be simply "6.*" or like "6.1.0":
        min-unrealircd-version "6.*";

        // THE FOLLOWING FIELDS ARE OPTIONAL:

        // Maximum version that this module supports:
        max-unrealircd-version "6.*";

        // This text is displayed after running './unrealircd module install ...'
        // It is recommended not to make this an insane number of lines and refer to a URL instead
        // if you have lots of text/information to share:
        post-install-text {
                "The module is installed. Now all you need to do is add a loadmodule line:";
                "loadmodule \"third/testmod\";";
                "And /REHASH the IRCd.";
                "The module does not need any other configuration.";
        }
}
*** <<<MODULE MANAGER END>>>
*/

Checking the data

Then run the following command to parse/test the C file: ./unrealircd module parse-c-file src/modules/third/testmod.c

module "third/testmod"
{
	description "This is a short description of the module";
	version "1.0.0";
	author "Bram Matthys (Syzop)";
	documentation "https://www.example.org/";
	troubleshooting "In case of problems, check the FAQ at ... or e-mail me at ...";
	source "...";
	sha256sum "1cdbc358d57b598747062e035d0ec44c9432f18b041a6bfc8505e95c9343b97f";
	min-unrealircd-version "6.*";
	max-unrealircd-version "6.*";
	post-install-text
	{
		"The module is installed. Now all you need to do is add a loadmodule line:";
		"loadmodule \"third/testmod\";";
		"And /REHASH the IRCd.";
		"The module does not need any other configuration.";
	}
}

As you can see, the parser gathered information from both the MOD_HEADER() block (name, description, author, version) and from the magic module block. Some fields are autogenerated, such as the sha256sum. The URL is always three dots in the parse test.

If there are any problems then you will not see the block output from above but see an ERROR on the console with a description of what needs to be fixed. For example, if you are missing the min-unrealircd-version field.