1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/* cs_appendtopic.c - Add text to a channels topic
*
* (C) 2003-2010 Anope Team
* Contact us at team@anope.org
*
* Based on the original module by SGR <Alex_SGR@ntlworld.com>
* Included in the Anope module pack since Anope 1.7.9
* Anope Coder: GeniusDex <geniusdex@anope.org>
*
* Please read COPYING and README for further details.
*
* Send bug reports to the Anope Coder instead of the module
* author, because any changes since the inclusion into anope
* are not supported by the original author.
*/
/*************************************************************************/
#include "module.h"
#define AUTHOR "SGR"
/* ------------------------------------------------------------
* Name: cs_appendtopic
* Author: SGR <Alex_SGR@ntlworld.com>
* Date: 31/08/2003
* ------------------------------------------------------------
*
* This module has no configurable options. For information on
* this module, load it and refer to /ChanServ APPENDTOPIC HELP
*
* Thanks to dengel, Rob and Certus for all there support.
* Especially Rob, who always manages to show me where I have
* not allocated any memory. Even if it takes a few weeks of
* pestering to get him to look at it.
*
* ------------------------------------------------------------
*/
/* ---------------------------------------------------------------------- */
/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */
/* ---------------------------------------------------------------------- */
static Module *me;
class CommandCSAppendTopic : public Command
{
public:
CommandCSAppendTopic() : Command("APPENDTOPIC", 2, 2)
{
}
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
{
const Anope::string &newtopic = params[1];
User *u = source.u;
ChannelInfo *ci = source.ci;
Channel *c = ci->c;
if (!c)
u->SendMessage(ChanServ, CHAN_X_NOT_IN_USE, ci->name.c_str());
else if (!check_access(u, ci, CA_TOPIC))
u->SendMessage(ChanServ, ACCESS_DENIED);
else
{
Anope::string topic;
if (!ci->last_topic.empty())
{
topic = ci->last_topic + " " + newtopic;
ci->last_topic.clear();
}
else
topic = newtopic;
bool has_topiclock = ci->HasFlag(CI_TOPICLOCK);
ci->UnsetFlag(CI_TOPICLOCK);
c->ChangeTopic(u->nick, topic, Anope::CurTime);
if (has_topiclock)
ci->SetFlag(CI_TOPICLOCK);
bool override = !check_access(u, ci, CA_TOPIC);
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "changed topic to " << topic;
}
return MOD_CONT;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
me->SendMessage(source, _("Syntax: APPENDTOPIC channel text"));
source.Reply(" ");
me->SendMessage(source, _("This command allows users to append text to a currently set\n"
"channel topic. When TOPICLOCK is on, the topic is updated and\n"
"the new, updated topic is locked."));
return true;
}
void OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
{
me->SendMessage(source, _("Syntax: APPENDTOPIC channel text"));
}
void OnServHelp(CommandSource &source)
{
me->SendMessage(source, _(" APPENDTOPIC Add text to a channels topic"));
}
};
class CSAppendTopic : public Module
{
CommandCSAppendTopic commandcsappendtopic;
public:
CSAppendTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
me = this;
this->SetAuthor(AUTHOR);
this->SetType(SUPPORTED);
this->AddCommand(ChanServ, &commandcsappendtopic);
}
};
MODULE_INIT(CSAppendTopic)
|