2 * Copyright (C) 1998 Peter Zelezny.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
39 ctcp_reply (session
*sess
, char *nick
, char *word
[], char *word_eol
[],
42 char tbuf
[4096]; /* can receive 2048 from IRC, so this is enough */
45 /* process %C %B etc */
46 check_special_chars (conf
, TRUE
);
47 auto_insert (tbuf
, sizeof (tbuf
), conf
, word
, word_eol
, "", "", word_eol
[5],
48 server_get_network (sess
->server
, TRUE
), "", "", nick
);
50 handle_command (sess
, tbuf
, FALSE
);
54 ctcp_check (session
*sess
, char *nick
, char *word
[], char *word_eol
[],
60 GSList
*list
= ctcp_list
;
62 po
= strchr (ctcp
, '\001');
66 po
= strchr (word_eol
[5], '\001');
72 pop
= (struct popup
*) list
->data
;
73 if (!strcasecmp (ctcp
, pop
->name
))
75 ctcp_reply (sess
, nick
, word
, word_eol
, pop
->cmd
);
84 ctcp_handle (session
*sess
, char *to
, char *nick
, char *ip
,
85 char *msg
, char *word
[], char *word_eol
[], int id
)
89 server
*serv
= sess
->server
;
93 if (serv
->have_idmsg
&& (word
[4][1] == '+' || word
[4][1] == '-') )
96 /* consider DCC to be different from other CTCPs */
97 if (!strncasecmp (msg
, "DCC", 3))
99 /* but still let CTCP replies override it */
100 if (!ctcp_check (sess
, nick
, word
, word_eol
, word
[4] + ctcp_offset
))
102 if (!ignore_check (word
[1], IG_DCC
))
103 handle_dcc (sess
, nick
, word
, word_eol
);
108 /* consider ACTION to be different from other CTCPs. Check
109 ignore as if it was a PRIV/CHAN. */
110 if (!strncasecmp (msg
, "ACTION ", 7))
112 if (is_channel (serv
, to
))
114 /* treat a channel action as a CHAN */
115 if (ignore_check (word
[1], IG_CHAN
))
119 /* treat a private action as a PRIV */
120 if (ignore_check (word
[1], IG_PRIV
))
124 /* but still let CTCP replies override it */
125 if (ctcp_check (sess
, nick
, word
, word_eol
, word
[4] + ctcp_offset
))
128 inbound_action (sess
, to
, nick
, ip
, msg
+ 7, FALSE
, id
);
132 if (ignore_check (word
[1], IG_CTCP
))
135 if (!strcasecmp (msg
, "VERSION") && !prefs
.hidever
)
137 serv
->p_nctcp (serv
, nick
, "VERSION Purple IRC");
140 if (!ctcp_check (sess
, nick
, word
, word_eol
, word
[4] + ctcp_offset
))
142 if (!strncasecmp (msg
, "SOUND", 5))
144 po
= strchr (word
[5], '\001');
148 if (is_channel (sess
->server
, to
))
150 chansess
= find_channel (sess
->server
, to
);
154 EMIT_SIGNAL (XP_TE_CTCPSNDC
, chansess
, word
[5],
158 EMIT_SIGNAL (XP_TE_CTCPSND
, sess
->server
->front_session
, word
[5],
159 nick
, NULL
, NULL
, 0);
162 /* don't let IRCers specify path */
163 if (strchr (word
[5], '/') == NULL
)
164 sound_play (word
[5], TRUE
);
170 po
= strchr (msg
, '\001');
174 if (!is_channel (sess
->server
, to
))
176 EMIT_SIGNAL (XP_TE_CTCPGEN
, sess
->server
->front_session
, msg
, nick
,
180 chansess
= find_channel (sess
->server
, to
);
183 EMIT_SIGNAL (XP_TE_CTCPGENC
, chansess
, msg
, nick
, to
, NULL
, 0);