[DONE] m_fantasy for custom !cmds

Need a module converted from 3.2.x to UnrealIRCd 4? Or looking for a certain module? Ask here.

Moderators: Gottem, Supporters

Post Reply
Posts: 171
Joined: Fri Aug 19, 2016 5:26 pm
Location: NL

[DONE] m_fantasy for custom !cmds

Post by Gottem » Sun Jan 22, 2017 12:11 am

Another recommendation by alhoceima, this implements something very similar to Unreal's aliases and Anope's fantasy stuff. But where the aliases are limited to /command, this module allows you to use `command, !command, etc. This has the (intended) side effect of being visible to users. Furthermore, these fantasy aliases are limited to channel messages. There's not much you can do in private messages anyways, besides maybe ACTION or something. It also supports a few special inline variables, more on that below.

If you're not sure what fantasy means, you may remember/have seen something like "!kick <user>" in channels. This causes ChanServ to kick that particular user.

Special variables:
I'll put these before the config block so you'll have that info before you get to it. ;] You can use all the special variants for $1 through $9.
  • $chan => Will be replaced with the channel you said the command in
  • $1 => Will be replaced with the user's first argument
  • $1- => Becomes the first argument plus everything after it (greedy)
  • $1i => If the first arg is a nick, replace it with their ident/username
  • $1h => If the first arg is a nick, replace it with their hostname
You cannot use multiple greedy vars however, reasons should be obvious.

Config block:
Creating aliases might be a bit complex, so I'll just dump an example config right here and explain in-line with comments. =]

Code: Select all

fantasy {
	// Change command prefix to \, so it becomes \dovoice etc
	//cmdchar \;

	// "!benice someuser" is turned into "/kick $chan someuser :You be nice now"
	benice "KICK $chan $1 :You be nice now";

	// "!kick someuser shut up" becomes "/kick someuser :shut up"
	kick "KICK $chan $1 :$2-";

	// "!invex someuser" is majikked into "/mode $chan +I *!*@someuser.tld
	invex "MODE $chan +I *!*@$1h";
	uninvex "MODE $chan -I *!*@$1h";

	// "!safe someuser" will become "/kick $chan someuser :$chan is a safe space, someuser"
	safe "KICK $chan $1 :$chan is a safe space, $1";

	// It is also possible to have the same alias issue multiple commands ;]
	safe "MODE $chan +b $1";
	// You can also go through ChanServ, provided you have access with it
	n "PRIVMSG ChanServ :KICK $chan $1 please change your nick and rejoin, thank you";
As you may have noticed there are some colons in there. These are required, because otherwise there's no telling where the target arg stops and the message begins. Also, in case you do !devoice (so without any args) it will try and voice the user who issued it. Permissions for using the resulting command are eventually checked by the do_cmd() call I have in here. ;3

Get it here.
If you like my modules, pls consider donating (through PayPal) or becoming a monthly Patron ;];]

Post Reply