diff options
author | Naram Qashat cyberbotx@cyberbotx.com <Naram Qashat cyberbotx@cyberbotx.com@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-10-02 19:06:00 +0000 |
---|---|---|
committer | Naram Qashat cyberbotx@cyberbotx.com <Naram Qashat cyberbotx@cyberbotx.com@5417fbe8-f217-4b02-8779-1006273d7864> | 2008-10-02 19:06:00 +0000 |
commit | 552c4a47b18a3373b46512a00bfce360f30a5cea (patch) | |
tree | 3a458d3c53bfe78d63c28fe520b2dd83b9a0d11f | |
parent | 8001cc147dded5bb8acefe6cb93d6defb3f92562 (diff) |
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
-rw-r--r-- | include/extern.h | 2 | ||||
-rw-r--r-- | include/services.h | 18 | ||||
-rw-r--r-- | src/botserv.c | 8 | ||||
-rw-r--r-- | src/channels.c | 2 | ||||
-rw-r--r-- | src/core/bs_act.c | 6 | ||||
-rw-r--r-- | src/core/bs_fantasy_seen.c | 16 | ||||
-rw-r--r-- | src/core/bs_say.c | 8 | ||||
-rw-r--r-- | src/ircd.c | 13 | ||||
-rw-r--r-- | src/log.c | 10 | ||||
-rw-r--r-- | src/send.c | 33 | ||||
-rw-r--r-- | src/users.c | 2 |
11 files changed, 44 insertions, 74 deletions
diff --git a/include/extern.h b/include/extern.h index c7993688a..96ea8d52a 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 */ diff --git a/include/services.h b/include/services.h index 9cb3273ba..6a23d4162 100644 --- a/include/services.h +++ b/include/services.h @@ -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) { diff --git a/src/botserv.c b/src/botserv.c index 5705b1e27..9a476fd72 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -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; } diff --git a/src/channels.c b/src/channels.c index 5290826f6..97d2e698a 100644 --- a/src/channels.c +++ b/src/channels.c @@ -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); } diff --git a/src/core/bs_act.c b/src/core/bs_act.c index ff33c9955..2cdf2e28b 100644 --- a/src/core/bs_act.c +++ b/src/core/bs_act.c @@ -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; diff --git a/src/core/bs_fantasy_seen.c b/src/core/bs_fantasy_seen.c index 5703d9e9a..486df3a8f 100644 --- a/src/core/bs_fantasy_seen.c +++ b/src/core/bs_fantasy_seen.c @@ -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); diff --git a/src/core/bs_say.c b/src/core/bs_say.c index 06a9497ce..76f14ee76 100644 --- a/src/core/bs_say.c +++ b/src/core/bs_say.c @@ -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); diff --git a/src/ircd.c b/src/ircd.c index 5a75668ee..39e17df7c 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -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); @@ -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. */ diff --git a/src/send.c b/src/send.c index 5911dda44..7474a380b 100644 --- a/src/send.c +++ b/src/send.c @@ -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); -} - - diff --git a/src/users.c b/src/users.c index dee3f645c..482dd4cda 100644 --- a/src/users.c +++ b/src/users.c @@ -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 { |