X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_services_account.cpp;h=77a7377c6527e7f8a67f8636e1b4d72aa988926e;hb=de69e28a4a1aea89e410b693bbbb67890ecb0bd3;hp=ac71a12157a24a1f66ad740a3d774afd16335141;hpb=2d732f4dbf4ccd22c8a4424692cc72a89ffd49b7;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index ac71a1215..77a7377c6 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -22,12 +22,12 @@ class Channel_r : public ModeHandler { public: - Channel_r(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'r', PARAM_NONE, MODETYPE_CHANNEL) { } + Channel_r(Module* Creator) : ModeHandler(Creator, "registered", 'r', PARAM_NONE, MODETYPE_CHANNEL) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { // only a u-lined server may add or remove the +r mode. - if (IS_REMOTE(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server)) + if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server)) { // Only change the mode if it's not redundant if ((adding && !channel->IsModeSet('r')) || (!adding && channel->IsModeSet('r'))) @@ -52,11 +52,11 @@ class User_r : public ModeHandler { public: - User_r(InspIRCd* Instance, Module* Creator) : ModeHandler(Creator, 'r', PARAM_NONE, MODETYPE_USER) { } + User_r(Module* Creator) : ModeHandler(Creator, "registered", 'r', PARAM_NONE, MODETYPE_USER) { } ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) { - if (IS_REMOTE(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server)) + if (!IS_LOCAL(source) || ServerInstance->ULine(source->nick.c_str()) || ServerInstance->ULine(source->server)) { if ((adding && !dest->IsModeSet('r')) || (!adding && dest->IsModeSet('r'))) { @@ -78,7 +78,7 @@ class User_r : public ModeHandler class AChannel_R : public SimpleChannelModeHandler { public: - AChannel_R(InspIRCd* Instance, Module* Creator) : SimpleChannelModeHandler(Instance, Creator, 'R') { } + AChannel_R(Module* Creator) : SimpleChannelModeHandler(Creator, "reginvite", 'R') { } }; /** User mode +R - unidentified users cannot message @@ -86,7 +86,7 @@ class AChannel_R : public SimpleChannelModeHandler class AUser_R : public SimpleUserModeHandler { public: - AUser_R(InspIRCd* Instance, Module* Creator) : SimpleUserModeHandler(Creator, 'R') { } + AUser_R(Module* Creator) : SimpleUserModeHandler(Creator, "regdeaf", 'R') { } }; /** Channel mode +M - unidentified users cannot message channel @@ -94,7 +94,7 @@ class AUser_R : public SimpleUserModeHandler class AChannel_M : public SimpleChannelModeHandler { public: - AChannel_M(InspIRCd* Instance, Module* Creator) : SimpleChannelModeHandler(Instance, Creator, 'M') { } + AChannel_M(Module* Creator) : SimpleChannelModeHandler(Creator, "regmoderated", 'M') { } }; class ModuleServicesAccount : public Module @@ -104,10 +104,9 @@ class ModuleServicesAccount : public Module AUser_R m3; Channel_r m4; User_r m5; - StringExtItem accountname; + AccountExtItem accountname; public: - ModuleServicesAccount(InspIRCd* Me) : Module(Me), - m1(Me, this), m2(Me, this), m3(Me, this), m4(Me, this), m5(Me, this), + ModuleServicesAccount() : m1(this), m2(this), m3(this), m4(this), m5(this), accountname("accountname", this) { @@ -116,11 +115,11 @@ class ModuleServicesAccount : public Module !ServerInstance->Modes->AddMode(&m5)) throw ModuleException("Some other module has claimed our modes!"); - Extensible::Register(&accountname); + ServerInstance->Extensions.Register(&accountname); Implementation eventlist[] = { I_OnWhois, I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserPreJoin, I_OnCheckBan, - I_OnSyncUser, I_OnUserQuit, I_OnCleanup, I_OnDecodeMetaData, I_On005Numeric, I_OnUserPostNick }; + I_OnDecodeMetaData, I_On005Numeric, I_OnUserPostNick }; - ServerInstance->Modules->Attach(eventlist, this, 10); + ServerInstance->Modules->Attach(eventlist, this, 8); } void On005Numeric(std::string &t) @@ -174,8 +173,10 @@ class ModuleServicesAccount : public Module if (target_type == TYPE_CHANNEL) { Channel* c = (Channel*)dest; + ModResult res; + FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,c,"regmoderated")); - if (c->IsModeSet('M') && !is_registered) + if (c->IsModeSet('M') && !is_registered && res != MOD_RES_ALLOW) { // user messaging a +M channel and is not registered user->WriteNumeric(477, ""+std::string(user->nick)+" "+std::string(c->name)+" :You need to be identified to a registered account to message this channel"); @@ -254,36 +255,27 @@ class ModuleServicesAccount : public Module // check if its our metadata key, and its associated with a user if (dest && (extname == "accountname")) { - if (!extdata.empty()) + std::string *account = accountname.get(dest); + if (account && !account->empty()) { - std::string *account = accountname.get(dest); trim(*account); if (IS_LOCAL(dest)) dest->WriteNumeric(900, "%s %s %s :You are now logged in as %s", dest->nick.c_str(), dest->GetFullHost().c_str(), account->c_str(), account->c_str()); - AccountData ac; - ac.user = dest; - ac.account = *account; - Event n((char*)&ac, this, "account_login"); - n.Send(ServerInstance); + AccountEvent(this, dest, *account).Send(); } } } ~ModuleServicesAccount() { - ServerInstance->Modes->DelMode(&m1); - ServerInstance->Modes->DelMode(&m2); - ServerInstance->Modes->DelMode(&m3); - ServerInstance->Modes->DelMode(&m4); - ServerInstance->Modes->DelMode(&m5); } Version GetVersion() { - return Version("$Id$",VF_COMMON|VF_VENDOR,API_VERSION); + return Version("Povides support for ircu-style services accounts, including chmode +R, etc.",VF_COMMON|VF_VENDOR); } };