X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_callerid.cpp;h=416ede9a1ba8f05cb6381b9c5f975cb4aa29f439;hb=9539fa9d7bcb19100bd5b7f67d6f792e48fff909;hp=ae3ec1450a0bcdf206f1e6fb3986c9d9d3edd470;hpb=c4d6ce8c5e1802e5b834d5845e31c3adf7700585;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index ae3ec1450..416ede9a1 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -1,16 +1,25 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2008-2009 Robin Burchell + * Copyright (C) 2008 Thomas Stagner + * Copyright (C) 2008 Craig Edwards * - * This program is free but copyrighted software; see - * the file COPYING for details. + * 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 + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" #include #include @@ -18,7 +27,7 @@ /* $ModDesc: Implementation of callerid (umode +g & /accept, ala hybrid etc) */ -class callerid_data : public classbase +class callerid_data { public: time_t lastnotify; @@ -66,7 +75,6 @@ class callerid_data : public classbase // Encode UIDs. oss << "," << (format == FORMAT_USER ? u->nick : u->uuid); } - oss << std::ends; return oss.str(); } }; @@ -78,7 +86,7 @@ struct CallerIDExtInfo : public ExtensionItem { } - std::string serialize(SerializeFormat format, const Extensible* container, void* item) + std::string serialize(SerializeFormat format, const Extensible* container, void* item) const { callerid_data* dat = static_cast(item); return dat->ToString(format); @@ -93,7 +101,7 @@ struct CallerIDExtInfo : public ExtensionItem callerid_data* get(User* user, bool create) { callerid_data* dat = static_cast(get_raw(user)); - if (!dat) + if (create && !dat) { dat = new callerid_data; set_raw(user, dat); @@ -222,6 +230,11 @@ public: } } + RouteDescriptor GetRouting(User* user, const std::vector& parameters) + { + return ROUTE_BROADCAST; + } + void ListAccept(User* user) { callerid_data* dat = extInfo.get(user, false); @@ -344,13 +357,15 @@ private: public: ModuleCallerID() : cmd(this), myumode(this) { - OnRehash(NULL); + } - if (!ServerInstance->Modes->AddMode(&myumode)) - throw ModuleException("Could not add usermode +g"); + void init() + { + OnRehash(NULL); - ServerInstance->AddCommand(&cmd); - Extensible::Register(&cmd.extInfo); + ServerInstance->Modules->AddService(myumode); + ServerInstance->Modules->AddService(cmd); + ServerInstance->Modules->AddService(cmd.extInfo); Implementation eventlist[] = { I_OnRehash, I_OnUserPreNick, I_OnUserQuit, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage }; ServerInstance->Modules->Attach(eventlist, this, 6); @@ -362,7 +377,7 @@ public: virtual Version GetVersion() { - return Version("Implementation of callerid (umode +g & /accept, ala hybrid etc)", VF_COMMON | VF_VENDOR, API_VERSION); + return Version("Implementation of callerid (umode +g & /accept, ala hybrid etc)", VF_COMMON | VF_VENDOR); } virtual void On005Numeric(std::string& output) @@ -389,7 +404,7 @@ public: if (now > (dat->lastnotify + (time_t)notify_cooldown)) { user->WriteNumeric(717, "%s %s :has been informed that you messaged them.", user->nick.c_str(), dest->nick.c_str()); - ServerInstance->DumpText(dest, ":%s 718 %s %s %s@%s :is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.", + dest->SendText(":%s 718 %s %s %s@%s :is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.", ServerInstance->Config->ServerName.c_str(), dest->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), user->nick.c_str()); dat->lastnotify = now; }