]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chancreate.cpp
Update all wiki links to point to the new wiki. This was done automatically with...
[user/henk/code/inspircd.git] / src / modules / m_chancreate.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: Creates a snomask with notices whenever a new channel is created */
17
18 class ModuleChanCreate : public Module
19 {
20  private:
21  public:
22         ModuleChanCreate(InspIRCd* Me)
23                 : Module(Me)
24         {
25                 ServerInstance->SNO->EnableSnomask('j', "CHANCREATE");
26                 ServerInstance->SNO->EnableSnomask('J', "REMOTECHANCREATE");
27                 Implementation eventlist[] = { I_OnUserJoin };
28                 ServerInstance->Modules->Attach(eventlist, this, 1);
29         }
30
31         virtual ~ModuleChanCreate()
32         {
33                 ServerInstance->SNO->DisableSnomask('j');
34                 ServerInstance->SNO->DisableSnomask('J');
35         }
36
37         virtual Version GetVersion()
38         {
39                 return Version("$Id$",VF_VENDOR,API_VERSION);
40         }
41
42
43         virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
44         {
45                 if (channel->GetUserCounter() == 1 && !channel->IsModeSet('P'))
46                 {
47                         if (IS_LOCAL(user))
48                                 ServerInstance->SNO->WriteToSnoMask('j', "Channel %s created by %s!%s@%s", channel->name.c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str());
49                         else
50                                 ServerInstance->SNO->WriteToSnoMask('J', "Channel %s created by %s!%s@%s", channel->name.c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str());
51                 }
52         }
53 };
54
55 MODULE_INIT(ModuleChanCreate)