Changeset e907683
- Timestamp:
- 2010-06-26T23:39:31Z (14 years ago)
- Branches:
- master
- Children:
- 84c3a72
- Parents:
- 92c8d41
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user-guide/commands.xml
r92c8d41 re907683 6 6 <bitlbee-command name="account"> 7 7 <short-description>IM-account list maintenance</short-description> 8 <syntax>account <action> [<arguments>]</syntax>8 <syntax>account [<account id>] <action> [<arguments>]</syntax> 9 9 10 10 <description> … … 99 99 100 100 <bitlbee-command name="del"> 101 <syntax>account del <account id></syntax>101 <syntax>account <account id> del</syntax> 102 102 103 103 <description> … … 114 114 115 115 <bitlbee-command name="on"> 116 <syntax>account on [<account id>]</syntax>116 <syntax>account [<account id>] on</syntax> 117 117 118 118 <description> … … 129 129 130 130 <bitlbee-command name="off"> 131 <syntax>account off [<account id>]</syntax>131 <syntax>account [<account id>] off</syntax> 132 132 133 133 <description> … … 153 153 154 154 <bitlbee-command name="set"> 155 <syntax>account set <account id></syntax>156 <syntax>account set <account id>/<setting></syntax>157 <syntax>account set <account id>/<setting> <value></syntax>158 <syntax>account set -del <account id>/<setting></syntax>155 <syntax>account <account id> set</syntax> 156 <syntax>account <account id> set <setting></syntax> 157 <syntax>account <account id> set <setting> <value></syntax> 158 <syntax>account <account id> set -del <setting></syntax> 159 159 160 160 <description> … … 181 181 182 182 <para> 183 Available actions: add, del, list, with and set. See <emphasis>help chat <action></emphasis> for more information.183 Available actions: add, with. See <emphasis>help chat <action></emphasis> for more information. 184 184 </para> 185 185 … … 205 205 </bitlbee-command> 206 206 207 <bitlbee-command name="del">208 <syntax>chat del <chat id></syntax>209 210 <description>211 <para>212 This commands deletes an chatroom from your list.213 </para>214 215 <para>216 The room ID can be a number (see <emphasis>chat list</emphasis>), or (part of) the name of the room/channel.217 </para>218 </description>219 </bitlbee-command>220 221 <bitlbee-command name="list">222 <syntax>chat list</syntax>223 224 <description>225 <para>226 This command gives you a list of all the chatrooms known by BitlBee.227 </para>228 </description>229 </bitlbee-command>230 231 207 <bitlbee-command name="with"> 232 208 <syntax>chat with <nickname></syntax> … … 235 211 <para> 236 212 While most <emphasis>chat</emphasis> subcommands are about named chatrooms, this command can be used to open an unnamed groupchat with one or more persons. This command is what <emphasis>/join #nickname</emphasis> used to do in older BitlBee versions. 237 </para>238 </description>239 </bitlbee-command>240 241 <bitlbee-command name="set">242 <syntax>chat set <chat id></syntax>243 <syntax>chat set <chat id>/<setting></syntax>244 <syntax>chat set <chat id>/<setting> <value></syntax>245 <syntax>chat set -del <chat id>/<setting></syntax>246 247 <description>248 <para>249 This command can be used to change various settings for chatrooms.250 </para>251 252 <para>253 For more infomation about a setting, see <emphasis>help set <setting></emphasis>.254 </para>255 256 <para>257 The room ID can be a number (see <emphasis>chat list</emphasis>), or (part of) the name of the room/channel.258 213 </para> 259 214 </description> -
root_commands.c
r92c8d41 re907683 241 241 typedef int (*cmd_set_checkflags)( irc_t*, set_t *set ); 242 242 243 static int cmd_set_real( irc_t *irc, char **cmd, cmd_set_findhead findhead, cmd_set_checkflags checkflags )244 { 245 char *set_ full = NULL, *set_name = NULL, *tmp;246 set_t **head;243 static int cmd_set_real( irc_t *irc, char **cmd, set_t **head, cmd_set_checkflags checkflags ) 244 { 245 char *set_name = NULL, *value = NULL; 246 gboolean del = FALSE; 247 247 248 248 if( cmd[1] && g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) 249 249 { 250 250 MIN_ARGS( 2, 0 ); 251 set_full = cmd[2]; 252 } 253 else 254 set_full = cmd[1]; 255 256 if( findhead == NULL ) 257 { 258 set_name = set_full; 259 260 head = &irc->b->set; 261 } 262 else 263 { 264 char *id; 265 266 if( ( tmp = strchr( set_full, '/' ) ) ) 267 { 268 id = g_strndup( set_full, ( tmp - set_full ) ); 269 set_name = tmp + 1; 270 } 271 else 272 { 273 id = g_strdup( set_full ); 274 } 275 276 if( ( head = findhead( irc, id ) ) == NULL ) 277 { 278 g_free( id ); 279 irc_usermsg( irc, "Could not find setting." ); 280 return 0; 281 } 282 g_free( id ); 283 } 284 285 if( cmd[1] && cmd[2] && set_name ) 251 set_name = cmd[2]; 252 del = TRUE; 253 } 254 else 255 { 256 set_name = cmd[1]; 257 value = cmd[2]; 258 } 259 260 if( set_name && ( value || del ) ) 286 261 { 287 262 set_t *s = set_find( head, set_name ); … … 291 266 return 0; 292 267 293 if( g_strncasecmp( cmd[1], "-del", 4 ) == 0)268 if( del ) 294 269 st = set_reset( head, set_name ); 295 270 else 296 st = set_setstr( head, set_name, cmd[2]);271 st = set_setstr( head, set_name, value ); 297 272 298 273 if( set_getstr( head, set_name ) == NULL ) 299 274 { 275 /* This happens when changing the passwd, for example. 276 Showing these msgs instead gives slightly clearer 277 feedback. */ 300 278 if( st ) 301 279 irc_usermsg( irc, "Setting changed successfully" ); … … 325 303 } 326 304 327 static set_t **cmd_account_set_findhead( irc_t *irc, char *id )328 {329 account_t *a;330 331 if( ( a = account_get( irc->b, id ) ) )332 return &a->set;333 else334 return NULL;335 }336 337 305 static int cmd_account_set_checkflags( irc_t *irc, set_t *s ) 338 306 { … … 386 354 387 355 irc_usermsg( irc, "Account successfully added" ); 388 } 389 else if( g_strcasecmp( cmd[1], "del" ) == 0 ) 390 { 391 MIN_ARGS( 2 ); 392 393 if( !( a = account_get( irc->b, cmd[2] ) ) ) 394 { 395 irc_usermsg( irc, "Invalid account" ); 396 } 397 else if( a->ic ) 398 { 399 irc_usermsg( irc, "Account is still logged in, can't delete" ); 400 } 401 else 402 { 403 account_del( irc->b, a ); 404 irc_usermsg( irc, "Account deleted" ); 405 } 356 357 return; 406 358 } 407 359 else if( g_strcasecmp( cmd[1], "list" ) == 0 ) … … 430 382 } 431 383 irc_usermsg( irc, "End of account list" ); 384 385 return; 386 } 387 else if( cmd[2] ) 388 { 389 /* Try the following two only if cmd[2] == NULL */ 432 390 } 433 391 else if( g_strcasecmp( cmd[1], "on" ) == 0 ) 434 392 { 435 if( cmd[2] ) 436 { 437 if( ( a = account_get( irc->b, cmd[2] ) ) ) 438 { 439 if( a->ic ) 440 { 441 irc_usermsg( irc, "Account already online" ); 442 return; 443 } 444 else 445 { 393 if ( irc->b->accounts ) 394 { 395 irc_usermsg( irc, "Trying to get all accounts connected..." ); 396 397 for( a = irc->b->accounts; a; a = a->next ) 398 if( !a->ic && a->auto_connect ) 446 399 account_on( irc->b, a ); 447 } 448 } 449 else 450 { 451 irc_usermsg( irc, "Invalid account" ); 452 return; 453 } 454 } 455 else 456 { 457 if ( irc->b->accounts ) 458 { 459 irc_usermsg( irc, "Trying to get all accounts connected..." ); 460 461 for( a = irc->b->accounts; a; a = a->next ) 462 if( !a->ic && a->auto_connect ) 463 account_on( irc->b, a ); 464 } 465 else 466 { 467 irc_usermsg( irc, "No accounts known. Use `account add' to add one." ); 468 } 469 } 400 } 401 else 402 { 403 irc_usermsg( irc, "No accounts known. Use `account add' to add one." ); 404 } 405 406 return; 470 407 } 471 408 else if( g_strcasecmp( cmd[1], "off" ) == 0 ) 472 409 { 473 if( !cmd[2] ) 474 { 475 irc_usermsg( irc, "Deactivating all active (re)connections..." ); 476 477 for( a = irc->b->accounts; a; a = a->next ) 478 { 479 if( a->ic ) 480 account_off( irc->b, a ); 481 else if( a->reconnect ) 482 cancel_auto_reconnect( a ); 483 } 484 } 485 else if( ( a = account_get( irc->b, cmd[2] ) ) ) 410 irc_usermsg( irc, "Deactivating all active (re)connections..." ); 411 412 for( a = irc->b->accounts; a; a = a->next ) 486 413 { 487 414 if( a->ic ) 488 {489 415 account_off( irc->b, a ); 490 }491 416 else if( a->reconnect ) 492 {493 417 cancel_auto_reconnect( a ); 494 irc_usermsg( irc, "Reconnect cancelled" ); 495 } 496 else 497 { 498 irc_usermsg( irc, "Account already offline" ); 499 return; 500 } 501 } 502 else 503 { 504 irc_usermsg( irc, "Invalid account" ); 505 return; 506 } 507 } 508 else if( g_strcasecmp( cmd[1], "set" ) == 0 ) 509 { 510 MIN_ARGS( 2 ); 511 512 cmd_set_real( irc, cmd + 1, cmd_account_set_findhead, cmd_account_set_checkflags ); 513 } 514 else 515 { 516 irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "account", cmd[1] ); 517 } 518 } 519 520 static set_t **cmd_channel_set_findhead( irc_t *irc, char *id ) 418 } 419 420 return; 421 } 422 423 MIN_ARGS( 2 ); 424 425 /* At least right now, don't accept on/off/set/del as account IDs even 426 if they're a proper match, since people not familiar with the new 427 syntax yet may get a confusing/nasty surprise. */ 428 if( g_strcasecmp( cmd[1], "on" ) == 0 || 429 g_strcasecmp( cmd[1], "off" ) == 0 || 430 g_strcasecmp( cmd[1], "set" ) == 0 || 431 g_strcasecmp( cmd[1], "del" ) == 0 || 432 ( a = account_get( irc->b, cmd[1] ) ) == NULL ) 433 { 434 irc_usermsg( irc, "Could not find account `%s'. Note that the syntax " 435 "of the account command changed, see \x02help account\x02.", cmd[1] ); 436 437 return; 438 } 439 440 if( g_strcasecmp( cmd[2], "del" ) == 0 ) 441 { 442 if( a->ic ) 443 { 444 irc_usermsg( irc, "Account is still logged in, can't delete" ); 445 } 446 else 447 { 448 account_del( irc->b, a ); 449 irc_usermsg( irc, "Account deleted" ); 450 } 451 } 452 else if( g_strcasecmp( cmd[2], "on" ) == 0 ) 453 { 454 if( a->ic ) 455 irc_usermsg( irc, "Account already online" ); 456 else 457 account_on( irc->b, a ); 458 } 459 else if( g_strcasecmp( cmd[2], "off" ) == 0 ) 460 { 461 if( a->ic ) 462 { 463 account_off( irc->b, a ); 464 } 465 else if( a->reconnect ) 466 { 467 cancel_auto_reconnect( a ); 468 irc_usermsg( irc, "Reconnect cancelled" ); 469 } 470 else 471 { 472 irc_usermsg( irc, "Account already offline" ); 473 } 474 } 475 else if( g_strcasecmp( cmd[2], "set" ) == 0 ) 476 { 477 cmd_set_real( irc, cmd + 2, &a->set, cmd_account_set_checkflags ); 478 } 479 else 480 { 481 irc_usermsg( irc, "Unknown command: %s [...] %s. Please use \x02help commands\x02 to get a list of available commands.", "account", cmd[2] ); 482 } 483 } 484 485 static void cmd_channel( irc_t *irc, char **cmd ) 521 486 { 522 487 irc_channel_t *ic; 523 488 524 if( ( ic = irc_channel_get( irc, id ) ) ) 525 return &ic->set; 526 else 527 return NULL; 528 } 529 530 static void cmd_channel( irc_t *irc, char **cmd ) 531 { 532 if( g_strcasecmp( cmd[1], "set" ) == 0 ) 533 { 534 MIN_ARGS( 2 ); 535 536 cmd_set_real( irc, cmd + 1, cmd_channel_set_findhead, NULL ); 537 } 538 else if( g_strcasecmp( cmd[1], "list" ) == 0 ) 489 if( g_strcasecmp( cmd[1], "list" ) == 0 ) 539 490 { 540 491 GSList *l; … … 555 506 } 556 507 irc_usermsg( irc, "End of channel list" ); 557 } 558 else if( g_strcasecmp( cmd[1], "del" ) == 0 ) 559 { 560 irc_channel_t *ic; 561 562 MIN_ARGS( 2 ); 563 564 if( ( ic = irc_channel_get( irc, cmd[2] ) ) && 565 !( ic->flags & IRC_CHANNEL_JOINED ) && 508 509 return; 510 } 511 512 MIN_ARGS( 2 ); 513 514 if( ( ic = irc_channel_get( irc, cmd[1] ) ) == NULL ) 515 { 516 irc_usermsg( irc, "Could not find channel `%s'", cmd[1] ); 517 return; 518 } 519 520 if( g_strcasecmp( cmd[2], "set" ) == 0 ) 521 { 522 cmd_set_real( irc, cmd + 2, &ic->set, NULL ); 523 } 524 else if( g_strcasecmp( cmd[2], "del" ) == 0 ) 525 { 526 if( !( ic->flags & IRC_CHANNEL_JOINED ) && 566 527 ic != ic->irc->default_channel ) 567 528 { … … 576 537 else 577 538 { 578 irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "channel", cmd[1] );539 irc_usermsg( irc, "Unknown command: %s [...] %s. Please use \x02help commands\x02 to get a list of available commands.", "channel", cmd[1] ); 579 540 } 580 541 } … … 912 873 static void cmd_set( irc_t *irc, char **cmd ) 913 874 { 914 cmd_set_real( irc, cmd, NULL, NULL );875 cmd_set_real( irc, cmd, &irc->b->set, NULL ); 915 876 } 916 877
Note: See TracChangeset
for help on using the changeset viewer.