m_namesx.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "inspircd.h"
00015 #include "m_cap.h"
00016
00017
00018
00019 class ModuleNamesX : public Module
00020 {
00021 public:
00022
00023 ModuleNamesX(InspIRCd* Me)
00024 : Module(Me)
00025 {
00026 Implementation eventlist[] = { I_OnSyncUserMetaData, I_OnPreCommand, I_OnNamesListItem, I_On005Numeric, I_OnEvent };
00027 ServerInstance->Modules->Attach(eventlist, this, 5);
00028 }
00029
00030
00031 virtual ~ModuleNamesX()
00032 {
00033 }
00034
00035 void OnSyncUserMetaData(User* user, Module* proto,void* opaque, const std::string &extname, bool displayable)
00036 {
00037 if ((displayable) && (extname == "NAMESX"))
00038 proto->ProtoSendMetaData(opaque, TYPE_USER, user, extname, "Enabled");
00039 }
00040
00041 virtual Version GetVersion()
00042 {
00043 return Version("$Id: m_namesx.cpp 10291 2008-08-25 20:35:51Z w00t $",VF_VENDOR,API_VERSION);
00044 }
00045
00046 virtual void On005Numeric(std::string &output)
00047 {
00048 output.append(" NAMESX");
00049 }
00050
00051 virtual int OnPreCommand(std::string &command, std::vector<std::string> ¶meters, User *user, bool validated, const std::string &original_line)
00052 {
00053 irc::string c = command.c_str();
00054
00055
00056
00057
00058
00059 if (c == "PROTOCTL")
00060 {
00061 if ((parameters.size()) && (!strcasecmp(parameters[0].c_str(),"NAMESX")))
00062 {
00063 user->Extend("NAMESX");
00064 return 1;
00065 }
00066 }
00067 return 0;
00068 }
00069
00070 virtual void OnNamesListItem(User* issuer, User* user, Channel* channel, std::string &prefixes, std::string &nick)
00071 {
00072 if (!issuer->GetExt("NAMESX"))
00073 return;
00074
00075
00076 if (nick.empty())
00077 return;
00078
00079 prefixes = channel->GetAllPrefixChars(user);
00080 }
00081
00082 virtual void OnEvent(Event *ev)
00083 {
00084 GenericCapHandler(ev, "NAMESX", "multi-prefix");
00085 }
00086 };
00087
00088 MODULE_INIT(ModuleNamesX)