X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules%2Fm_codepage.cpp;h=45fdb3d834ae02e2b312c2c5b68403cdba7a3dbd;hb=c7b938502295ddc5b2c89e0854d8c5c19ede32dc;hp=9fd012ffe80ab118f064fdf5ada264622c2695c4;hpb=34e33342d548f3ecaff791f526786b39318b7437;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp index 9fd012ffe..45fdb3d83 100644 --- a/src/modules/m_codepage.cpp +++ b/src/modules/m_codepage.cpp @@ -2,7 +2,6 @@ * InspIRCd -- Internet Relay Chat Daemon * * Copyright (C) 2020 Sadie Powell - * Copyright (C) 2014 Googolplexed * * This file is part of InspIRCd. InspIRCd is free software: you can * redistribute it and/or modify it under the terms of the GNU General Public @@ -77,6 +76,21 @@ class ModuleCodepage hashmap.swap(newhash); } + void CheckDuplicateNick() + { + insp::flat_set duplicates; + const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); + for (UserManager::LocalList::const_iterator iter = list.begin(); iter != list.end(); ++iter) + { + LocalUser* user = *iter; + if (user->nick != user->uuid && !duplicates.insert(user->nick).second) + { + user->WriteNumeric(RPL_SAVENICK, user->uuid, "Your nickname is no longer available."); + user->ChangeNick(user->uuid); + } + } + } + void CheckInvalidNick() { const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); @@ -84,7 +98,10 @@ class ModuleCodepage { LocalUser* user = *iter; if (user->nick != user->uuid && !ServerInstance->IsNick(user->nick)) + { + user->WriteNumeric(RPL_SAVENICK, user->uuid, "Your nickname is no longer valid."); user->ChangeNick(user->uuid); + } } } @@ -113,6 +130,7 @@ class ModuleCodepage ServerInstance->Config->CaseMapping = origcasemapname; national_case_insensitive_map = origcasemap; + CheckDuplicateNick(); CheckRehash(casemap); ServerInstance->ISupport.Build(); @@ -134,7 +152,7 @@ class ModuleCodepage unsigned char begin = tag->getUInt("begin", tag->getUInt("index", 0), 1, UCHAR_MAX); if (!begin) throw ModuleException(" tag without index or begin specified at " + tag->getTagLocation()); - + unsigned char end = tag->getUInt("end", begin, 1, UCHAR_MAX); if (begin > end) throw ModuleException(" must be lower than at " + tag->getTagLocation()); @@ -215,7 +233,7 @@ class ModuleCodepage if (casemap[i] != i) linkdata << static_cast(i) << casemap[i] << ','; - return Version("Provides support for custom 8-bit codepages", VF_COMMON | VF_VENDOR, linkdata.str()); + return Version("Allows the server administrator to define what characters are allowed in nicknames and how characters should be compared in a case insensitive way.", VF_COMMON | VF_VENDOR, linkdata.str()); } }; MODULE_INIT(ModuleCodepage)