summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2009-01-18 20:10:12 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2009-01-18 20:10:12 +0000
commitfa70e3360757075e45b08340b0ab3a5b585af826 (patch)
tree11ffd3a26f6b727d33f8a89db98f8f96ae5f9907
parent1cb625e2a216704f9e59f2b9cfb2b0611e4f12f5 (diff)
Hmm, why didnt this go through before?
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10973 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--conf/modules.conf.example28
-rw-r--r--src/modules/m_alias.cpp10
2 files changed, 36 insertions, 2 deletions
diff --git a/conf/modules.conf.example b/conf/modules.conf.example
index dc99a61ba..c49967f92 100644
--- a/conf/modules.conf.example
+++ b/conf/modules.conf.example
@@ -71,6 +71,14 @@
# Alias module: Allows you to define server-side command aliases
#<module name="m_alias.so">
#
+# Fantasy settings:
+#
+#<fantasy prefix="!">
+#
+# prefix:
+# Set the prefix for in-channel aliases (fantasy commands) to the
+# specified character. If not set, the default is "!".
+#
#-#-#-#-#-#-#-#-#-#-#- ALIAS DEFINITIONS -#-#-#-#-#-#-#-#-#-#-#-#-#-#
# #
# If you have the m_alias.so module loaded, you may also define #
@@ -86,6 +94,14 @@
# matched, or it has no format value. Aliases are #
# read from the top of the file to the bottom. #
# #
+# usercommand - If this is true, the alias can be run simply as #
+# /aliasname. Defaults to true. #
+# #
+# channelcommand - If this is true, the alias can be used as an #
+# in-channel alias or 'fantasy command', prefixed #
+# by the fantasy prefix character, !aliasname by #
+# default. Defaults to false. #
+# #
# format - If this is defined, the parameters of the alias #
# must match this glob pattern. For example if you #
# want the first parameter to start with a # for #
@@ -152,6 +168,18 @@
#
#<alias text="NICKSERV" format=":IDENTIFY *" replace="PRIVMSG NickServ :IDENTIFY $3-"
# requires="NickServ" uline="yes">
+#
+# You may also add aliases to trigger based on something said in a
+# channel, aka 'fantasy' commands, configured in the same manner as any
+# other alias, with usercommand="no" and channelcommand="yes" The
+# command must be preceded by the fantasy prefix when used.
+#
+#<alias text="CS" usercommand="no" channelcommand="yes"
+# replace="PRIVMSG ChanServ $1 $chan $2-" requires="ChanServ" uline="yes">
+#
+# This would be used as "!cs <command> <options>", with the channel
+# being automatically inserted after the command in the message to
+# ChanServ, assuming the fantasy prefix is "!".
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
# Allowinvite module: Gives channel mode +A to allow all users to use
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index e3e2e9a5d..c914aad66 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -51,6 +51,9 @@ class Alias : public classbase
class ModuleAlias : public Module
{
private:
+
+ char fprefix;
+
/* We cant use a map, there may be multiple aliases with the same name.
* We can, however, use a fancy invention: the multimap. Maps a key to one or more values.
* -- w00t
@@ -60,6 +63,9 @@ class ModuleAlias : public Module
virtual void ReadAliases()
{
ConfigReader MyConf(ServerInstance);
+
+ std::string fpre = MyConf.ReadValue("fantasy","prefix",0);
+ fprefix = fpre.empty() ? '!' : fpre[0];
Aliases.clear();
for (int i = 0; i < MyConf.Enumerate("alias"); i++)
@@ -214,13 +220,13 @@ class ModuleAlias : public Module
ServerInstance->Logs->Log("FANTASY", DEBUG, "fantasy: looking at fcommand %s", fcommand.c_str());
// we don't want to touch non-fantasy stuff
- if (*fcommand.c_str() != '!')
+ if (*fcommand.c_str() != fprefix)
{
ServerInstance->Logs->Log("FANTASY", DEBUG, "fantasy: not a fcommand");
return 0;
}
- // nor do we give a shit about the !
+ // nor do we give a shit about the prefix
fcommand.erase(fcommand.begin());
std::transform(fcommand.begin(), fcommand.end(), fcommand.begin(), ::toupper);
ServerInstance->Logs->Log("FANTASY", DEBUG, "fantasy: now got %s", fcommand.c_str());