*/
#include "inspircd.h"
-#include "wildcard.h"
/* $ModDesc: Provides the TITLE command which allows setting of CUSTOM WHOIS TITLE line */
*/
class CommandTitle : public Command
{
-
public:
CommandTitle (InspIRCd* Instance) : Command(Instance,"TITLE",0,2)
{
TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
}
-bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
-{
- std::stringstream hl(hostlist);
- std::string xhost;
- while (hl >> xhost)
- {
- if (match(host, xhost) || match(ip,xhost, true))
- {
- return true;
- }
- }
- return false;
-}
+ bool OneOfMatches(const char* host, const char* ip, const char* hostlist)
+ {
+ std::stringstream hl(hostlist);
+ std::string xhost;
+ while (hl >> xhost)
+ {
+ if (InspIRCd::Match(host, xhost) || InspIRCd::MatchCIDR(ip,xhost))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
CmdResult Handle(const std::vector<std::string> ¶meters, User* user)
{
if (!IS_LOCAL(user))
return CMD_LOCALONLY;
-
+
char TheHost[MAXBUF];
char TheIP[MAXBUF];
if (!strcmp(name.c_str(),parameters[0].c_str()) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.c_str()) && OneOfMatches(TheHost,TheIP,host.c_str()) && !title.empty())
{
std::string* text;
- user->GetExt("ctitle", text);
-
- if (text)
+ if (user->GetExt("ctitle", text))
{
user->Shrink("ctitle");
delete text;
user->Extend("ctitle", text);
ServerInstance->PI->SendMetaData(user, TYPE_USER, "ctitle", *text);
-
+
if (!vhost.empty())
user->ChangeDisplayedHost(vhost.c_str());
class ModuleCustomTitle : public Module
{
CommandTitle* mycommand;
-
+
public:
ModuleCustomTitle(InspIRCd* Me) : Module(Me)
{
-
+
mycommand = new CommandTitle(ServerInstance);
ServerInstance->AddCommand(mycommand);
Implementation eventlist[] = { I_OnDecodeMetaData, I_OnWhoisLine, I_OnSyncUserMetaData, I_OnUserQuit, I_OnCleanup };
{
/* Insert our numeric before 312 */
std::string* ctitle;
- dest->GetExt("ctitle", ctitle);
- if (ctitle)
+ if (dest->GetExt("ctitle", ctitle))
{
ServerInstance->SendWhoisLine(user, dest, 320, "%s %s :%s",user->nick.c_str(), dest->nick.c_str(), ctitle->c_str());
}
{
// check if this user has an ctitle field to send
std::string* ctitle;
- user->GetExt("ctitle", ctitle);
- if (ctitle)
+ if (user->GetExt("ctitle", ctitle))
{
// call this function in the linking module, let it format the data how it
// sees fit, and send it on its way. We dont need or want to know how.
virtual void OnUserQuit(User* user, const std::string &message, const std::string &oper_message)
{
std::string* ctitle;
- user->GetExt("ctitle", ctitle);
- if (ctitle)
+ if (user->GetExt("ctitle", ctitle))
{
user->Shrink("ctitle");
delete ctitle;
{
User* user = (User*)item;
std::string* ctitle;
- user->GetExt("ctitle", ctitle);
- if (ctitle)
+ if (user->GetExt("ctitle", ctitle))
{
user->Shrink("ctitle");
delete ctitle;
}
}
}
-
+
virtual ~ModuleCustomTitle()
{
}
-
+
virtual Version GetVersion()
{
- return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
+ return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
}
};