summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/channels.h8
-rw-r--r--src/channels.cpp18
-rw-r--r--src/cmd_notice.cpp2
-rw-r--r--src/cmd_privmsg.cpp2
-rw-r--r--src/mode.cpp3
-rw-r--r--src/users.cpp12
6 files changed, 26 insertions, 19 deletions
diff --git a/include/channels.h b/include/channels.h
index d0d221550..21cd8402d 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -428,18 +428,22 @@ class chanrec : public Extensible
/** Write to all users on a channel except a specific user, using va_args for text
* @param user User whos details to prefix the line with, and to omit from receipt of the message
+ * @param serversource If this parameter is true, use the local server name as the source of the text, otherwise,
+ * use the nick!user@host of the user.
* @param status The status of the users to write to, e.g. '@' or '%'. Use a value of 0 to write to everyone
* @param text A printf-style format string which builds the output line without prefi
* @param ... Zero or more POD type
*/
- void WriteAllExceptSender(userrec* user, char status, char* text, ...);
+ void WriteAllExceptSender(userrec* user, bool serversource, char status, char* text, ...);
/** Write to all users on a channel except a specific user, using std::string for text
* @param user User whos details to prefix the line with, and to omit from receipt of the message
+ * @param serversource If this parameter is true, use the local server name as the source of the text, otherwise,
+ * use the nick!user@host of the user.
* @param status The status of the users to write to, e.g. '@' or '%'. Use a value of 0 to write to everyone
* @param text A std::string containing the output line without prefix
*/
- void WriteAllExceptSender(userrec* user, char status, const std::string& text);
+ void WriteAllExceptSender(userrec* user, bool serversource, char status, const std::string& text);
/** Returns the maximum number of bans allowed to be set on this channel
* @return The maximum number of bans allowed
diff --git a/src/channels.cpp b/src/channels.cpp
index 732b253cc..8dd8b490e 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -690,28 +690,25 @@ void chanrec::WriteChannelWithServ(const char* ServName, const std::string &text
/* 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, ...)
+void chanrec::WriteAllExceptSender(userrec* user, bool serversource, char status, char* text, ...)
{
char textbuffer[MAXBUF];
va_list argsPtr;
- if (!user || !text)
+ if (!text)
return;
va_start(argsPtr, text);
vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);
- this->WriteAllExceptSender(user, status, std::string(textbuffer));
+ this->WriteAllExceptSender(user, serversource, status, std::string(textbuffer));
}
-void chanrec::WriteAllExceptSender(userrec* user, char status, const std::string& text)
+void chanrec::WriteAllExceptSender(userrec* user, bool serversource, char status, const std::string& text)
{
CUList *ulist;
- if (!user)
- return;
-
switch (status)
{
case '@':
@@ -731,7 +728,12 @@ void chanrec::WriteAllExceptSender(userrec* user, char status, const std::string
for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
{
if ((IS_LOCAL(i->second)) && (user != i->second))
- i->second->WriteFrom(user,text);
+ {
+ if (serversource)
+ i->second->WriteServ(text);
+ else
+ i->second->WriteFrom(user,text);
+ }
}
}
diff --git a/src/cmd_notice.cpp b/src/cmd_notice.cpp
index d018e1eb2..6c0336fa5 100644
--- a/src/cmd_notice.cpp
+++ b/src/cmd_notice.cpp
@@ -93,7 +93,7 @@ CmdResult cmd_notice::Handle (const char** parameters, int pcnt, userrec *user)
return CMD_FAILURE;
}
- chan->WriteAllExceptSender(user, status, "NOTICE %s :%s", chan->name, parameters[1]);
+ chan->WriteAllExceptSender(user, false, 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 0623fcd85..18c6900f4 100644
--- a/src/cmd_privmsg.cpp
+++ b/src/cmd_privmsg.cpp
@@ -94,7 +94,7 @@ CmdResult cmd_privmsg::Handle (const char** parameters, int pcnt, userrec *user)
return CMD_FAILURE;
}
- chan->WriteAllExceptSender(user, status, "PRIVMSG %s :%s", chan->name, parameters[1]);
+ chan->WriteAllExceptSender(user, false, 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/mode.cpp b/src/mode.cpp
index bddd6cc31..13bfe234b 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -734,7 +734,8 @@ std::string ModeParser::ModeString(userrec* user, chanrec* channel)
{
ModePair ret;
ret = mh->ModeSet(NULL, user, channel, user->nick);
- if (ret.first)
+ ServerInstance->Log(DEBUG,"first='%d' second='%s'",ret.first,ret.second.c_str());
+ if ((ret.first) && (ret.second == user->nick))
{
pars.append(" ");
pars.append(user->nick);
diff --git a/src/users.cpp b/src/users.cpp
index 56d578687..8c6711d64 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1754,10 +1754,10 @@ bool userrec::ChangeDisplayedHost(const char* host)
{
if ((*i)->channel)
{
- (*i)->channel->WriteAllExceptSender(this, 0, "JOIN %s", (*i)->channel->name);
+ (*i)->channel->WriteAllExceptSender(this, false, 0, "JOIN %s", (*i)->channel->name);
std::string n = this->ServerInstance->Modes->ModeString(this, (*i)->channel);
- if (n.length())
- (*i)->channel->WriteChannelWithServ(this->ServerInstance->Config->ServerName, "MODE %s +%s", (*i)->channel->name, n.c_str());
+ if (n.length() > 0)
+ (*i)->channel->WriteAllExceptSender(this, true, 0, "MODE %s +%s", (*i)->channel->name, n.c_str());
}
}
}
@@ -1784,10 +1784,10 @@ bool userrec::ChangeIdent(const char* newident)
{
if ((*i)->channel)
{
- (*i)->channel->WriteAllExceptSender(this, 0, "JOIN %s", (*i)->channel->name);
+ (*i)->channel->WriteAllExceptSender(this, false, 0, "JOIN %s", (*i)->channel->name);
std::string n = this->ServerInstance->Modes->ModeString(this, (*i)->channel);
- if (n.length())
- (*i)->channel->WriteChannelWithServ(this->ServerInstance->Config->ServerName, "MODE %s +%s", (*i)->channel->name, n.c_str());
+ if (n.length() > 0)
+ (*i)->channel->WriteAllExceptSender(this, true, 0, "MODE %s +%s", (*i)->channel->name, n.c_str());
}
}
}