Skip to content

Commit

Permalink
Add invite-notify to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- authored and attilamolnar committed May 21, 2013
1 parent 8fc1d3e commit cf9b1d0
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions 2.0/m_invitenotify.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
* Copyright (C) 2013 Adam <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/

/* $ModAuthor: Adam */
/* $ModAuthorMail: [email protected] */
/* $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)

0 comments on commit cf9b1d0

Please sign in to comment.