From cf9b1d041f8c8bf5917f67d90470dfc4cb800d43 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 19 May 2013 16:12:51 -0400 Subject: [PATCH] Add invite-notify to 2.0 --- 2.0/m_invitenotify.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 2.0/m_invitenotify.cpp diff --git a/2.0/m_invitenotify.cpp b/2.0/m_invitenotify.cpp new file mode 100644 index 00000000..c8d8b0d9 --- /dev/null +++ b/2.0/m_invitenotify.cpp @@ -0,0 +1,67 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2013 Adam + * + * 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 . + */ + +/* $ModAuthor: Adam */ +/* $ModAuthorMail: Adam@anope.org */ +/* $ModDesc: Implements invite-notify */ +/* $ModDepends: core 2.0 */ + +#include "inspircd.h" +#include "m_cap.h" + +class ModuleInviteNotify : public Module +{ + GenericCap invite_notify; + + public: + ModuleInviteNotify() : invite_notify(this, "invite-notify") + { + } + + void init() + { + Implementation eventlist[] = { I_OnEvent, I_OnUserInvite }; + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist) / sizeof(Implementation)); + } + + Version GetVersion() + { + return Version("Implements invite-notify"); + } + + void OnEvent(Event& ev) + { + this->invite_notify.HandleEvent(ev); + } + + void OnUserInvite(User* source, User* dest, Channel* channel, time_t) + { + const UserMembList* cl = channel->GetUsers(); + for (UserMembCIter it = cl->begin(); it != cl->end(); ++it) + { + User* u = it->first; + + if (u == source || u == dest || !this->invite_notify.ext.get(u)) + continue; + + u->WriteFrom(source, "INVITE " + dest->nick + " :" + channel->name); + } + } +}; + +MODULE_INIT(ModuleInviteNotify)