diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-08-04 15:28:29 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-08-04 15:28:29 +0000 |
commit | 904161fdba32468ff4d97d9533e62809131ed1a2 (patch) | |
tree | 77c35abdd8fdc34c6c63ca7d531aa2222781f08a /src/channels.cpp | |
parent | 83c6918cfa416e8bf65a48973fe6b726d825e069 (diff) |
Add Channel::SetTopic(User *, std::string &) to set topic on a channel. Use it in CommandTopic. Also modify OnLocalTopicChange to accept a new return value. (0 == proceed as normal, 1 == don't check anything, -1 == disallow change silently).
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10082 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/channels.cpp')
-rw-r--r-- | src/channels.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 9da94b4bf..19cfccc79 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -73,6 +73,45 @@ std::string Channel::GetModeParameter(char mode) return ""; } +int Channel::SetTopic(User *u, std::string &ntopic) +{ + if (IS_LOCAL(u)) + { + int MOD_RESULT = 0; + /* 0: check status, 1: don't, -1: disallow change silently */ + + FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(u,this,ntopic)); + if (MOD_RESULT == -1) + return CMD_FAILURE; + else if (MOD_RESULT == 0) + { + if (!this->HasUser(u)) + { + u->WriteNumeric(442, "%s %s :You're not on that channel!",u->nick.c_str(), this->name.c_str()); + return CMD_FAILURE; + } + if ((this->IsModeSet('t')) && (this->GetStatus(u) < STATUS_HOP)) + { + u->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", u->nick.c_str(), this->name.c_str()); + return CMD_FAILURE; + } + } + + this->topic.assign(ntopic, 0, ServerInstance->Config->Limits.MaxTopic); + } + + this->setby.assign(ServerInstance->Config->FullHostInTopic ? u->GetFullHost() : u->nick, 0, 128); + this->topicset = ServerInstance->Time(); + this->WriteChannel(u, "TOPIC %s :%s", this->name.c_str(), this->topic.c_str()); + + if (IS_LOCAL(u)) + { + FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(u, this, this->topic)); + } + + return CMD_SUCCESS; +} + long Channel::GetUserCounter() { return (this->internal_userlist.size()); |