+ 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
+ */
+ std::multimap<irc::string, Alias> Aliases;
+
+ /* whether or not +B users are allowed to use fantasy commands */
+ bool AllowBots;
+
+ virtual void ReadAliases()
+ {
+ ConfigReader MyConf;
+
+ AllowBots = MyConf.ReadFlag("fantasy", "allowbots", "no", 0);
+
+ std::string fpre = MyConf.ReadValue("fantasy","prefix",0);
+ fprefix = fpre.empty() ? '!' : fpre[0];
+
+ Aliases.clear();
+ ConfigTagList tags = ServerInstance->Config->ConfTags("alias");
+ for(ConfigIter i = tags.first; i != tags.second; ++i)
+ {
+ ConfigTag* tag = i->second;
+ Alias a;
+ a.AliasedCommand = tag->getString("text").c_str();
+ tag->readString("replace", a.ReplaceFormat, true);
+ a.RequiredNick = tag->getString("requires");
+ a.ULineOnly = tag->getBool("uline");
+ a.ChannelCommand = tag->getBool("channelcommand", "no");
+ a.UserCommand = tag->getBool("usercommand", "yes");
+ a.OperOnly = tag->getBool("operonly");
+ a.format = tag->getString("format");
+ a.CaseSensitive = tag->getBool("matchcase");
+ Aliases.insert(std::make_pair(a.AliasedCommand, a));
+ }
+ }
+
+ public:
+
+ ModuleAlias()
+ {
+ ReadAliases();
+ ServerInstance->Modules->Attach(I_OnPreCommand, this);
+ ServerInstance->Modules->Attach(I_OnRehash, this);
+ ServerInstance->Modules->Attach(I_OnUserMessage, this);
+ }
+
+ virtual ~ModuleAlias()
+ {
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version("Provides aliases of commands.", VF_VENDOR);
+ }
+
+ std::string GetVar(std::string varname, const std::string &original_line)
+ {
+ irc::spacesepstream ss(original_line);
+ varname.erase(varname.begin());
+ int index = *(varname.begin()) - 48;
+ varname.erase(varname.begin());
+ bool everything_after = (varname == "-");
+ std::string word;
+
+ for (int j = 0; j < index; j++)
+ ss.GetToken(word);