]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_halfvoice.cpp
Restore <options:exemptchanops> with long names
[user/henk/code/inspircd.git] / src / modules / m_halfvoice.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: Provides channel mode +V, adding the - prefix
17  *  which does nothing but serves as a status symbol. */
18
19 #define HALFVOICE_VALUE 1
20
21 class HalfVoiceMode : public ModeHandler
22 {
23  public:
24         HalfVoiceMode(Module* parent) : ModeHandler(parent, "halfvoice", 'V', PARAM_ALWAYS, MODETYPE_CHANNEL)
25         {
26                 list = true;
27                 prefix = 0;
28                 levelrequired = HALFOP_VALUE;
29                 m_paramtype = TR_NICK;
30         }
31
32         void SetPrefix(char pfx) { prefix = pfx; }
33
34         unsigned int GetPrefixRank()
35         {
36                 return HALFVOICE_VALUE;
37         }
38
39         void RemoveMode(Channel* channel, irc::modestacker* stack)
40         {
41                 const UserMembList* cl = channel->GetUsers();
42                 std::vector<std::string> mode_junk;
43                 mode_junk.push_back(channel->name);
44                 irc::modestacker modestack(false);
45                 std::deque<std::string> stackresult;
46
47                 for (UserMembCIter i = cl->begin(); i != cl->end(); i++)
48                 {
49                         if (i->second->hasMode('V'))
50                         {
51                                 if (stack)
52                                         stack->Push(this->GetModeChar(), i->first->nick);
53                                 else
54                                         modestack.Push(this->GetModeChar(), i->first->nick);
55                         }
56                 }
57
58                 if (stack)
59                         return;
60
61                 while (modestack.GetStackedLine(stackresult))
62                 {
63                         mode_junk.insert(mode_junk.end(), stackresult.begin(), stackresult.end());
64                         ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);
65                         mode_junk.erase(mode_junk.begin() + 1, mode_junk.end());
66                 }
67         }
68
69         void RemoveMode(User* user, irc::modestacker* stack)
70         {
71         }
72
73         ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
74         {
75                 return MODEACTION_ALLOW;
76         }
77 };
78
79 class ModuleHalfVoice : public Module
80 {
81         HalfVoiceMode mh;
82
83  public:
84         ModuleHalfVoice() : mh(this)
85         {
86         }
87
88         void init()
89         {
90                 ConfigTag* tag = ServerInstance->Config->ConfValue("halfvoice");
91                 std::string pfxchar = tag->getString("prefix", "-");
92                 mh.SetPrefix(pfxchar[0]);
93                 ServerInstance->Modules->AddService(mh);
94         }
95
96         Version GetVersion()
97         {
98                 return Version("Provides a channel mode that does nothing but serve as a status symbol", VF_VENDOR);
99         }
100 };
101
102 MODULE_INIT(ModuleHalfVoice)