Mercurial > pidgin
annotate src/protocols/irc/cmds.c @ 8907:00138e366ef8
[gaim-migrate @ 9677]
" Fixes a few warnings on 64bit machines. Also fixes
yahoo auth on 64bit machines which would have taken me
awhile if marv didn't point me in the right direction.
I've applied to my local 32bit copy and everything
seems to be working fine." --Gary Kramlich
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Sat, 08 May 2004 23:34:30 +0000 |
| parents | da687392cbcb |
| children | 933a19e3a6b3 |
| 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" | |
| 8504 | 26 #include "debug.h" |
| 6333 | 27 #include "notify.h" |
| 8624 | 28 #include "util.h" |
| 8504 | 29 |
| 6333 | 30 #include "irc.h" |
| 31 | |
| 32 | |
| 33 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops); | |
| 34 | |
| 35 int irc_cmd_default(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 36 { | |
| 37 GaimConversation *convo = gaim_find_conversation_with_account(target, irc->account); | |
| 38 char *buf; | |
| 39 | |
| 40 if (!convo) | |
| 6350 | 41 return 1; |
| 6333 | 42 |
| 43 buf = g_strdup_printf(_("Unknown command: %s"), cmd); | |
| 44 if (gaim_conversation_get_type(convo) == GAIM_CONV_IM) | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
45 gaim_conv_im_write(GAIM_CONV_IM(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 46 else |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
47 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 48 g_free(buf); |
| 49 | |
| 50 return 1; | |
| 51 } | |
| 52 | |
| 53 int irc_cmd_away(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 54 { | |
| 55 char *buf, *message, *cur; | |
| 56 | |
| 57 if (args[0] && strcmp(cmd, "back")) { | |
| 58 message = strdup(args[0]); | |
| 59 for (cur = message; *cur; cur++) { | |
| 60 if (*cur == '\n') | |
| 61 *cur = ' '; | |
| 62 } | |
| 63 buf = irc_format(irc, "v:", "AWAY", message); | |
| 64 g_free(message); | |
| 65 } else { | |
| 66 buf = irc_format(irc, "v", "AWAY"); | |
| 67 } | |
| 68 irc_send(irc, buf); | |
| 69 g_free(buf); | |
| 70 | |
| 71 return 0; | |
| 72 } | |
| 73 | |
| 74 int irc_cmd_ctcp_action(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 75 { | |
| 76 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 77 char *action, *dst, **newargs; | |
| 78 const char *src; | |
| 79 GaimConversation *convo; | |
| 80 | |
| 81 if (!args || !args[0] || !gc) | |
| 82 return 0; | |
| 83 | |
| 6376 | 84 action = g_malloc(strlen(args[0]) + 10); |
| 6333 | 85 |
| 86 sprintf(action, "\001ACTION "); | |
| 87 | |
| 88 src = args[0]; | |
| 89 dst = action + 8; | |
| 90 while (*src) { | |
| 91 if (*src == '\n') { | |
| 92 if (*(src + 1) == '\0') { | |
| 93 break; | |
| 94 } else { | |
| 95 *dst++ = ' '; | |
| 96 src++; | |
| 97 continue; | |
| 98 } | |
| 99 } | |
| 100 *dst++ = *src++; | |
| 101 } | |
| 102 *dst++ = '\001'; | |
| 103 *dst = '\0'; | |
| 104 | |
| 105 newargs = g_new0(char *, 2); | |
| 106 newargs[0] = g_strdup(target); | |
| 107 newargs[1] = action; | |
| 108 irc_cmd_privmsg(irc, cmd, target, (const char **)newargs); | |
| 109 g_free(newargs[0]); | |
| 110 g_free(newargs[1]); | |
| 111 g_free(newargs); | |
| 112 | |
| 113 convo = gaim_find_conversation_with_account(target, irc->account); | |
| 114 if (convo && gaim_conversation_get_type(convo) == GAIM_CONV_CHAT) { | |
| 115 action = g_strdup_printf("/me %s", args[0]); | |
| 116 if (action[strlen(action) - 1] == '\n') | |
| 117 action[strlen(action) - 1] = '\0'; | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
118 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), |
| 6333 | 119 gaim_connection_get_display_name(gc), |
| 120 0, action, time(NULL)); | |
| 121 g_free(action); | |
| 122 } | |
| 123 | |
| 124 return 1; | |
| 125 } | |
| 126 | |
|
6415
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
127 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
|
128 { |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
129 GaimConversation *convo = gaim_find_conversation_with_account(target, irc->account); |
|
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 /* XXX we should eventually have per-command help */ |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
132 |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
133 if (!convo) |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
134 return 0; |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
135 |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
136 if (gaim_conversation_get_type(convo) == GAIM_CONV_CHAT) { |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
137 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", _("<B>Supported IRC Commands:</B><BR>" |
|
6415
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
138 "AWAY INVITE JOIN KICK<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
139 "ME MODE MSG NAMES<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
140 "NICK OP DEOP OPERWALL<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
141 "PART PING QUERY QUIT<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
142 "QUOTE REMOVE TOPIC UMODE<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
143 "VOICE DEVOICE WALLOPS WHOIS<BR>"), |
| 6621 | 144 GAIM_MESSAGE_NO_LOG, time(NULL)); |
|
6415
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
145 } else { |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
146 gaim_conv_im_write(GAIM_CONV_IM(convo), "", _("<B>Supported IRC Commands:</B><BR>" |
|
6415
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
147 "AWAY JOIN ME MODE<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
148 "MSG NICK OPERWALL PING<BR>" |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
149 "QUERY QUIT QUOTE UMODE<BR>" |
| 6982 | 150 "WALLOPS WHOIS"), GAIM_MESSAGE_NO_LOG, time(NULL)); |
|
6415
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
151 } |
|
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 return 0; |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
154 } |
|
e3be6b9744b7
[gaim-migrate @ 6922]
Christian Hammond <chipx86@chipx86.com>
parents:
6376
diff
changeset
|
155 |
| 6333 | 156 int irc_cmd_invite(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 157 { | |
| 158 char *buf; | |
| 159 | |
| 160 if (!args || !args[0] || !(args[1] || target)) | |
| 161 return 0; | |
| 162 | |
| 163 buf = irc_format(irc, "vnc", "INVITE", args[0], args[1] ? args[1] : target); | |
| 164 irc_send(irc, buf); | |
| 165 g_free(buf); | |
| 166 | |
| 167 return 0; | |
| 168 } | |
| 169 | |
| 170 int irc_cmd_join(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 171 { | |
| 172 char *buf; | |
| 173 | |
| 174 if (!args || !args[0]) | |
| 175 return 0; | |
| 176 | |
| 177 if (args[1]) | |
| 178 buf = irc_format(irc, "vcv", "JOIN", args[0], args[1]); | |
| 179 else | |
| 180 buf = irc_format(irc, "vc", "JOIN", args[0]); | |
| 181 irc_send(irc, buf); | |
| 182 g_free(buf); | |
| 183 | |
| 184 return 0; | |
| 185 } | |
| 186 | |
| 187 int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 188 { | |
| 189 char *buf; | |
| 190 GaimConversation *convo; | |
| 191 | |
| 192 if (!args || !args[0]) | |
| 193 return 0; | |
| 194 | |
| 195 convo = gaim_find_conversation_with_account(target, irc->account); | |
| 196 if (!convo || gaim_conversation_get_type(convo) != GAIM_CONV_CHAT) | |
| 6350 | 197 return 0; |
| 6333 | 198 |
| 199 if (args[1]) | |
| 200 buf = irc_format(irc, "vcn:", "KICK", target, args[0], args[1]); | |
| 201 else | |
| 202 buf = irc_format(irc, "vcn", "KICK", target, args[0]); | |
| 203 irc_send(irc, buf); | |
| 204 g_free(buf); | |
| 205 | |
| 206 return 0; | |
| 207 } | |
| 208 | |
| 8114 | 209 int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 210 { | |
| 8352 | 211 gaim_roomlist_show_with_account(irc->account); |
| 8114 | 212 |
| 213 return 0; | |
| 214 } | |
| 215 | |
| 6333 | 216 int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args) |
| 217 { | |
| 218 GaimConnection *gc; | |
| 219 char *buf; | |
| 220 | |
| 221 if (!args) | |
| 222 return 0; | |
| 223 | |
| 224 if (!strcmp(cmd, "mode")) { | |
| 225 if (!args[0] && (*target == '#' || *target == '&')) | |
| 226 buf = irc_format(irc, "vc", "MODE", target); | |
| 227 else if (args[0] && (*args[0] == '+' || *args[0] == '-')) | |
| 228 buf = irc_format(irc, "vcv", "MODE", target, args[0]); | |
| 229 else if (args[0]) | |
| 230 buf = irc_format(irc, "vv", "MODE", args[0]); | |
| 231 else | |
| 6350 | 232 return 0; |
| 6333 | 233 } else if (!strcmp(cmd, "umode")) { |
| 234 if (!args[0]) | |
| 6350 | 235 return 0; |
| 6333 | 236 gc = gaim_account_get_connection(irc->account); |
| 237 buf = irc_format(irc, "vnv", "MODE", gaim_connection_get_display_name(gc), args[0]); | |
| 6365 | 238 } else { |
| 239 return 0; | |
| 6333 | 240 } |
| 6365 | 241 |
| 6333 | 242 irc_send(irc, buf); |
| 243 g_free(buf); | |
| 244 | |
| 245 return 0; | |
| 246 } | |
| 247 | |
| 248 int irc_cmd_names(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 249 { | |
| 250 char *buf; | |
| 251 | |
| 252 if (!args) | |
| 253 return 0; | |
| 254 | |
| 255 buf = irc_format(irc, "vc", "NAMES", args[0] ? args[0] : target); | |
| 256 irc_send(irc, buf); | |
| 257 g_free(buf); | |
| 258 | |
| 259 irc->nameconv = g_strdup(target); | |
| 260 | |
| 261 return 0; | |
| 262 } | |
| 263 | |
| 264 int irc_cmd_nick(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 265 { | |
| 266 char *buf; | |
| 267 | |
| 268 if (!args || !args[0]) | |
| 269 return 0; | |
| 270 | |
| 271 buf = irc_format(irc, "v:", "NICK", args[0]); | |
| 272 irc_send(irc, buf); | |
| 273 g_free(buf); | |
| 274 | |
| 275 return 0; | |
| 276 } | |
| 277 | |
| 278 int irc_cmd_op(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 279 { | |
| 280 char **nicks, **ops, *sign, *mode; | |
| 281 int i = 0, used = 0; | |
| 282 | |
| 283 if (!args || !args[0] || !*args[0]) | |
| 284 return 0; | |
| 285 | |
| 286 if (!strcmp(cmd, "op")) { | |
| 287 sign = "+"; | |
| 288 mode = "o"; | |
| 289 } else if (!strcmp(cmd, "deop")) { | |
| 290 sign = "-"; | |
| 291 mode = "o"; | |
| 292 } else if (!strcmp(cmd, "voice")) { | |
| 293 sign = "+"; | |
| 294 mode = "v"; | |
| 295 } else if (!strcmp(cmd, "devoice")) { | |
| 296 sign = "-"; | |
| 297 mode = "v"; | |
| 298 } else { | |
| 299 gaim_debug(GAIM_DEBUG_ERROR, "irc", "invalid 'op' command '%s'\n", cmd); | |
| 300 return 0; | |
| 301 } | |
| 302 | |
| 303 nicks = g_strsplit(args[0], " ", -1); | |
| 304 | |
| 305 for (i = 0; nicks[i]; i++) | |
| 306 /* nothing */; | |
| 307 ops = g_new0(char *, i * 2 + 1); | |
| 308 | |
| 309 for (i = 0; nicks[i]; i++) { | |
| 310 if (!*nicks[i]) | |
| 311 continue; | |
| 312 ops[used++] = mode; | |
| 313 ops[used++] = nicks[i]; | |
| 314 } | |
| 315 | |
| 316 irc_do_mode(irc, target, sign, ops); | |
| 317 g_free(ops); | |
| 318 | |
| 6350 | 319 return 0; |
| 6333 | 320 } |
| 321 | |
| 322 int irc_cmd_part(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 323 { | |
| 324 char *buf; | |
| 325 | |
| 326 if (!args) | |
| 327 return 0; | |
| 328 | |
| 329 if (args[1]) | |
| 330 buf = irc_format(irc, "vc:", "PART", args[0] ? args[0] : target, args[1]); | |
| 331 else | |
| 332 buf = irc_format(irc, "vc", "PART", args[0] ? args[0] : target); | |
| 333 irc_send(irc, buf); | |
| 334 g_free(buf); | |
| 335 | |
| 336 return 0; | |
| 337 } | |
| 338 | |
| 339 int irc_cmd_ping(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 340 { | |
| 341 char *stamp; | |
| 342 char *buf; | |
| 343 | |
| 344 if (args && args[0]) { | |
| 345 if (*args[0] == '#' || *args[0] == '&') | |
| 346 return 0; | |
| 347 stamp = g_strdup_printf("\001PING %lu\001", time(NULL)); | |
| 348 buf = irc_format(irc, "vn:", "PRIVMSG", args[0], stamp); | |
| 349 g_free(stamp); | |
| 350 } else { | |
| 6350 | 351 stamp = g_strdup_printf("%s %lu", target, time(NULL)); |
| 6333 | 352 buf = irc_format(irc, "v:", "PING", stamp); |
| 353 g_free(stamp); | |
| 354 } | |
| 355 irc_send(irc, buf); | |
| 356 g_free(buf); | |
| 357 | |
| 358 return 0; | |
| 359 } | |
| 360 | |
| 361 int irc_cmd_privmsg(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 362 { | |
| 363 const char *cur, *end; | |
| 364 char *msg, *buf; | |
| 365 | |
| 366 if (!args || !args[0] || !args[1]) | |
| 367 return 0; | |
| 368 | |
| 369 cur = args[1]; | |
| 370 end = args[1]; | |
| 371 while (*end && *cur) { | |
| 372 end = strchr(cur, '\n'); | |
| 373 if (!end) | |
| 374 end = cur + strlen(cur); | |
| 375 msg = g_strndup(cur, end - cur); | |
| 376 buf = irc_format(irc, "vt:", "PRIVMSG", args[0], msg); | |
| 377 irc_send(irc, buf); | |
| 378 g_free(msg); | |
| 379 g_free(buf); | |
| 380 cur = end + 1; | |
| 381 } | |
| 382 | |
| 383 return 0; | |
| 384 } | |
| 385 | |
| 386 int irc_cmd_quit(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 387 { | |
| 388 char *buf; | |
| 389 | |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6365
diff
changeset
|
390 buf = irc_format(irc, "v:", "QUIT", (args && args[0]) ? args[0] : "Download Gaim: " GAIM_WEBSITE); |
| 6333 | 391 irc_send(irc, buf); |
| 392 g_free(buf); | |
| 393 | |
| 394 return 0; | |
| 395 } | |
| 396 | |
| 397 int irc_cmd_quote(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 398 { | |
| 399 char *buf; | |
| 400 | |
| 401 if (!args || !args[0]) | |
| 402 return 0; | |
| 403 | |
| 404 buf = irc_format(irc, "v", args[0]); | |
| 405 irc_send(irc, buf); | |
| 406 g_free(buf); | |
| 407 | |
| 408 return 0; | |
| 409 } | |
| 410 | |
| 411 int irc_cmd_query(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 412 { | |
| 413 GaimConversation *convo; | |
| 414 GaimConnection *gc; | |
| 415 | |
| 416 if (!args || !args[0]) | |
| 417 return 0; | |
| 418 | |
| 419 convo = gaim_conversation_new(GAIM_CONV_IM, irc->account, args[0]); | |
| 420 | |
| 421 if (args[1]) { | |
| 422 gc = gaim_account_get_connection(irc->account); | |
| 423 irc_cmd_privmsg(irc, cmd, target, args); | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
424 gaim_conv_im_write(GAIM_CONV_IM(convo), gaim_connection_get_display_name(gc), |
| 6982 | 425 args[1], GAIM_MESSAGE_SEND, time(NULL)); |
| 6333 | 426 } |
| 427 | |
| 428 return 0; | |
| 429 } | |
| 430 | |
| 431 int irc_cmd_remove(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 432 { | |
| 433 char *buf; | |
| 434 | |
| 435 if (!args || !args[0]) | |
| 436 return 0; | |
| 437 | |
| 438 if (*target != '#' && *target != '&') /* not a channel, punt */ | |
| 439 return 0; | |
| 440 | |
| 441 if (args[1]) | |
| 442 buf = irc_format(irc, "vcn:", "REMOVE", target, args[0], args[1]); | |
| 443 else | |
| 444 buf = irc_format(irc, "vcn", "REMOVE", target, args[0]); | |
| 445 irc_send(irc, buf); | |
| 446 g_free(buf); | |
| 447 | |
| 448 return 0; | |
| 449 } | |
| 450 | |
| 451 int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 452 { | |
| 453 char *buf; | |
| 454 const char *topic; | |
| 455 GaimConversation *convo; | |
| 456 | |
| 457 if (!args) | |
| 458 return 0; | |
| 459 | |
| 460 convo = gaim_find_conversation_with_account(target, irc->account); | |
| 461 if (!convo || gaim_conversation_get_type(convo) != GAIM_CONV_CHAT) | |
| 6350 | 462 return 0; |
| 6333 | 463 |
| 464 if (!args[0]) { | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
465 topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(convo)); |
| 6333 | 466 |
| 8504 | 467 if (topic) { |
| 468 char *tmp = gaim_escape_html(topic); | |
| 469 buf = g_strdup_printf(_("current topic is: %s"), tmp); | |
| 470 g_free(tmp); | |
| 471 } else | |
| 6333 | 472 buf = g_strdup(_("No topic is set")); |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
473 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), target, buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 474 g_free(buf); |
| 475 | |
| 476 return 0; | |
| 477 } | |
| 478 | |
| 479 buf = irc_format(irc, "vt:", "TOPIC", target, args[0]); | |
| 480 irc_send(irc, buf); | |
| 481 g_free(buf); | |
| 482 | |
| 483 return 0; | |
| 484 } | |
| 485 | |
| 486 int irc_cmd_wallops(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 487 { | |
| 488 char *buf; | |
| 489 | |
| 490 if (!args || !args[0]) | |
| 6350 | 491 return 0; |
| 6333 | 492 |
| 493 if (!strcmp(cmd, "wallops")) | |
| 494 buf = irc_format(irc, "v:", "WALLOPS", args[0]); | |
| 495 else if (!strcmp(cmd, "operwall")) | |
| 496 buf = irc_format(irc, "v:", "OPERWALL", args[0]); | |
| 6365 | 497 else |
| 498 return 0; | |
| 6333 | 499 |
| 500 irc_send(irc, buf); | |
| 501 g_free(buf); | |
| 502 | |
| 503 return 0; | |
| 504 } | |
| 505 | |
| 506 int irc_cmd_whois(struct irc_conn *irc, const char *cmd, const char *target, const char **args) | |
| 507 { | |
| 508 char *buf; | |
| 509 | |
| 510 if (!args || !args[0]) | |
| 511 return 0; | |
| 512 | |
| 513 buf = irc_format(irc, "vn", "WHOIS", args[0]); | |
| 514 irc_send(irc, buf); | |
| 515 g_free(buf); | |
| 516 irc->whois.nick = g_strdup(args[0]); | |
| 517 | |
| 518 return 0; | |
| 519 } | |
| 520 | |
| 521 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops) | |
| 522 { | |
| 523 char *buf, mode[5]; | |
| 524 int i = 0; | |
| 525 | |
| 526 if (!sign) | |
| 527 return; | |
| 528 | |
| 529 while (ops[i]) { | |
| 530 if (ops[i + 2] && ops[i + 4]) { | |
| 531 g_snprintf(mode, sizeof(mode), "%s%s%s%s", sign, | |
| 532 ops[i], ops[i + 2], ops[i + 4]); | |
| 533 buf = irc_format(irc, "vcvnnn", "MODE", target, mode, | |
| 534 ops[i + 1], ops[i + 3], ops[i + 5]); | |
| 535 i += 6; | |
| 536 } else if (ops[i + 2]) { | |
| 537 g_snprintf(mode, sizeof(mode), "%s%s%s", | |
| 538 sign, ops[i], ops[i + 2]); | |
| 539 buf = irc_format(irc, "vcvnn", "MODE", target, mode, | |
| 540 ops[i + 1], ops[i + 3]); | |
| 541 i += 4; | |
| 542 } else { | |
| 543 g_snprintf(mode, sizeof(mode), "%s%s", sign, ops[i]); | |
| 544 buf = irc_format(irc, "vcvn", "MODE", target, mode, ops[i + 1]); | |
| 545 i += 2; | |
| 546 } | |
| 547 irc_send(irc, buf); | |
| 548 g_free(buf); | |
| 549 } | |
| 6350 | 550 |
| 551 return; | |
| 6333 | 552 } |
