]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_conn_join.cpp
Allow <connect autojoin=""> to override the m_conn_join channel list
[user/henk/code/inspircd.git] / src / modules / m_conn_join.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 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: Forces users to join the specified channel(s) on connect */
17
18 class ModuleConnJoin : public Module
19 {
20         public:
21                 void init()
22                 {
23                         Implementation eventlist[] = { I_OnPostConnect };
24                         ServerInstance->Modules->Attach(eventlist, this, 1);
25                 }
26
27                 void Prioritize()
28                 {
29                         ServerInstance->Modules->SetPriority(this, I_OnPostConnect, PRIORITY_LAST);
30                 }
31
32                 Version GetVersion()
33                 {
34                         return Version("Forces users to join the specified channel(s) on connect", VF_VENDOR);
35                 }
36
37                 void OnPostConnect(User* user)
38                 {
39                         if (!IS_LOCAL(user))
40                                 return;
41
42                         std::string chanlist = ServerInstance->Config->ConfValue("autojoin")->getString("channel");
43                         chanlist = user->GetClass()->config->getString("autojoin", chanlist);
44
45                         irc::commasepstream chans(chanlist);
46                         std::string chan;
47
48                         while (chans.GetToken(chan))
49                         {
50                                 if (ServerInstance->IsChannel(chan.c_str(), ServerInstance->Config->Limits.ChanMax))
51                                         Channel::JoinUser(user, chan.c_str(), false, "", false, ServerInstance->Time());
52                         }
53                 }
54 };
55
56
57 MODULE_INIT(ModuleConnJoin)