Changeset 3ddb7477 for irc_commands.c
- Timestamp:
- 2010-03-26T12:14:37Z (14 years ago)
- Branches:
- master
- Children:
- ebaebfe
- Parents:
- ba7d16f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_commands.c
rba7d16f r3ddb7477 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-20 06Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 39 39 out we don't require it, which will break this feature.) 40 40 Try to identify using the given password. */ 41 return root_command( irc, send_cmd );41 /*return root_command( irc, send_cmd );*/ 42 42 } 43 43 /* Handling in pre-logged-in state, first see if this server is … … 53 53 else if( global.conf->auth_pass ) 54 54 { 55 irc_ reply( irc, 464, ":Incorrect password" );55 irc_send_num( irc, 464, ":Incorrect password" ); 56 56 } 57 57 else 58 58 { 59 59 /* Remember the password and try to identify after USER/NICK. */ 60 irc_setpass( irc, cmd[1] );60 /*irc_setpass( irc, cmd[1] ); */ 61 61 irc_check_login( irc ); 62 62 } … … 65 65 static void irc_cmd_user( irc_t *irc, char **cmd ) 66 66 { 67 irc->user = g_strdup( cmd[1] );68 irc-> realname = g_strdup( cmd[4] );67 irc->user->user = g_strdup( cmd[1] ); 68 irc->user->fullname = g_strdup( cmd[4] ); 69 69 70 70 irc_check_login( irc ); … … 73 73 static void irc_cmd_nick( irc_t *irc, char **cmd ) 74 74 { 75 if( irc->nick ) 76 { 77 irc_reply( irc, 438, ":The hand of the deity is upon thee, thy nick may not change" ); 78 } 79 /* This is not clean, but for now it'll have to be like this... */ 80 else if( ( nick_cmp( cmd[1], irc->mynick ) == 0 ) || ( nick_cmp( cmd[1], NS_NICK ) == 0 ) ) 81 { 82 irc_reply( irc, 433, ":This nick is already in use" ); 75 if( irc->user->nick ) 76 { 77 irc_send_num( irc, 438, ":The hand of the deity is upon thee, thy nick may not change" ); 78 } 79 else if( irc_user_find( irc, cmd[1] ) ) 80 { 81 irc_send_num( irc, 433, ":This nick is already in use" ); 83 82 } 84 83 else if( !nick_ok( cmd[1] ) ) 85 84 { 86 85 /* [SH] Invalid characters. */ 87 irc_ reply( irc, 432, ":This nick contains invalid characters" );88 } 89 else 90 { 91 irc-> nick = g_strdup( cmd[1] );86 irc_send_num( irc, 432, ":This nick contains invalid characters" ); 87 } 88 else 89 { 90 irc->user->nick = g_strdup( cmd[1] ); 92 91 93 92 irc_check_login( irc ); … … 95 94 } 96 95 96 #if 0 97 97 static void irc_cmd_quit( irc_t *irc, char **cmd ) 98 98 { … … 116 116 { 117 117 irc_umode_set( irc, "+o", 1 ); 118 irc_ reply( irc, 381, ":Password accepted" );119 } 120 else 121 { 122 irc_ reply( irc, 432, ":Incorrect password" );118 irc_send_num( irc, 381, ":Password accepted" ); 119 } 120 else 121 { 122 irc_send_num( irc, 432, ":Incorrect password" ); 123 123 } 124 124 } … … 131 131 { 132 132 if( *cmd[2] == '+' || *cmd[2] == '-' ) 133 irc_ reply( irc, 477, "%s :Can't change channel modes", cmd[1] );133 irc_send_num( irc, 477, "%s :Can't change channel modes", cmd[1] ); 134 134 else if( *cmd[2] == 'b' ) 135 irc_ reply( irc, 368, "%s :No bans possible", cmd[1] );135 irc_send_num( irc, 368, "%s :No bans possible", cmd[1] ); 136 136 } 137 137 else 138 irc_ reply( irc, 324, "%s +%s", cmd[1], CMODE );138 irc_send_num( irc, 324, "%s +%s", cmd[1], CMODE ); 139 139 } 140 140 else … … 145 145 irc_umode_set( irc, cmd[2], 0 ); 146 146 else 147 irc_ reply( irc, 221, "+%s", irc->umode );147 irc_send_num( irc, 221, "+%s", irc->umode ); 148 148 } 149 149 else 150 irc_ reply( irc, 502, ":Don't touch their modes" );150 irc_send_num( irc, 502, ":Don't touch their modes" ); 151 151 } 152 152 } … … 183 183 else 184 184 { 185 irc_ reply( irc, 403, "%s :No such channel", cmd[1] );185 irc_send_num( irc, 403, "%s :No such channel", cmd[1] ); 186 186 } 187 187 } … … 197 197 198 198 if( strchr( CTYPES, cmd[1][0] ) == NULL || cmd[1][1] == 0 ) 199 irc_ reply( irc, 479, "%s :Invalid channel name", cmd[1] );199 irc_send_num( irc, 479, "%s :Invalid channel name", cmd[1] ); 200 200 else if( ( c = chat_bychannel( irc, cmd[1] ) ) && c->acc && c->acc->ic ) 201 201 chat_join( irc, c, cmd[2] ); 202 202 else 203 irc_ reply( irc, 403, "%s :No such channel", cmd[1] );203 irc_send_num( irc, 403, "%s :No such channel", cmd[1] ); 204 204 } 205 205 } … … 215 215 { 216 216 c->ic->acc->prpl->chat_invite( c, u->handle, NULL ); 217 irc_ reply( irc, 341, "%s %s", nick, channel );217 irc_send_num( irc, 341, "%s %s", nick, channel ); 218 218 return; 219 219 } 220 220 221 irc_ reply( irc, 482, "%s :Invite impossible; User/Channel non-existent or incompatible", channel );221 irc_send_num( irc, 482, "%s :Invite impossible; User/Channel non-existent or incompatible", channel ); 222 222 } 223 223 … … 226 226 if ( !cmd[2] ) 227 227 { 228 irc_ reply( irc, 412, ":No text to send" );228 irc_send_num( irc, 412, ":No text to send" ); 229 229 } 230 230 else if ( irc->nick && g_strcasecmp( cmd[1], irc->nick ) == 0 ) … … 283 283 while( u ) 284 284 { 285 irc_ reply( irc, 352, "%s %s %s %s %s %c :0 %s", u->online ? irc->channel : "*", u->user, u->host, irc->myhost, u->nick, u->online ? ( u->away ? 'G' : 'H' ) : 'G', u->realname );285 irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s", u->online ? irc->channel : "*", u->user, u->host, irc->myhost, u->nick, u->online ? ( u->away ? 'G' : 'H' ) : 'G', u->realname ); 286 286 u = u->next; 287 287 } … … 290 290 { 291 291 if( u->online ) 292 irc_ reply( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname );292 irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname ); 293 293 u = u->next; 294 294 } … … 297 297 { 298 298 if( ( u = user_findhandle( c->ic, l->data ) ) ) 299 irc_ reply( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname );299 irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname ); 300 300 } 301 301 else if( ( u = user_find( irc, channel ) ) ) 302 irc_ reply( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->online ? ( u->away ? 'G' : 'H' ) : 'G', u->realname );303 304 irc_ reply( irc, 315, "%s :End of /WHO list", channel?channel:"**" );302 irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->online ? ( u->away ? 'G' : 'H' ) : 'G', u->realname ); 303 304 irc_send_num( irc, 315, "%s :End of /WHO list", channel?channel:"**" ); 305 305 } 306 306 … … 320 320 { 321 321 if( u->online && u->away ) 322 irc_ reply( irc, 302, ":%s=-%s@%s", u->nick, u->user, u->host );322 irc_send_num( irc, 302, ":%s=-%s@%s", u->nick, u->user, u->host ); 323 323 else 324 irc_ reply( irc, 302, ":%s=+%s@%s", u->nick, u->user, u->host );324 irc_send_num( irc, 302, ":%s=+%s@%s", u->nick, u->user, u->host ); 325 325 } 326 326 } … … 377 377 buff[strlen(buff)-1] = '\0'; 378 378 379 irc_ reply( irc, 303, ":%s", buff );379 irc_send_num( irc, 303, ":%s", buff ); 380 380 } 381 381 … … 406 406 407 407 if( u && u->online ) 408 irc_ reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" );408 irc_send_num( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" ); 409 409 else 410 irc_ reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" );410 irc_send_num( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" ); 411 411 } 412 412 else if( cmd[i][0] == '-' ) … … 419 419 g_free( okey ); 420 420 421 irc_ reply( irc, 602, "%s %s %s %d :%s", nick, "*", "*", 0, "Stopped watching" );421 irc_send_num( irc, 602, "%s %s %s %d :%s", nick, "*", "*", 0, "Stopped watching" ); 422 422 } 423 423 } … … 463 463 u->away[j] = 0; 464 464 465 irc_ reply( irc, 306, ":You're now away: %s", u->away );465 irc_send_num( irc, 306, ":You're now away: %s", u->away ); 466 466 /* irc_umode_set( irc, irc->myhost, "+a" ); */ 467 467 } … … 471 471 u->away = NULL; 472 472 /* irc_umode_set( irc, irc->myhost, "-a" ); */ 473 irc_ reply( irc, 305, ":Welcome back" );473 irc_send_num( irc, 305, ":Welcome back" ); 474 474 } 475 475 … … 484 484 if( u ) 485 485 { 486 irc_ reply( irc, 311, "%s %s %s * :%s", u->nick, u->user, u->host, u->realname );486 irc_send_num( irc, 311, "%s %s %s * :%s", u->nick, u->user, u->host, u->realname ); 487 487 488 488 if( u->ic ) 489 irc_ reply( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user,489 irc_send_num( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user, 490 490 u->ic->acc->server && *u->ic->acc->server ? u->ic->acc->server : "", 491 491 u->ic->acc->prpl->name ); 492 492 else 493 irc_ reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO );493 irc_send_num( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO ); 494 494 495 495 if( !u->online ) 496 irc_ reply( irc, 301, "%s :%s", u->nick, "User is offline" );496 irc_send_num( irc, 301, "%s :%s", u->nick, "User is offline" ); 497 497 else if( u->away ) 498 irc_ reply( irc, 301, "%s :%s", u->nick, u->away );498 irc_send_num( irc, 301, "%s :%s", u->nick, u->away ); 499 499 if( u->status_msg ) 500 irc_ reply( irc, 333, "%s :Status: %s", u->nick, u->status_msg );501 502 irc_ reply( irc, 318, "%s :End of /WHOIS list", nick );503 } 504 else 505 { 506 irc_ reply( irc, 401, "%s :Nick does not exist", nick );500 irc_send_num( irc, 333, "%s :Status: %s", u->nick, u->status_msg ); 501 502 irc_send_num( irc, 318, "%s :End of /WHOIS list", nick ); 503 } 504 else 505 { 506 irc_send_num( irc, 401, "%s :Nick does not exist", nick ); 507 507 } 508 508 } … … 515 515 with not-found and irssi users will get better error messages */ 516 516 517 irc_ reply( irc, 406, "%s :Nick does not exist", cmd[1] );518 irc_ reply( irc, 369, "%s :End of WHOWAS", cmd[1] );517 irc_send_num( irc, 406, "%s :Nick does not exist", cmd[1] ); 518 irc_send_num( irc, 369, "%s :End of WHOWAS", cmd[1] ); 519 519 } 520 520 … … 541 541 static void irc_cmd_version( irc_t *irc, char **cmd ) 542 542 { 543 irc_ reply( irc, 351, "bitlbee-%s. %s :%s/%s ", BITLBEE_VERSION, irc->myhost, ARCH, CPU );543 irc_send_num( irc, 351, "bitlbee-%s. %s :%s/%s ", BITLBEE_VERSION, irc->myhost, ARCH, CPU ); 544 544 } 545 545 … … 572 572 ipc_to_master( cmd ); 573 573 574 irc_reply( irc, 382, "%s :Rehashing", global.conf_file ); 575 } 574 irc_send_num( irc, 382, "%s :Rehashing", global.conf_file ); 575 } 576 #endif 576 577 577 578 static const command_t irc_commands[] = { … … 579 580 { "user", 4, irc_cmd_user, IRC_CMD_PRE_LOGIN }, 580 581 { "nick", 1, irc_cmd_nick, 0 }, 582 #if 0 581 583 { "quit", 0, irc_cmd_quit, 0 }, 582 584 { "ping", 0, irc_cmd_ping, 0 }, … … 610 612 { "restart", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 611 613 { "kill", 2, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 614 #endif 612 615 { NULL } 613 616 }; … … 628 631 if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status & USTATUS_LOGGED_IN ) 629 632 { 630 irc_ reply( irc, 462, ":Only allowed before logging in" );633 irc_send_num( irc, 462, ":Only allowed before logging in" ); 631 634 } 632 635 else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && !( irc->status & USTATUS_LOGGED_IN ) ) 633 636 { 634 irc_ reply( irc, 451, ":Register first" );637 irc_send_num( irc, 451, ":Register first" ); 635 638 } 636 639 else if( irc_commands[i].flags & IRC_CMD_OPER_ONLY && !strchr( irc->umode, 'o' ) ) 637 640 { 638 irc_ reply( irc, 481, ":Permission denied - You're not an IRC operator" );641 irc_send_num( irc, 481, ":Permission denied - You're not an IRC operator" ); 639 642 } 640 643 else if( n_arg < irc_commands[i].required_parameters ) 641 644 { 642 irc_ reply( irc, 461, "%s :Need more parameters", cmd[0] );645 irc_send_num( irc, 461, "%s :Need more parameters", cmd[0] ); 643 646 } 644 647 else if( irc_commands[i].flags & IRC_CMD_TO_MASTER ) … … 657 660 658 661 if( irc->status >= USTATUS_LOGGED_IN ) 659 irc_ reply( irc, 421, "%s :Unknown command", cmd[0] );660 } 662 irc_send_num( irc, 421, "%s :Unknown command", cmd[0] ); 663 }
Note: See TracChangeset
for help on using the changeset viewer.