Mercurial > pidgin
annotate src/protocols/irc/cmds.c @ 6415:e3be6b9744b7
[gaim-migrate @ 6922]
Committing a patch from Paco-Paco. Adds the /help command to IRC and
updates the todo.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Fri, 08 Aug 2003 19:49:45 +0000 |
| parents | 05b488eda686 |
| children | 42fdf16f1dad |
| rev | line source |
|---|---|
| 6333 | 1 /** |
| 2 * @file cmds.c | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
| 6 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | |
| 7 * | |
| 8 * This program is free software; you can redistribute it and/or modify | |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 */ | |
| 22 | |
| 23 #include "internal.h" | |
| 24 | |
| 25 #include "conversation.h" | |
| 26 #include "notify.h" | |
| 27 #include "debug.h" | |
| 28 #include "irc.h" | |
| 29 | |
| 30 | |
| 31 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops); | |
| 32 | |
| 33 int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 34 { | |
| 35 GaimConversation *convo = gaim_find_conversation_with_account(target, irc->account); | |
| 36 char *buf; | |
| 37 | |
| 38 if (!convo) | |
| 6350 | 39 return 1; |
| 6333 | 40 |
| 41 buf = g_strdup_printf(_("Unknown command: %s"), cmd); | |
| 42 if (gaim_conversation_get_type(convo) == GAIM_CONV_IM) | |
| 43 gaim_im_write(GAIM_IM(convo), "", buf, -1, WFLAG_SYSTEM|WFLAG_NOLOG, time(NULL)); | |
| 44 else | |
| 45 gaim_chat_write(GAIM_CHAT(convo), "", buf, WFLAG_SYSTEM|WFLAG_NOLOG, time(NULL)); | |
| 46 g_free(buf); | |
| 47 | |
| 48 return 1; | |
| 49 } | |
| 50 | |
| 51 int irc_cmd_away(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 52 { | |
| 53 char *buf, *message, *cur; | |
| 54 | |
| 55 if (args[0] && strcmp(cmd, "back")) { | |
| 56 message = strdup(args[0]); | |
| 57 for (cur = message; *cur; cur++) { | |
| 58 if (*cur == '\n') | |
| 59 *cur = ' '; | |
| 60 } | |
| 61 buf = irc_format(irc, "v:", "AWAY", message); | |
| 62 g_free(message); | |
| 63 } else { | |
| 64 buf = irc_format(irc, "v", "AWAY"); | |
| 65 } | |
| 66 irc_send(irc, buf); | |
| 67 g_free(buf); | |
| 68 | |
| 69 return 0; | |
| 70 } | |
| 71 | |
| 72 int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 73 { | |
| 74 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 75 char *action, *dst, **newargs; | |
| 76 const char *src; | |
| 77 GaimConversation *convo; | |
| 78 | |
| 79 if (!args || !args[0] || !gc) | |
| 80 return 0; | |
| 81 | |
| 6376 | 82 action = g_malloc(strlen(args[0]) + 10); |
| 6333 | 83 |
| 84 sprintf(action, "\001ACTION "); | |
| 85 | |
| 86 src = args[0]; | |
| 87 dst = action + 8; | |
| 88 while (*src) { | |
| 89 if (*src == '\n') { | |
| 90 if (*(src + 1) == '\0') { | |
| 91 break; | |
| 92 } else { | |
| 93 *dst++ = ' '; | |
| 94 src++; | |
| 95 continue; | |
| 96 } | |
| 97 } | |
| 98 *dst++ = *src++; | |
| 99 } | |
| 100 *dst++ = '\001'; | |
| 101 *dst = '\0'; | |
| 102 | |
| 103 newargs = g_new0(char *, 2); | |
| 104 newargs[0] = g_strdup(target); | |
| 105 newargs[1] = action; | |
| 106 irc_cmd_privmsg(irc, cmd, target, (const char **)newargs); | |
| 107 g_free(newargs[0]); | |
| 108 g_free(newargs[1]); | |
| 109 g_free(newargs); | |
| 110 | |
| 111 convo = gaim_find_conversation_with_account(target, irc->account); | |
| 112 if (convo && gaim_conversation_get_type(convo) == GAIM_CONV_CHAT) { | |
| 113 action = g_strdup_printf("/me %s", args[0]); | |
| 114 if (action[strlen(action) - 1] == '\n') | |
| 115 action[strlen(action) - 1] = '\0'; | |
| 116 serv_got_chat_in(gc, gaim_chat_get_id(GAIM_CHAT(convo)), | |
| 117 gaim_connection_get_display_name(gc), | |
| 118 0, action, time(NULL)); | |
| 119 g_free(action); | |
| 120 } | |
| 121 | |
| 122 return 1; | |
| 123 } | |
| 124 | |
|
6415
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
125 int irc_cmd_help(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
126 { |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
127 GaimConversation *convo = gaim_find_conversation_with_account(target, irc->account); |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
128 |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
129 /* XXX we should eventually have per-command help */ |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
130 |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
131 if (!convo) |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
132 return 0; |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
133 |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
134 if (gaim_conversation_get_type(convo) == GAIM_CONV_CHAT) { |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
135 gaim_chat_write(GAIM_CHAT(convo), "", _("<B>Supported IRC Commands:</B><BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
136 "AWAY INVITE JOIN KICK<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
137 "ME MODE MSG NAMES<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
138 "NICK OP DEOP OPERWALL<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
139 "PART PING QUERY QUIT<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
140 "QUOTE REMOVE TOPIC UMODE<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
141 "VOICE DEVOICE WALLOPS WHOIS<BR>"), |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
142 WFLAG_NOLOG, time(NULL)); |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
143 } else { |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
144 gaim_im_write(GAIM_IM(convo), "", _("<B>Supported IRC Commands:</B><BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
145 "AWAY JOIN ME MODE<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
146 "MSG NICK OPERWALL PING<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
147 "QUERY QUIT QUOTE UMODE<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
148 "WALLOPS WHOIS"), -1, WFLAG_NOLOG, time(NULL)); |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
149 } |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
150 |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
151 return 0; |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
152 } |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
153 |
| 6333 | 154 int irc_cmd_invite(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 155 { | |
| 156 char *buf; | |
| 157 | |
| 158 if (!args || !args[0] || !(args[1] || target)) | |
| 159 return 0; | |
| 160 | |
| 161 buf = irc_format(irc, "vnc", "INVITE", args[0], args[1] ? args[1] : target); | |
| 162 irc_send(irc, buf); | |
| 163 g_free(buf); | |
| 164 | |
| 165 return 0; | |
| 166 } | |
| 167 | |
| 168 int irc_cmd_join(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 169 { | |
| 170 char *buf; | |
| 171 | |
| 172 if (!args || !args[0]) | |
| 173 return 0; | |
| 174 | |
| 175 if (args[1]) | |
| 176 buf = irc_format(irc, "vcv", "JOIN", args[0], args[1]); | |
| 177 else | |
| 178 buf = irc_format(irc, "vc", "JOIN", args[0]); | |
| 179 irc_send(irc, buf); | |
| 180 g_free(buf); | |
| 181 | |
| 182 return 0; | |
| 183 } | |
| 184 | |
| 185 int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 186 { | |
| 187 char *buf; | |
| 188 GaimConversation *convo; | |
| 189 | |
| 190 if (!args || !args[0]) | |
| 191 return 0; | |
| 192 | |
| 193 convo = gaim_find_conversation_with_account(target, irc->account); | |
| 194 if (!convo || gaim_conversation_get_type(convo) != GAIM_CONV_CHAT) | |
| 6350 | 195 return 0; |
| 6333 | 196 |
| 197 if (args[1]) | |
| 198 buf = irc_format(irc, "vcn:", "KICK", target, args[0], args[1]); | |
| 199 else | |
| 200 buf = irc_format(irc, "vcn", "KICK", target, args[0]); | |
| 201 irc_send(irc, buf); | |
| 202 g_free(buf); | |
| 203 | |
| 204 return 0; | |
| 205 } | |
| 206 | |
| 207 int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 208 { | |
| 209 GaimConnection *gc; | |
| 210 char *buf; | |
| 211 | |
| 212 if (!args) | |
| 213 return 0; | |
| 214 | |
| 215 if (!strcmp(cmd, "mode")) { | |
| 216 if (!args[0] && (*target == '#' || *target == '&')) | |
| 217 buf = irc_format(irc, "vc", "MODE", target); | |
| 218 else if (args[0] && (*args[0] == '+' || *args[0] == '-')) | |
| 219 buf = irc_format(irc, "vcv", "MODE", target, args[0]); | |
| 220 else if (args[0]) | |
| 221 buf = irc_format(irc, "vv", "MODE", args[0]); | |
| 222 else | |
| 6350 | 223 return 0; |
| 6333 | 224 } else if (!strcmp(cmd, "umode")) { |
| 225 if (!args[0]) | |
| 6350 | 226 return 0; |
| 6333 | 227 gc = gaim_account_get_connection(irc->account); |
| 228 buf = irc_format(irc, "vnv", "MODE", gaim_connection_get_display_name(gc), args[0]); | |
| 6365 | 229 } else { |
| 230 return 0; | |
| 6333 | 231 } |
| 6365 | 232 |
| 6333 | 233 irc_send(irc, buf); |
| 234 g_free(buf); | |
| 235 | |
| 236 return 0; | |
| 237 } | |
| 238 | |
| 239 int irc_cmd_names(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 240 { | |
| 241 char *buf; | |
| 242 | |
| 243 if (!args) | |
| 244 return 0; | |
| 245 | |
| 246 buf = irc_format(irc, "vc", "NAMES", args[0] ? args[0] : target); | |
| 247 irc_send(irc, buf); | |
| 248 g_free(buf); | |
| 249 | |
| 250 irc->nameconv = g_strdup(target); | |
| 251 | |
| 252 return 0; | |
| 253 } | |
| 254 | |
| 255 int irc_cmd_nick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 256 { | |
| 257 char *buf; | |
| 258 | |
| 259 if (!args || !args[0]) | |
| 260 return 0; | |
| 261 | |
| 262 buf = irc_format(irc, "v:", "NICK", args[0]); | |
| 263 irc_send(irc, buf); | |
| 264 g_free(buf); | |
| 265 | |
| 266 return 0; | |
| 267 } | |
| 268 | |
| 269 int irc_cmd_op(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 270 { | |
| 271 char **nicks, **ops, *sign, *mode; | |
| 272 int i = 0, used = 0; | |
| 273 | |
| 274 if (!args || !args[0] || !*args[0]) | |
| 275 return 0; | |
| 276 | |
| 277 if (!strcmp(cmd, "op")) { | |
| 278 sign = "+"; | |
| 279 mode = "o"; | |
| 280 } else if (!strcmp(cmd, "deop")) { | |
| 281 sign = "-"; | |
| 282 mode = "o"; | |
| 283 } else if (!strcmp(cmd, "voice")) { | |
| 284 sign = "+"; | |
| 285 mode = "v"; | |
| 286 } else if (!strcmp(cmd, "devoice")) { | |
| 287 sign = "-"; | |
| 288 mode = "v"; | |
| 289 } else { | |
| 290 gaim_debug(GAIM_DEBUG_ERROR, "irc", "invalid 'op' command '%s'\n", cmd); | |
| 291 return 0; | |
| 292 } | |
| 293 | |
| 294 nicks = g_strsplit(args[0], " ", -1); | |
| 295 | |
| 296 for (i = 0; nicks[i]; i++) | |
| 297 /* nothing */; | |
| 298 ops = g_new0(char *, i * 2 + 1); | |
| 299 | |
| 300 for (i = 0; nicks[i]; i++) { | |
| 301 if (!*nicks[i]) | |
| 302 continue; | |
| 303 ops[used++] = mode; | |
| 304 ops[used++] = nicks[i]; | |
| 305 } | |
| 306 | |
| 307 irc_do_mode(irc, target, sign, ops); | |
| 308 g_free(ops); | |
| 309 | |
| 6350 | 310 return 0; |
| 6333 | 311 } |
| 312 | |
| 313 int irc_cmd_part(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 314 { | |
| 315 char *buf; | |
| 316 | |
| 317 if (!args) | |
| 318 return 0; | |
| 319 | |
| 320 if (args[1]) | |
| 321 buf = irc_format(irc, "vc:", "PART", args[0] ? args[0] : target, args[1]); | |
| 322 else | |
| 323 buf = irc_format(irc, "vc", "PART", args[0] ? args[0] : target); | |
| 324 irc_send(irc, buf); | |
| 325 g_free(buf); | |
| 326 | |
| 327 return 0; | |
| 328 } | |
| 329 | |
| 330 int irc_cmd_ping(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 331 { | |
| 332 char *stamp; | |
| 333 char *buf; | |
| 334 | |
| 335 if (args && args[0]) { | |
| 336 if (*args[0] == '#' || *args[0] == '&') | |
| 337 return 0; | |
| 338 stamp = g_strdup_printf("\001PING %lu\001", time(NULL)); | |
| 339 buf = irc_format(irc, "vn:", "PRIVMSG", args[0], stamp); | |
| 340 g_free(stamp); | |
| 341 } else { | |
| 6350 | 342 stamp = g_strdup_printf("%s %lu", target, time(NULL)); |
| 6333 | 343 buf = irc_format(irc, "v:", "PING", stamp); |
| 344 g_free(stamp); | |
| 345 } | |
| 346 irc_send(irc, buf); | |
| 347 g_free(buf); | |
| 348 | |
| 349 return 0; | |
| 350 } | |
| 351 | |
| 352 int irc_cmd_privmsg(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 353 { | |
| 354 const char *cur, *end; | |
| 355 char *msg, *buf; | |
| 356 | |
| 357 if (!args || !args[0] || !args[1]) | |
| 358 return 0; | |
| 359 | |
| 360 cur = args[1]; | |
| 361 end = args[1]; | |
| 362 while (*end && *cur) { | |
| 363 end = strchr(cur, '\n'); | |
| 364 if (!end) | |
| 365 end = cur + strlen(cur); | |
| 366 msg = g_strndup(cur, end - cur); | |
| 367 buf = irc_format(irc, "vt:", "PRIVMSG", args[0], msg); | |
| 368 irc_send(irc, buf); | |
| 369 g_free(msg); | |
| 370 g_free(buf); | |
| 371 cur = end + 1; | |
| 372 } | |
| 373 | |
| 374 return 0; | |
| 375 } | |
| 376 | |
| 377 int irc_cmd_quit(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 378 { | |
| 379 char *buf; | |
| 380 | |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6365
diff
changeset
|
381 buf = irc_format(irc, "v:", "QUIT", (args && args[0]) ? args[0] : "Download Gaim: " GAIM_WEBSITE); |
| 6333 | 382 irc_send(irc, buf); |
| 383 g_free(buf); | |
| 384 | |
| 385 return 0; | |
| 386 } | |
| 387 | |
| 388 int irc_cmd_quote(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 389 { | |
| 390 char *buf; | |
| 391 | |
| 392 if (!args || !args[0]) | |
| 393 return 0; | |
| 394 | |
| 395 buf = irc_format(irc, "v", args[0]); | |
| 396 irc_send(irc, buf); | |
| 397 g_free(buf); | |
| 398 | |
| 399 return 0; | |
| 400 } | |
| 401 | |
| 402 int irc_cmd_query(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 403 { | |
| 404 GaimConversation *convo; | |
| 405 GaimConnection *gc; | |
| 406 | |
| 407 if (!args || !args[0]) | |
| 408 return 0; | |
| 409 | |
| 410 convo = gaim_conversation_new(GAIM_CONV_IM, irc->account, args[0]); | |
| 411 | |
| 412 if (args[1]) { | |
| 413 gc = gaim_account_get_connection(irc->account); | |
| 414 irc_cmd_privmsg(irc, cmd, target, args); | |
| 415 gaim_im_write(GAIM_IM(convo), gaim_connection_get_display_name(gc), | |
| 416 args[1], -1, WFLAG_SEND, time(NULL)); | |
| 417 } | |
| 418 | |
| 419 return 0; | |
| 420 } | |
| 421 | |
| 422 int irc_cmd_remove(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 423 { | |
| 424 char *buf; | |
| 425 | |
| 426 if (!args || !args[0]) | |
| 427 return 0; | |
| 428 | |
| 429 if (*target != '#' && *target != '&') /* not a channel, punt */ | |
| 430 return 0; | |
| 431 | |
| 432 if (args[1]) | |
| 433 buf = irc_format(irc, "vcn:", "REMOVE", target, args[0], args[1]); | |
| 434 else | |
| 435 buf = irc_format(irc, "vcn", "REMOVE", target, args[0]); | |
| 436 irc_send(irc, buf); | |
| 437 g_free(buf); | |
| 438 | |
| 439 return 0; | |
| 440 } | |
| 441 | |
| 442 int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 443 { | |
| 444 char *buf; | |
| 445 const char *topic; | |
| 446 GaimConversation *convo; | |
| 447 | |
| 448 if (!args) | |
| 449 return 0; | |
| 450 | |
| 451 convo = gaim_find_conversation_with_account(target, irc->account); | |
| 452 if (!convo || gaim_conversation_get_type(convo) != GAIM_CONV_CHAT) | |
| 6350 | 453 return 0; |
| 6333 | 454 |
| 455 if (!args[0]) { | |
| 456 topic = gaim_chat_get_topic (GAIM_CHAT(convo)); | |
| 457 | |
| 458 if (topic) | |
| 6350 | 459 buf = g_strdup_printf(_("current topic is: %s"), topic); |
| 6333 | 460 else |
| 461 buf = g_strdup(_("No topic is set")); | |
| 462 gaim_chat_write(GAIM_CHAT(convo), target, buf, WFLAG_SYSTEM|WFLAG_NOLOG, time(NULL)); | |
| 463 g_free(buf); | |
| 464 | |
| 465 return 0; | |
| 466 } | |
| 467 | |
| 468 buf = irc_format(irc, "vt:", "TOPIC", target, args[0]); | |
| 469 irc_send(irc, buf); | |
| 470 g_free(buf); | |
| 471 | |
| 472 return 0; | |
| 473 } | |
| 474 | |
| 475 int irc_cmd_wallops(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 476 { | |
| 477 char *buf; | |
| 478 | |
| 479 if (!args || !args[0]) | |
| 6350 | 480 return 0; |
| 6333 | 481 |
| 482 if (!strcmp(cmd, "wallops")) | |
| 483 buf = irc_format(irc, "v:", "WALLOPS", args[0]); | |
| 484 else if (!strcmp(cmd, "operwall")) | |
| 485 buf = irc_format(irc, "v:", "OPERWALL", args[0]); | |
| 6365 | 486 else |
| 487 return 0; | |
| 6333 | 488 |
| 489 irc_send(irc, buf); | |
| 490 g_free(buf); | |
| 491 | |
| 492 return 0; | |
| 493 } | |
| 494 | |
| 495 int irc_cmd_whois(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 496 { | |
| 497 char *buf; | |
| 498 | |
| 499 if (!args || !args[0]) | |
| 500 return 0; | |
| 501 | |
| 502 buf = irc_format(irc, "vn", "WHOIS", args[0]); | |
| 503 irc_send(irc, buf); | |
| 504 g_free(buf); | |
| 505 irc->whois.nick = g_strdup(args[0]); | |
| 506 | |
| 507 return 0; | |
| 508 } | |
| 509 | |
| 510 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops) | |
| 511 { | |
| 512 char *buf, mode[5]; | |
| 513 int i = 0; | |
| 514 | |
| 515 if (!sign) | |
| 516 return; | |
| 517 | |
| 518 while (ops[i]) { | |
| 519 if (ops[i + 2] && ops[i + 4]) { | |
| 520 g_snprintf(mode, sizeof(mode), "%s%s%s%s", sign, | |
| 521 ops[i], ops[i + 2], ops[i + 4]); | |
| 522 buf = irc_format(irc, "vcvnnn", "MODE", target, mode, | |
| 523 ops[i + 1], ops[i + 3], ops[i + 5]); | |
| 524 i += 6; | |
| 525 } else if (ops[i + 2]) { | |
| 526 g_snprintf(mode, sizeof(mode), "%s%s%s", | |
| 527 sign, ops[i], ops[i + 2]); | |
| 528 buf = irc_format(irc, "vcvnn", "MODE", target, mode, | |
| 529 ops[i + 1], ops[i + 3]); | |
| 530 i += 4; | |
| 531 } else { | |
| 532 g_snprintf(mode, sizeof(mode), "%s%s", sign, ops[i]); | |
| 533 buf = irc_format(irc, "vcvn", "MODE", target, mode, ops[i + 1]); | |
| 534 i += 2; | |
| 535 } | |
| 536 irc_send(irc, buf); | |
| 537 g_free(buf); | |
| 538 } | |
| 6350 | 539 |
| 540 return; | |
| 6333 | 541 } |
