1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 09:53:12 +02:00

Replaced anope_cmd_privmsg() and privmsg() with direct call to SendPrivmsg() in IRCDProto class.

Added SendPrivmsgInternal() function to IRCDProto class, now SendPrivmsg() is a stub to handle varargs.


git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1335 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Naram Qashat cyberbotx@cyberbotx.com
2008-10-02 19:06:00 +00:00
parent 8001cc147d
commit 552c4a47b1
11 changed files with 44 additions and 74 deletions
-2
View File
@@ -1110,7 +1110,6 @@ E int db_mysql_load_news(void);
E unsigned int mysql_rand(void);
#endif
E void privmsg(char *source, char *dest, const char *fmt, ...);
E void notice(char *source, const char *dest, const char *fmt, ...);
/******************************************************************************/
@@ -1133,7 +1132,6 @@ E void anope_SendGlobalNotice(const char *source, const char *dest, const char *
E void anope_SendPart(const char *nick, const char *chan, const char *fmt, ...); /* PART */
E void anope_cmd_pass(const char *pass); /* PASS */
E void anope_SendPong(const char *servname, const char *who); /* PONG */
E void anope_cmd_privmsg(const char *source, const char *dest, const char *fmt, ...); /* PRIVMSG */
E void anope_cmd_action(const char *source, const char *dest, const char *fmt, ...); /* PRIVMSG */
E void anope_SendGlobalPrivmsg(const char *source, const char *dest, const char *msg); /* PRIVMSG */
E void anope_cmd_protoctl(); /* PROTOCTL */
+15 -3
View File
@@ -1237,10 +1237,14 @@ class IRCDProto {
virtual void SendMessageInternal(BotInfo *bi, const char *dest, const char *buf)
{
if (NSDefFlags & NI_MSG)
SendPrivmsg(bi, dest, buf);
SendPrivmsgInternal(bi, dest, buf);
else
SendNotice(bi, dest, buf);
}
virtual void SendPrivmsgInternal(BotInfo *bi, const char *dest, const char *buf)
{
send_cmd(UseTS6 ? bi->uid : bi->nick, "PRIVMSG %s :%s", dest, buf);
}
public:
virtual void SendSVSNOOP(const char *, int) { }
virtual void SendAkillDel(const char *, const char *) = 0;
@@ -1310,9 +1314,17 @@ class IRCDProto {
{
send_cmd(UseTS6 ? bi->uid : bi->nick, "NOTICE %s :%s", dest, msg);
}
virtual void SendPrivmsg(BotInfo *bi, const char *dest, const char *buf)
virtual void SendPrivmsg(const char *source, const char *dest, const char *fmt, ...)
{
send_cmd(UseTS6 ? bi->uid : bi->nick, "PRIVMSG %s :%s", dest, buf);
va_list args;
char buf[BUFSIZE] = "";
if (fmt) {
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
va_end(args);
}
BotInfo *bi = findbot(source);
SendPrivmsgInternal(bi, dest, buf);
}
virtual void SendGlobalNotice(const char *source, const char *dest, const char *msg)
{
+4 -4
View File
@@ -846,7 +846,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
if (ircd->protectedumode) {
if (is_protected(u) && (requester != u)) {
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s",
getstring2(NULL, PERMISSION_DENIED));
return;
}
@@ -858,7 +858,7 @@ void bot_raw_ban(User * requester, ChannelInfo * ci, char *nick,
if (ircd->except) {
if (is_excepted(ci, u) == 1) {
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s",
getstring2(NULL, BOT_EXCEPT));
return;
}
@@ -922,7 +922,7 @@ void bot_raw_kick(User * requester, ChannelInfo * ci, char *nick,
if (ircd->protectedumode) {
if (is_protected(u) && (requester != u)) {
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s",
getstring2(NULL, PERMISSION_DENIED));
return;
}
@@ -976,7 +976,7 @@ void bot_raw_mode(User * requester, ChannelInfo * ci, char *mode,
if (ircd->protectedumode) {
if (is_protected(u) && *mode == '-' && (requester != u)) {
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s",
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s",
getstring2(NULL, PERMISSION_DENIED));
return;
}
+1 -1
View File
@@ -1569,7 +1569,7 @@ void chan_adduser2(User * user, Channel * c)
* recovers from a netsplit. -GD
*/
if (is_sync(user->server)) {
anope_cmd_privmsg(c->ci->bi->nick, c->name, "[%s] %s",
ircdproto->SendPrivmsg(c->ci->bi->nick, c->name, "[%s] %s",
user->na->nick, user->na->nc->greet);
c->ci->bi->lastmsg = time(NULL);
}
+3 -3
View File
@@ -6,8 +6,8 @@
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
* Based on the original code of Services by Andy Church.
*
* $Id$
*
*/
@@ -85,7 +85,7 @@ int do_act(User * u)
anope_cmd_action(ci->bi->nick, ci->name, "%s", text);
ci->bi->lastmsg = time(NULL);
if (LogBot && LogChannel && logchan && !debug && findchan(LogChannel))
anope_cmd_privmsg(ci->bi->nick, LogChannel, "ACT %s %s %s",
ircdproto->SendPrivmsg(ci->bi->nick, LogChannel, "ACT %s %s %s",
u->nick, ci->name, text);
}
return MOD_CONT;
+8 -8
View File
@@ -6,8 +6,8 @@
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
* Based on the original code of Services by Andy Church.
*
* $Id$
*
*/
@@ -77,12 +77,12 @@ int do_fantasy(int argc, char **argv)
/* If we look for the bot */
snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_BOT),
u->nick);
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s", buf);
} else if (!(na = findnick(target)) || (na->status & NS_VERBOTEN)) {
/* If the nick is not registered or forbidden */
snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN),
target);
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s", buf);
} else if ((u2 = nc_on_chan(ci->c, na->nc))) {
/* If the nick we're looking for is on the channel,
* there are three possibilities: it's yourself,
@@ -100,7 +100,7 @@ int do_fantasy(int argc, char **argv)
getstring(u->na, BOT_SEEN_ON_CHANNEL_AS), target,
u2->nick);
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s", buf);
} else if ((access = get_access_entry(na->nc, ci))) {
/* User is on the access list but not present actually.
Special case: if access->last_seen is 0 it's that we
@@ -116,7 +116,7 @@ int do_fantasy(int argc, char **argv)
snprintf(buf, sizeof(buf),
getstring(u->na, BOT_SEEN_NEVER), target);
}
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s", buf);
} else if (na->nc == ci->founder) {
/* User is the founder of the channel */
char durastr[192];
@@ -124,12 +124,12 @@ int do_fantasy(int argc, char **argv)
time(NULL) - na->last_seen);
snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON),
target, durastr);
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s", buf);
} else {
/* All other cases */
snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN),
target);
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf);
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s", buf);
}
/* free myStrGetToken(ed) variable target (#851) */
Anope_Free(target);
+4 -4
View File
@@ -6,8 +6,8 @@
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
* Based on the original code of Services by Andy Church.
*
* $Id$
*
*/
@@ -84,10 +84,10 @@ int do_say(User * u)
notice_lang(s_BotServ, u, ACCESS_DENIED);
else {
if (text[0] != '\001') {
anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", text);
ircdproto->SendPrivmsg(ci->bi->nick, ci->name, "%s", text);
ci->bi->lastmsg = time(NULL);
if (LogBot && LogChannel && logchan && !debug && findchan(LogChannel))
anope_cmd_privmsg(ci->bi->nick, LogChannel,
ircdproto->SendPrivmsg(ci->bi->nick, LogChannel,
"SAY %s %s %s", u->nick, ci->name, text);
} else {
syntax_error(s_BotServ, u, "SAY", BOT_SAY_SYNTAX);
-13
View File
@@ -72,19 +72,6 @@ void anope_cmd_action(const char *source, const char *dest, const char *fmt, ...
ircdproto->SendPrivmsg(bi, dest, actionbuf);
}
void anope_cmd_privmsg(const char *source, const char *dest, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE] = "";
if (fmt) {
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
va_end(args);
}
BotInfo *bi = findbot(source);
ircdproto->SendPrivmsg(bi, dest, buf);
}
void anope_SendGlobalNotice(const char *source, const char *dest, const char *msg)
{
ircdproto->SendGlobalNotice(source, dest, msg);
+5 -5
View File
@@ -6,9 +6,9 @@
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*
* $Id$
* Based on the original code of Services by Andy Church.
*
* $Id$
*
*/
@@ -177,7 +177,7 @@ void alog(const char *fmt, ...)
fprintf(stderr, "%s %s\n", buf, str);
}
if (LogChannel && logchan && !debug && findchan(LogChannel)) {
privmsg(s_GlobalNoticer, LogChannel, "%s", str);
ircdproto->SendPrivmsg(s_GlobalNoticer, LogChannel, "%s", str);
}
errno = errno_save;
}
@@ -294,7 +294,7 @@ void fatal_perror(const char *fmt, ...)
/*************************************************************************/
/* Same thing, but do it like perror().
/* Same thing, but do it like perror().
* This is for socket errors. On *nix, it works just like fatal_perror,
* on Win32, it uses the socket error code and formatting functions.
*/
+3 -30
View File
@@ -202,7 +202,7 @@ void notice_lang(const char *source, User * dest, int message, ...)
if (UsePrivmsg && ((!dest->na && (NSDefFlags & NI_MSG))
|| (dest->na
&& (dest->na->nc->flags & NI_MSG)))) {
anope_cmd_privmsg(source, dest->nick, *t ? t : " ");
ircdproto->SendPrivmsg(source, dest->nick, *t ? t : " ");
} else {
ircdproto->SendNotice(source, dest->nick, *t ? t : " ");
}
@@ -258,7 +258,7 @@ void notice_help(const char *source, User * dest, int message, ...)
if (UsePrivmsg && ((!dest->na && (NSDefFlags & NI_MSG))
|| (dest->na
&& (dest->na->nc->flags & NI_MSG)))) {
anope_cmd_privmsg(source, dest->nick, *outbuf ? outbuf : " ");
ircdproto->SendPrivmsg(source, dest->nick, *outbuf ? outbuf : " ");
} else {
ircdproto->SendNotice(source, dest->nick, *outbuf ? outbuf : " ");
}
@@ -287,37 +287,10 @@ void notice(char *source, const char *dest, const char *fmt, ...)
vsnprintf(buf, BUFSIZE - 1, fmt, args);
if (NSDefFlags & NI_MSG) {
anope_cmd_privmsg(source, dest, buf);
ircdproto->SendPrivmsg(source, dest, buf);
} else {
ircdproto->SendNotice(source, dest, buf);
}
va_end(args);
}
}
/*************************************************************************/
/**
* Send a PRIVMSG from the given source to the given nick.
* @param source Orgin of the Message
* @param dest Destination of the Message
* @param fmt Format of the Message
* @param ... any number of parameters
* @return void
*/
void privmsg(char *source, char *dest, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE];
*buf = '\0';
if (fmt) {
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
va_end(args);
}
anope_cmd_privmsg(source, dest, buf);
}
+1 -1
View File
@@ -297,7 +297,7 @@ void User::SendMessage(const char *source, const std::string &msg)
if (UsePrivmsg &&
((!this->na && NSDefFlags & NI_MSG) || (this->na && this->na->nc->flags & NI_MSG)))
{
anope_cmd_privmsg(source, this->nick, msg.c_str());
ircdproto->SendPrivmsg(source, this->nick, msg.c_str());
}
else
{