]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_satopic.cpp
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / src / modules / m_satopic.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 /* $ModDesc: Provides a SATOPIC command */
15
16 #include "inspircd.h"
17
18 /** Handle /SATOPIC
19  */
20 class CommandSATopic : public Command
21 {
22  public:
23         CommandSATopic(Module* Creator) : Command(Creator,"SATOPIC", 2, 2)
24         {
25                 flags_needed = 'o'; Penalty = 0; syntax = "<target> <topic>";
26         }
27
28         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
29         {
30                 /*
31                  * Handles a SATOPIC request. Notifies all +s users.
32                  */
33                 Channel* target = ServerInstance->FindChan(parameters[0]);
34
35                 if(target)
36                 {
37                         std::string newTopic = parameters[1];
38
39                         // 3rd parameter overrides access checks
40                         target->SetTopic(user, newTopic, true);
41                         ServerInstance->SNO->WriteToSnoMask('a', user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
42                         ServerInstance->PI->SendSNONotice("A", user->nick + " used SATOPIC on " + target->name + ", new topic: " + newTopic);
43
44                         return CMD_SUCCESS;
45                 }
46                 else
47                 {
48                         user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
49                         return CMD_FAILURE;
50                 }
51         }
52 };
53
54 class ModuleSATopic : public Module
55 {
56         CommandSATopic cmd;
57  public:
58         ModuleSATopic()
59         : cmd(this)
60         {
61                 ServerInstance->AddCommand(&cmd);
62         }
63
64         virtual ~ModuleSATopic()
65         {
66         }
67
68         virtual Version GetVersion()
69         {
70                 return Version("Provides a SATOPIC command", VF_VENDOR, API_VERSION);
71         }
72 };
73
74 MODULE_INIT(ModuleSATopic)