Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "module.h"
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 class CommandCSAppendTopic : public Command
00043 {
00044 public:
00045 CommandCSAppendTopic(Module *creator) : Command(creator, "chanserv/appendtopic", 2, 2)
00046 {
00047 this->SetDesc(_("Add text to a channels topic"));
00048 this->SetSyntax(_("\037channel\037 \037text\037"));
00049 }
00050
00051 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00052 {
00053 const Anope::string &newtopic = params[1];
00054
00055 Channel *c = Channel::Find(params[0]);;
00056
00057 if (!c)
00058 source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
00059 else if (!c->ci)
00060 source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str());
00061 else if (!source.AccessFor(c->ci).HasPriv("TOPIC") && !source.HasCommand("chanserv/topic"))
00062 source.Reply(ACCESS_DENIED);
00063 else
00064 {
00065 Anope::string topic;
00066 if (!c->ci->last_topic.empty())
00067 {
00068 topic = c->ci->last_topic + " " + newtopic;
00069 c->ci->last_topic.clear();
00070 }
00071 else
00072 topic = newtopic;
00073
00074 bool has_topiclock = c->ci->HasFlag(CI_TOPICLOCK);
00075 c->ci->UnsetFlag(CI_TOPICLOCK);
00076 c->ChangeTopic(source.GetNick(), topic, Anope::CurTime);
00077 if (has_topiclock)
00078 c->ci->SetFlag(CI_TOPICLOCK);
00079
00080 bool override = !source.AccessFor(c->ci).HasPriv("TOPIC");
00081 Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to append: " << topic;
00082 }
00083 return;
00084 }
00085
00086 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00087 {
00088 this->SendSyntax(source);
00089 source.Reply(" ");
00090 source.Reply(_("This command allows users to append text to a currently set\n"
00091 "channel topic. When TOPICLOCK is on, the topic is updated and\n"
00092 "the new, updated topic is locked."));
00093
00094 return true;
00095 }
00096 };
00097
00098 class CSAppendTopic : public Module
00099 {
00100 CommandCSAppendTopic commandcsappendtopic;
00101
00102 public:
00103 CSAppendTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00104 commandcsappendtopic(this)
00105 {
00106 this->SetAuthor("SGR");
00107
00108 }
00109 };
00110
00111 MODULE_INIT(CSAppendTopic)