forked from inspircd/inspircd-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fc1d3e
commit cf9b1d0
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |