summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 14:17:35 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-08 14:17:35 +0000
commit6ab1d0dffb8084bf6a2ad8a446a3836fa3760c8a (patch)
treeb29d44792a86a243693034a83326c17b847ecfdc
parent903ba4e2ebf608737e1890cfa43c3e92a9ec2cf4 (diff)
WriteChannel* functions and ChanExceptSender* functions are now methods of chanrec. They probably should be renamed too eventually.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4788 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/channels.h7
-rw-r--r--include/globals.h2
-rw-r--r--include/helperfuncs.h8
-rw-r--r--include/modules.h22
-rw-r--r--src/channels.cpp118
-rw-r--r--src/cmd_notice.cpp2
-rw-r--r--src/cmd_privmsg.cpp2
-rw-r--r--src/cmd_topic.cpp3
-rw-r--r--src/helperfuncs.cpp239
-rw-r--r--src/mode.cpp4
-rw-r--r--src/modules.cpp33
-rw-r--r--src/modules/m_joinflood.cpp2
-rw-r--r--src/modules/m_knock.cpp2
-rw-r--r--src/modules/m_messageflood.cpp2
-rw-r--r--src/modules/m_override.cpp6
-rw-r--r--src/modules/m_remove.cpp2
-rw-r--r--src/modules/m_spanningtree.cpp4
-rw-r--r--src/modules/m_timedbans.cpp4
-rw-r--r--src/modules/m_uninvite.cpp2
19 files changed, 136 insertions, 328 deletions
diff --git a/include/channels.h b/include/channels.h
index effb65873..82a955069 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -327,6 +327,13 @@ class chanrec : public Extensible
*/
static chanrec* JoinUser(userrec *user, const char* cn, bool override, const char* key = "");
+ void WriteChannel(userrec* user, char* text, ...);
+ void WriteChannel(userrec* user, const std::string &text);
+ void WriteChannelWithServ(const char* ServName, const char* text, ...);
+ void WriteChannelWithServ(const char* ServName, const std::string &text);
+ void WriteAllExceptSender(userrec* user, char status, char* text, ...);
+ void WriteAllExceptSender(userrec* user, char status, const std::string& text);
+
/** Destructor for chanrec
*/
virtual ~chanrec() { /* stub */ }
diff --git a/include/globals.h b/include/globals.h
index ce6bde09f..ea09f4227 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -37,8 +37,6 @@ void Write(int sock,char *text, ...);
void WriteServ(int sock, char* text, ...);
void WriteFrom(int sock, userrec *user,char* text, ...);
void WriteTo(userrec *source, userrec *dest,char *data, ...);
-void WriteChannel(chanrec* Ptr, userrec* user, char* text, ...);
-void ChanExceptSender(chanrec* Ptr, userrec* user, char* text, ...);
int common_channels(userrec *u, userrec *u2);
void WriteCommon(userrec *u, char* text, ...);
void WriteCommonExcept(userrec *u, char* text, ...);
diff --git a/include/helperfuncs.h b/include/helperfuncs.h
index 2fa47bffe..0ef5d4691 100644
--- a/include/helperfuncs.h
+++ b/include/helperfuncs.h
@@ -52,10 +52,6 @@ void Write(int sock,char *text, ...);
void WriteServ(int sock, char* text, ...);
void WriteFrom(int sock, userrec *user,char* text, ...);
void WriteTo(userrec *source, userrec *dest,char *data, ...);
-void WriteChannel(chanrec* Ptr, userrec* user, char* text, ...);
-void WriteChannelLocal(chanrec* Ptr, userrec* user, char* text, ...);
-void WriteChannelWithServ(const char* ServName, chanrec* Ptr, const char* text, ...);
-void ChanExceptSender(chanrec* Ptr, userrec* user, char status, char* text, ...);
void WriteCommon(userrec *u, char* text, ...);
void WriteCommonExcept(userrec *u, char* text, ...);
void WriteOpers(const char* text, ...);
@@ -64,10 +60,6 @@ void Write_NoFormat(int sock,const char *text);
void WriteServ_NoFormat(int sock, const char* text);
void WriteFrom_NoFormat(int sock, userrec *user,const char* text);
void WriteTo_NoFormat(userrec *source, userrec *dest,const char *data);
-void WriteChannel_NoFormat(chanrec* Ptr, userrec* user, const char* text);
-void WriteChannelLocal_NoFormat(chanrec* Ptr, userrec* user, const char* text);
-void WriteChannelWithServ_NoFormat(const char* ServName, chanrec* Ptr, const char* text);
-void ChanExceptSender_NoFormat(chanrec* Ptr, userrec* user, char status, const char* text);
void WriteCommon_NoFormat(userrec *u, const char* text);
void WriteCommonExcept_NoFormat(userrec *u, const char* text);
void WriteOpers_NoFormat(const char* text);
diff --git a/include/modules.h b/include/modules.h
index ebd810c41..93d911959 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1339,11 +1339,6 @@ class Server : public Extensible
*/
virtual void SendServ(int Socket, const std::string &s);
- /** Writes text to a channel, but from a server, including all.
- * This can be used to send server notices to a group of users.
- */
- virtual void SendChannelServerNotice(const std::string &ServName, chanrec* Channel, const std::string &text);
-
/** Sends text from a user to a socket.
* This method writes a line of text to an established socket, with the given user's nick/ident
* /host combination prepended, as used in PRIVSG etc commands (see RFC 1459)
@@ -1366,14 +1361,6 @@ class Server : public Extensible
*/
virtual void SendTo(userrec* Source, userrec* Dest, const std::string &s);
- /** Sends text from a user to a channel (mulicast).
- * This method writes a line of text to a channel, with the given user's nick/ident
- * /host combination prepended, as used in PRIVMSG etc commands (see RFC 1459). If the
- * IncludeSender flag is set, then the text is also sent back to the user from which
- * it originated, as seen in MODE (see RFC 1459).
- */
- virtual void SendChannel(userrec* User, chanrec* Channel, const std::string &s, bool IncludeSender);
-
/** Returns true if two users share a common channel.
* This method is used internally by the NICK and QUIT commands, and the Server::SendCommon
* method.
@@ -1531,15 +1518,6 @@ class Server : public Extensible
* action after calling this method is to immediately bail from your handler.
*/
virtual void QuitUser(userrec* user, const std::string &reason);
-
- /** Makes a user kick another user, with the specified reason.
- * If source is NULL, the server will peform the kick.
- * @param The person or server (if NULL) performing the KICK
- * @param target The person being kicked
- * @param chan The channel to kick from
- * @param reason The kick reason
- */
- virtual void KickUser(userrec* source, userrec* target, chanrec* chan, const std::string &reason);
/** Matches text against a glob pattern.
* Uses the ircd's internal matching function to match string against a globbing pattern, e.g. *!*@*.com
diff --git a/src/channels.cpp b/src/channels.cpp
index caae1a714..5fcf63148 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -21,6 +21,7 @@ using namespace std;
#include <sstream>
#include <vector>
#include <deque>
+#include <stdarg.h>
#include "configreader.h"
#include "inspircd.h"
#include "hash_map.h"
@@ -344,7 +345,7 @@ chanrec* chanrec::JoinUser(userrec *user, const char* cn, bool override, const c
{
/* This allows CIDR ban matching
*
- * Full masked host Full unmasked host IP with/without CIDR
+ * Full masked host Full unmasked host IP with/without CIDR
*/
if ((match(user->GetFullHost(),i->data)) || (match(user->GetFullRealHost(),i->data)) || (match(mask, i->data, true)))
{
@@ -446,7 +447,7 @@ chanrec* chanrec::ForceChan(chanrec* Ptr,ucrec *a,userrec* user, int created)
a->channel = Ptr;
Ptr->AddUser(user);
- WriteChannel(Ptr,user,"JOIN :%s",Ptr->name);
+ Ptr->WriteChannel(user,"JOIN :%s",Ptr->name);
/* Major improvement by Brain - we dont need to be calculating all this pointlessly for remote users */
if (IS_LOCAL(user))
@@ -481,12 +482,12 @@ long chanrec::PartUser(userrec *user, const char* reason)
if (reason)
{
FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, reason));
- WriteChannel(this, user, "PART %s :%s", this->name, reason);
+ this->WriteChannel(user, "PART %s :%s", this->name, reason);
}
else
{
FOREACH_MOD(I_OnUserPart,OnUserPart(user, this, ""));
- WriteChannel(this, user, "PART :%s", this->name);
+ this->WriteChannel(user, "PART :%s", this->name);
}
user->chans[i]->uc_modes = 0;
user->chans[i]->channel = NULL;
@@ -533,7 +534,7 @@ long chanrec::ServerKickUser(userrec* user, const char* reason, bool triggereven
{
if (user->chans[i]->channel == this)
{
- WriteChannelWithServ(Config->ServerName,this,"KICK %s %s :%s",this->name, user->nick, reason);
+ this->WriteChannelWithServ(Config->ServerName, "KICK %s %s :%s", this->name, user->nick, reason);
user->chans[i]->uc_modes = 0;
user->chans[i]->channel = NULL;
break;
@@ -567,7 +568,7 @@ long chanrec::KickUser(userrec *src, userrec *user, const char* reason)
WriteServ(src->fd,"441 %s %s %s :They are not on that channel",src->nick, user->nick, this->name);
return this->GetUserCounter();
}
- if ((is_uline(user->server)) && (!is_uline(src->server)))
+ if ((is_uline(user->server)) && (!is_uline(src->server)))
{
WriteServ(src->fd,"482 %s %s :Only a u-line may kick a u-line from a channel.",src->nick, this->name);
return this->GetUserCounter();
@@ -615,7 +616,7 @@ long chanrec::KickUser(userrec *src, userrec *user, const char* reason)
/* zap it from the channel list of the user */
if ((*i)->channel == this)
{
- WriteChannel(this,src,"KICK %s %s :%s",this->name, user->nick, reason);
+ this->WriteChannel(src, "KICK %s %s :%s", this->name, user->nick, reason);
(*i)->uc_modes = 0;
(*i)->channel = NULL;
break;
@@ -638,3 +639,106 @@ long chanrec::KickUser(userrec *src, userrec *user, const char* reason)
return this->GetUserCounter();
}
+
+void chanrec::WriteChannel(userrec* user, char* text, ...)
+{
+ char textbuffer[MAXBUF];
+ va_list argsPtr;
+
+ if (!user || !text)
+ return;
+
+ va_start(argsPtr, text);
+ vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+
+ this->WriteChannel(user, std::string(textbuffer));
+}
+
+void chanrec::WriteChannel(userrec* user, const std::string &text)
+{
+ CUList *ulist = this->GetUsers();
+
+ if (!user)
+ return;
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if (i->second->fd != FD_MAGIC_NUMBER)
+ WriteTo_NoFormat(user,i->second,text.c_str());
+ }
+}
+
+void chanrec::WriteChannelWithServ(const char* ServName, const char* text, ...)
+{
+ char textbuffer[MAXBUF];
+ va_list argsPtr;
+
+ if (!text)
+ return;
+
+ va_start(argsPtr, text);
+ vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+
+ this->WriteChannelWithServ(ServName, std::string(textbuffer));
+}
+
+void chanrec::WriteChannelWithServ(const char* ServName, const std::string &text)
+{
+ CUList *ulist = this->GetUsers();
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if (IS_LOCAL(i->second))
+ WriteServ_NoFormat(i->second->fd,text.c_str());
+ }
+}
+
+/* write formatted text from a source user to all users on a channel except
+ * for the sender (for privmsg etc) */
+void chanrec::WriteAllExceptSender(userrec* user, char status, char* text, ...)
+{
+ char textbuffer[MAXBUF];
+ va_list argsPtr;
+
+ if (!user || !text)
+ return;
+
+ va_start(argsPtr, text);
+ vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+
+ this->WriteAllExceptSender(user, status, std::string(textbuffer));
+}
+
+void chanrec::WriteAllExceptSender(userrec* user, char status, const std::string& text)
+{
+ CUList *ulist;
+
+ if (!user)
+ return;
+
+ switch (status)
+ {
+ case '@':
+ ulist = this->GetOppedUsers();
+ break;
+ case '%':
+ ulist = this->GetHalfoppedUsers();
+ break;
+ case '+':
+ ulist = this->GetVoicedUsers();
+ break;
+ default:
+ ulist = this->GetUsers();
+ break;
+ }
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ if ((IS_LOCAL(i->second)) && (user != i->second))
+ WriteFrom_NoFormat(i->second->fd,user,text.c_str());
+ }
+}
+
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index fbbeafec0..378c48f1e 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -102,7 +102,7 @@ void cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
return;
}
- ChanExceptSender(chan, user, status, "NOTICE %s :%s", chan->name, parameters[1]);
+ chan->WriteAllExceptSender(user, status, "NOTICE %s :%s", chan->name, parameters[1]);
FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,parameters[1],status));
}
diff --git a/src/cmd_privmsg.cpp b/src/cmd_privmsg.cpp
index 1218eca39..07b39e96a 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -99,7 +99,7 @@ void cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
return;
}
- ChanExceptSender(chan, user, status, "PRIVMSG %s :%s", chan->name, parameters[1]);
+ chan->WriteAllExceptSender(user, status, "PRIVMSG %s :%s", chan->name, parameters[1]);
FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,chan,TYPE_CHANNEL,parameters[1],status));
}
else
diff --git a/src/cmd_topic.cpp b/src/cmd_topic.cpp
index 4bfa608b4..e8784e318 100644
--- a/src/cmd_topic.cpp
+++ b/src/cmd_topic.cpp
@@ -91,7 +91,7 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
strlcpy(Ptr->topic,topic,MAXTOPIC-1);
strlcpy(Ptr->setby,user->nick,NICKMAX-1);
Ptr->topicset = TIME;
- WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
+ Ptr->WriteChannel(user, "TOPIC %s :%s", Ptr->name, Ptr->topic);
if (IS_LOCAL(user))
{
FOREACH_MOD(I_OnPostLocalTopicChange,OnPostLocalTopicChange(user,Ptr,topic));
@@ -103,3 +103,4 @@ void cmd_topic::Handle (const char** parameters, int pcnt, userrec *user)
}
}
}
+
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 1ebf89008..e7ecb56a1 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -428,245 +428,6 @@ void WriteTo_NoFormat(userrec *source, userrec *dest, const char *data)
}
}
-/* write formatted text from a source user to all users on a channel
- * including the sender (NOT for privmsg, notice etc!) */
-
-void WriteChannel(chanrec* Ptr, userrec* user, char* text, ...)
-{
- char textbuffer[MAXBUF];
- va_list argsPtr;
- CUList *ulist;
-
- if ((!Ptr) || (!user) || (!text))
- {
- log(DEFAULT,"*** BUG *** WriteChannel was given an invalid parameter");
- return;
- }
-
- va_start(argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
-
- ulist = Ptr->GetUsers();
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if (i->second->fd != FD_MAGIC_NUMBER)
- WriteTo_NoFormat(user,i->second,textbuffer);
- }
-}
-
-void WriteChannel_NoFormat(chanrec* Ptr, userrec* user, const char* text)
-{
- CUList *ulist;
-
- if ((!Ptr) || (!user) || (!text))
- {
- log(DEFAULT,"*** BUG *** WriteChannel was given an invalid parameter");
- return;
- }
-
- ulist = Ptr->GetUsers();
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if (i->second->fd != FD_MAGIC_NUMBER)
- WriteTo_NoFormat(user,i->second,text);
- }
-}
-
-
-/* write formatted text from a source user to all users on a channel
- * including the sender (NOT for privmsg, notice etc!) doesnt send to
- * users on remote servers */
-
-void WriteChannelLocal(chanrec* Ptr, userrec* user, char* text, ...)
-{
- char textbuffer[MAXBUF];
- va_list argsPtr;
- CUList *ulist;
-
- if ((!Ptr) || (!text))
- {
- log(DEFAULT,"*** BUG *** WriteChannel was given an invalid parameter");
- return;
- }
-
- va_start(argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
-
- ulist = Ptr->GetUsers();
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if ((i->second->fd != FD_MAGIC_NUMBER) && (i->second != user))
- {
- if (!user)
- {
- WriteServ_NoFormat(i->second->fd,textbuffer);
- }
- else
- {
- WriteTo_NoFormat(user,i->second,textbuffer);
- }
- }
- }
-}
-
-void WriteChannelLocal_NoFormat(chanrec* Ptr, userrec* user, const char* text)
-{
- CUList *ulist;
-
- if ((!Ptr) || (!text))
- {
- log(DEFAULT,"*** BUG *** WriteChannel was given an invalid parameter");
- return;
- }
-
- ulist = Ptr->GetUsers();
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if ((i->second->fd != FD_MAGIC_NUMBER) && (i->second != user))
- {
- if (!user)
- {
- WriteServ_NoFormat(i->second->fd,text);
- }
- else
- {
- WriteTo_NoFormat(user,i->second,text);
- }
- }
- }
-}
-
-
-
-void WriteChannelWithServ(const char* ServName, chanrec* Ptr, const char* text, ...)
-{
- char textbuffer[MAXBUF];
- va_list argsPtr;
- CUList *ulist;
-
- if ((!Ptr) || (!text))
- {
- log(DEFAULT,"*** BUG *** WriteChannelWithServ was given an invalid parameter");
- return;
- }
-
- va_start(argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
-
- ulist = Ptr->GetUsers();
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if (IS_LOCAL(i->second))
- WriteServ_NoFormat(i->second->fd,textbuffer);
- }
-}
-
-void WriteChannelWithServ_NoFormat(const char* ServName, chanrec* Ptr, const char* text)
-{
- CUList *ulist;
-
- if ((!Ptr) || (!text))
- {
- log(DEFAULT,"*** BUG *** WriteChannelWithServ was given an invalid parameter");
- return;
- }
-
- ulist = Ptr->GetUsers();
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if (IS_LOCAL(i->second))
- WriteServ_NoFormat(i->second->fd,text);
- }
-}
-
-
-
-/* write formatted text from a source user to all users on a channel except
- * for the sender (for privmsg etc) */
-
-void ChanExceptSender(chanrec* Ptr, userrec* user, char status, char* text, ...)
-{
- char textbuffer[MAXBUF];
- va_list argsPtr;
- CUList *ulist;
-
- if ((!Ptr) || (!user) || (!text))
- {
- log(DEFAULT,"*** BUG *** ChanExceptSender was given an invalid parameter");
- return;
- }
-
- va_start(argsPtr, text);
- vsnprintf(textbuffer, MAXBUF, text, argsPtr);
- va_end(argsPtr);
-
- switch (status)
- {
- case '@':
- ulist = Ptr->GetOppedUsers();
- break;
- case '%':
- ulist = Ptr->GetHalfoppedUsers();
- break;
- case '+':
- ulist = Ptr->GetVoicedUsers();
- break;
- default:
- ulist = Ptr->GetUsers();
- break;
- }
-
- log(DEBUG,"%d users to write to",ulist->size());
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if ((IS_LOCAL(i->second)) && (user != i->second))
- WriteFrom_NoFormat(i->second->fd,user,textbuffer);
- }
-}
-
-void ChanExceptSender_NoFormat(chanrec* Ptr, userrec* user, char status, const char* text)
-{
- CUList *ulist;
-
- if ((!Ptr) || (!user) || (!text))
- {
- log(DEFAULT,"*** BUG *** ChanExceptSender was given an invalid parameter");
- return;
- }
-
- switch (status)
- {
- case '@':
- ulist = Ptr->GetOppedUsers();
- break;
- case '%':
- ulist = Ptr->GetHalfoppedUsers();
- break;
- case '+':
- ulist = Ptr->GetVoicedUsers();
- break;
- default:
- ulist = Ptr->GetUsers();
- break;
- }
-
- for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
- {
- if ((IS_LOCAL(i->second)) && (user != i->second))
- WriteFrom_NoFormat(i->second->fd,user,text);
- }
-}
-
std::string GetServerDescription(const char* servername)
{
std::string description = "";
diff --git a/src/mode.cpp b/src/mode.cpp
index 35385c60c..35b8b1e65 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -467,7 +467,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
{
if (type == MODETYPE_CHANNEL)
{
- WriteChannelWithServ(Config->ServerName,targetchannel,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
+ targetchannel->WriteChannelWithServ(Config->ServerName, "MODE %s %s%s", targetchannel->name, output_sequence.c_str(), parameter_list.str().c_str());
}
else
{
@@ -479,7 +479,7 @@ void ModeParser::Process(const char** parameters, int pcnt, userrec *user, bool
if (type == MODETYPE_CHANNEL)
{
log(DEBUG,"Write output sequence and parameters to channel: %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
- WriteChannel(targetchannel,user,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
+ targetchannel->WriteChannel(user,"MODE %s %s%s",targetchannel->name,output_sequence.c_str(),parameter_list.str().c_str());
FOREACH_MOD(I_OnMode,OnMode(user, targetchannel, TYPE_CHANNEL, output_sequence + parameter_list.str()));
}
else
diff --git a/src/modules.cpp b/src/modules.cpp
index d012d2c71..1b00f3510 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -414,22 +414,6 @@ void Server::ChangeUserNick(userrec* user, const std::string &nickname)
force_nickchange(user,nickname.c_str());
}
-void Server::KickUser(userrec* source, userrec* target, chanrec* chan, const std::string &reason)
-{
- if (source)
- {
- if (!chan->KickUser(source, target, reason.c_str()))
- /* No users left? */
- delete chan;
- }
- else
- {
- if (!chan->ServerKickUser(target, reason.c_str(), true))
- /* No users left? */
- delete chan;
- }
-}
-
void Server::QuitUser(userrec* user, const std::string &reason)
{
kill_link(user,reason.c_str());
@@ -498,23 +482,6 @@ void Server::SendTo(userrec* Source, userrec* Dest, const std::string &s)
}
}
-void Server::SendChannelServerNotice(const std::string &ServName, chanrec* Channel, const std::string &text)
-{
- WriteChannelWithServ_NoFormat((char*)ServName.c_str(), Channel, text.c_str());
-}
-
-void Server::SendChannel(userrec* User, chanrec* Channel, const std::string &s, bool IncludeSender)
-{
- if (IncludeSender)
- {
- WriteChannel_NoFormat(Channel,User,s.c_str());
- }
- else
- {
- ChanExceptSender_NoFormat(Channel,User,0,s.c_str());
- }
-}
-
bool Server::CommonChannels(userrec* u1, userrec* u2)
{
return (common_channels(u1,u2) != 0);
diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp
index 3068c5209..f818484e8 100644
--- a/src/modules/m_joinflood.cpp
+++ b/src/modules/m_joinflood.cpp
@@ -224,7 +224,7 @@ class ModuleJoinFlood : public Module
{
f->clear();
f->lock();
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(), channel, "NOTICE %s :This channel has been closed to new users for 60 seconds because there have been more than %d joins in %d seconds.",channel->name,f->joins,f->secs);
+ channel->WriteChannelWithServ((char*)Srv->GetServerName().c_str(), "NOTICE %s :This channel has been closed to new users for 60 seconds because there have been more than %d joins in %d seconds.", channel->name, f->joins, f->secs);
}
}
}
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 9dcbbe05e..e1c021743 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -62,7 +62,7 @@ class cmd_knock : public command_t
if (c->modes[CM_INVITEONLY])
{
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(),c,"NOTICE %s :User %s is KNOCKing on %s (%s)",c->name,user->nick,c->name,line.c_str());
+ c->WriteChannelWithServ((char*)Srv->GetServerName().c_str(), "NOTICE %s :User %s is KNOCKing on %s (%s)", c->name, user->nick, c->name, line.c_str());
WriteServ(user->fd,"NOTICE %s :KNOCKing on %s",user->nick,c->name);
return;
}
diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp
index f322a63e6..6079eb47b 100644
--- a/src/modules/m_messageflood.cpp
+++ b/src/modules/m_messageflood.cpp
@@ -228,7 +228,7 @@ class ModuleMsgFlood : public Module
Event rmode((char *)&n, NULL, "send_mode");
rmode.Send();
}
- Srv->KickUser(NULL, user, dest, "Channel flood triggered (mode +f)");
+ dest->ServerKickUser(user, "Channel flood triggered (mode +f)", true);
}
}
}
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 64ce9cff6..116042ae6 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -209,7 +209,7 @@ class ModuleOverride : public Module
if (!user->IsInvited(x))
{
/* XXX - Ugly cast for a parameter that isn't used? :< - Om */
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(), chan, "NOTICE %s :%s invited himself into the channel",cname,user->nick);
+ chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s invited himself into the channel", cname, user->nick);
}
}
Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +i on "+std::string(cname));
@@ -219,7 +219,7 @@ class ModuleOverride : public Module
if ((chan->key[0]) && (CanOverride(user,"KEY")))
{
if (NoisyOverride)
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,"NOTICE %s :%s bypassed the channel key",cname,user->nick);
+ chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s bypassed the channel key", cname, user->nick);
Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +k on "+std::string(cname));
return -1;
}
@@ -227,7 +227,7 @@ class ModuleOverride : public Module
if ((chan->limit > 0) && (Srv->CountUsers(chan) >= chan->limit) && (CanOverride(user,"LIMIT")))
{
if (NoisyOverride)
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,"NOTICE %s :%s passed through your channel limit",cname,user->nick);
+ chan->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s passed through your channel limit", cname, user->nick);
Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +l on "+std::string(cname));
return -1;
}
diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp
index bab5ea11b..7452b2f33 100644
--- a/src/modules/m_remove.cpp
+++ b/src/modules/m_remove.cpp
@@ -182,7 +182,7 @@ class RemoveBase
/* Build up the part reason string. */
reason << "Removed by " << user->nick << reasonparam;
- WriteChannelWithServ(Srv->GetServerName().c_str(), channel, "NOTICE %s :%s removed %s from the channel", channel->name, user->nick, target->nick);
+ channel->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s removed %s from the channel", channel->name, user->nick, target->nick);
WriteServ(target->fd, "NOTICE %s :*** %s removed you from %s with the message: %s", target->nick, user->nick, channel->name, reasonparam.c_str());
if (!channel->PartUser(target, reason.str().c_str()))
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index d8292a669..93e501e6f 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -1338,11 +1338,11 @@ class TreeSocket : public InspSocket
userrec* user = Srv->FindNick(source);
if (!user)
{
- WriteChannelWithServ(source.c_str(), c, "TOPIC %s :%s", c->name, c->topic);
+ c->WriteChannelWithServ(source.c_str(), "TOPIC %s :%s", c->name, c->topic);
}
else
{
- WriteChannel(c, user, "TOPIC %s :%s", c->name, c->topic);
+ c->WriteChannel(user, "TOPIC %s :%s", c->name, c->topic);
nsource = user->server;
}
/* all done, send it on its way */
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index 9477a37f6..fbf220929 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -98,7 +98,7 @@ class cmd_tban : public command_t
T.mask = mask;
T.expire = expire;
TimedBanList.push_back(T);
- Srv->SendChannelServerNotice(Srv->GetServerName(),channel,"NOTICE "+std::string(channel->name)+" :"+std::string(user->nick)+" added a timed ban on "+mask+" lasting for "+std::string(duration)+" seconds.");
+ channel->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :%s added a timed ban on %s lasting for %s seconds.", channel->name, user->nick, mask.c_str(), duration);
}
return;
}
@@ -161,7 +161,7 @@ class ModuleTimedBans : public Module
again = true;
if (cr)
{
- Srv->SendChannelServerNotice(Srv->GetServerName(),cr,"NOTICE "+std::string(cr->name)+" :Timed ban on "+i->mask+" expired.");
+ cr->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :Timed ban on %s expired.", cr->name, i->mask.c_str());
const char *setban[3];
setban[0] = i->channel.c_str();
setban[1] = "-b";
diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp
index d5b1b587d..3e9c37a3a 100644
--- a/src/modules/m_uninvite.cpp
+++ b/src/modules/m_uninvite.cpp
@@ -80,7 +80,7 @@ class cmd_uninvite : public command_t
u->RemoveInvite(xname);
WriteServ(user->fd,"494 %s %s %s :Uninvited",user->nick,c->name,u->nick);
WriteServ(u->fd,"493 %s :You were uninvited from %s by %s",u->nick,c->name,user->nick);
- WriteChannel(c,user,"NOTICE %s :*** %s uninvited %s.",c->name,user->nick,u->nick);
+ c->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :*** %s uninvited %s.", c->name, user->nick, u->nick);
}
};