Skip to content

Commit 279f2a1

Browse files
author
pomac
committed
- Made privmsg and notice make use of cprivmsg and cnotice.
- Made added rping, parsing needs a text event, but the data is "known". - Fixed a bug in the plugin hook changes. git-svn-id: svn://red.pomac.com/rage@36 55c13d69-e7e2-0310-b639-a4a306287c42
1 parent d892aca commit 279f2a1

3 files changed

Lines changed: 57 additions & 3 deletions

File tree

trunk/src/common/outbound.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,6 +2384,9 @@ cmd_msg (struct session *sess, char *cmd, char *buf)
23842384
if (strcasecmp (nick, "nickserv") == 0 &&
23852385
strncasecmp (msg, "identify ", 9) == 0)
23862386
msg = "identify ****";
2387+
if (strcasecmp (nick, "authserv") == 0 &&
2388+
strncasecmp (msg, "auth ", 5) == 0)
2389+
msg = "auth ****";
23872390
EMIT_SIGNAL (XP_TE_MSGSEND, sess, nick, msg, NULL, NULL, 0);
23882391
}
23892392

@@ -2659,6 +2662,32 @@ cmd_recv (struct session *sess, char *msg, char *buf)
26592662
return FALSE;
26602663
}
26612664

2665+
static int
2666+
cmd_rping (struct session *sess, char *msg, char *buf)
2667+
{
2668+
char *parv[MAX_TOKENS];
2669+
int parc;
2670+
time_t tp;
2671+
char line[512];
2672+
2673+
split_cmd_parv(buf,&parc,parv);
2674+
2675+
if (parc == 0)
2676+
return FALSE;
2677+
2678+
tp = time(NULL);
2679+
2680+
if (parc > 1)
2681+
snprintf(line, 512, "RPING %s %s :%li\r\n", parv[1], parv[2], tp);
2682+
else
2683+
snprintf(line, 512, "RPING %s %s :%li\r\n", sess->server->servername,
2684+
parv[1], tp);
2685+
2686+
sess->server->p_raw (sess->server, line);
2687+
2688+
return TRUE;
2689+
}
2690+
26622691
static int
26632692
cmd_say (struct session *sess, char *cmd, char *buf)
26642693
{
@@ -3292,6 +3321,7 @@ static struct commands splay_reconnect = {"RECONNECT", cmd_reconnect, 0, 0,
32923321
N_("RECONNECT [<host>] [<port>] [<password>], Can be called just as /RECONNECT to reconnect to the current server or with /RECONNECT ALL to reconnect to all the open servers")};
32933322
#endif
32943323
static struct commands splay_recv = {"RECV", cmd_recv, 1, 0, N_("RECV <text>, send raw data to xchat, as if it was received from the irc server")};
3324+
static struct commands splay_rping = {"RPING", cmd_rping, 1, 0, N_("RPING <server> [server], ping between servers")};
32953325
static struct commands splay_say = {"SAY", cmd_say, 0, 0,
32963326
N_("SAY <text>, sends the text to the object in the current window")};
32973327
#ifdef USE_OPENSSL
@@ -3401,6 +3431,7 @@ setup_commands(void)
34013431
add_command(&splay_quote);
34023432
add_command(&splay_reconnect);
34033433
add_command(&splay_recv);
3434+
add_command(&splay_rping);
34043435
add_command(&splay_say);
34053436
add_command(&splay_servchan);
34063437
add_command(&splay_server);

trunk/src/common/plugin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ plugin_show_help (session *sess, char *cmd)
701701
return 1;
702702
}
703703

704-
list = plugin_hook_find (hook_list, HOOK_COMMAND, cmd);
704+
list = plugin_hook_find (hook_list[HOOK_COMMAND], HOOK_COMMAND, cmd);
705705
if (list)
706706
{
707707
hook = list->data;

trunk/src/common/proto-irc.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,14 @@ irc_user_whois (server *serv, char *nicks)
196196
static void
197197
irc_message (server *serv, char *channel, char *text)
198198
{
199-
tcp_sendf (serv, "PRIVMSG %s :%s\r\n", channel, text);
199+
session *sess = NULL;
200+
201+
if (is_channel(serv, channel))
202+
sess = find_channel(serv, channel);
203+
if (sess && sess->me->op && isupport(serv, "CPRIVMSG"))
204+
tcp_sendf (serv, "CPRIVMSG %s :%s\r\n", channel, text);
205+
else
206+
tcp_sendf (serv, "PRIVMSG %s :%s\r\n", channel, text);
200207
}
201208

202209
static void
@@ -208,7 +215,14 @@ irc_action (server *serv, char *channel, char *act)
208215
static void
209216
irc_notice (server *serv, char *channel, char *text)
210217
{
211-
tcp_sendf (serv, "NOTICE %s :%s\r\n", channel, text);
218+
session *sess = NULL;
219+
220+
if (is_channel(serv, channel))
221+
sess = find_channel(serv, channel);
222+
if (sess && sess->me->op && isupport(serv, "CNOTICE"))
223+
tcp_sendf (serv, "CNOTICE %s :%s\r\n", channel, text);
224+
else
225+
tcp_sendf (serv, "NOTICE %s :%s\r\n", channel, text);
212226
}
213227

214228
static void
@@ -312,6 +326,7 @@ channel_date (session *sess, char *chan, char *timestr)
312326
#define M_WALL MAKE4('W','A','L','L')
313327
#define M_PING MAKE4('P','I','N','G')
314328
#define M_PONG MAKE4('P','O','N','G')
329+
#define M_RPONG MAKE4('R','P','O','N')
315330
#define M_INVITE MAKE4('I','N','V','I')
316331

317332
/* Splits "buf" up into parv/parc */
@@ -948,6 +963,14 @@ irc_server(session *sess, int parc, char *parv[])
948963
case M_PING:
949964
tcp_sendf(sess->server, "PONG %s\r\n", parv[2]);
950965
break;
966+
case M_RPONG:
967+
/* XXX: needs a text event */
968+
/* parv[0] == source server
969+
* parv[3] == dest server
970+
* parv[4] == miliseconds
971+
* parv[5] == user added time, ie from client.
972+
*/
973+
break;
951974
case M_ERROR:
952975
EMIT_SIGNAL(XP_TE_SERVERERROR, sess, parv[2], NULL,
953976
NULL, NULL, 0);

0 commit comments

Comments
 (0)