Changes in irc_commands.c [fb117aee:449a51d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_commands.c
rfb117aee r449a51d 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-20 10Wilmer van der Gaast and others *4 * Copyright 2002-2006 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 53 53 else if( global.conf->auth_pass ) 54 54 { 55 irc_ send_num( irc, 464, ":Incorrect password" );55 irc_reply( 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 ->user= g_strdup( cmd[1] );68 irc-> user->fullname = g_strdup( cmd[4] );67 irc->user = g_strdup( cmd[1] ); 68 irc->realname = 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->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_by_name( irc, cmd[1] ) ) 80 { 81 irc_send_num( irc, 433, ":This nick is already in use" ); 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" ); 82 83 } 83 84 else if( !nick_ok( cmd[1] ) ) 84 85 { 85 86 /* [SH] Invalid characters. */ 86 irc_ send_num( irc, 432, ":This nick contains invalid characters" );87 } 88 else 89 { 90 irc-> user->nick = g_strdup( cmd[1] );87 irc_reply( irc, 432, ":This nick contains invalid characters" ); 88 } 89 else 90 { 91 irc->nick = g_strdup( cmd[1] ); 91 92 92 93 irc_check_login( irc ); … … 104 105 static void irc_cmd_ping( irc_t *irc, char **cmd ) 105 106 { 106 irc_write( irc, ":%s PONG %s :%s", irc->root->host, 107 irc->root->host, cmd[1]?cmd[1]:irc->root->host ); 108 } 109 110 static void irc_cmd_pong( irc_t *irc, char **cmd ) 111 { 112 /* We could check the value we get back from the user, but in 113 fact we don't care, we're just happy s/he's still alive. */ 114 irc->last_pong = gettime(); 115 irc->pinging = 0; 116 } 117 118 static void irc_cmd_join( irc_t *irc, char **cmd ) 119 { 120 irc_channel_t *ic; 121 122 if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL ) 123 ic = irc_channel_new( irc, cmd[1] ); 124 125 if( ic == NULL ) 126 irc_send_num( irc, 479, "%s :Invalid channel name", cmd[1] ); 127 128 if( ic->flags & IRC_CHANNEL_JOINED ) 129 return; /* Dude, you're already there... 130 RFC doesn't have any reply for that though? */ 131 132 irc_channel_add_user( ic, irc->user ); 133 } 134 135 static void irc_cmd_names( irc_t *irc, char **cmd ) 136 { 137 irc_channel_t *ic; 138 139 if( cmd[1] && ( ic = irc_channel_by_name( irc, cmd[1] ) ) ) 140 irc_send_names( ic ); 141 /* With no args, we should show /names of all chans. Make the code 142 below work well if necessary. 143 else 144 { 145 GSList *l; 146 147 for( l = irc->channels; l; l = l->next ) 148 irc_send_names( l->data ); 149 } 150 */ 151 } 152 153 static void irc_cmd_part( irc_t *irc, char **cmd ) 154 { 155 irc_channel_t *ic; 156 157 if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL ) 158 { 159 irc_send_num( irc, 403, "%s :No such channel", cmd[1] ); 160 } 161 else if( !irc_channel_del_user( ic, irc->user ) ) 162 { 163 irc_send_num( irc, 442, "%s :You're not on that channel", cmd[1] ); 164 } 165 } 166 167 static void irc_cmd_whois( irc_t *irc, char **cmd ) 168 { 169 char *nick = cmd[1]; 170 irc_user_t *iu = irc_user_by_name( irc, nick ); 171 172 if( iu ) 173 irc_send_whois( iu ); 174 else 175 irc_send_num( irc, 401, "%s :Nick does not exist", nick ); 176 } 177 178 static void irc_cmd_whowas( irc_t *irc, char **cmd ) 179 { 180 /* For some reason irssi tries a whowas when whois fails. We can 181 ignore this, but then the user never gets a "user not found" 182 message from irssi which is a bit annoying. So just respond 183 with not-found and irssi users will get better error messages */ 184 185 irc_send_num( irc, 406, "%s :Nick does not exist", cmd[1] ); 186 irc_send_num( irc, 369, "%s :End of WHOWAS", cmd[1] ); 187 } 188 189 static void irc_cmd_motd( irc_t *irc, char **cmd ) 190 { 191 irc_send_motd( irc ); 107 irc_write( irc, ":%s PONG %s :%s", irc->myhost, irc->myhost, cmd[1]?cmd[1]:irc->myhost ); 108 } 109 110 static void irc_cmd_oper( irc_t *irc, char **cmd ) 111 { 112 if( global.conf->oper_pass && 113 ( strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? 114 md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : 115 strcmp( cmd[2], global.conf->oper_pass ) == 0 ) ) 116 { 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" ); 123 } 192 124 } 193 125 194 126 static void irc_cmd_mode( irc_t *irc, char **cmd ) 195 127 { 196 if( irc_channel_name_ok( cmd[1] ) ) 197 { 198 irc_channel_t *ic; 199 200 if( ( ic = irc_channel_by_name( irc, cmd[1] ) ) == NULL ) 201 irc_send_num( irc, 403, "%s :No such channel", cmd[1] ); 202 else if( cmd[2] ) 128 if( strchr( CTYPES, *cmd[1] ) ) 129 { 130 if( cmd[2] ) 203 131 { 204 132 if( *cmd[2] == '+' || *cmd[2] == '-' ) 205 irc_ send_num( irc, 477, "%s :Can't change channel modes", cmd[1] );133 irc_reply( irc, 477, "%s :Can't change channel modes", cmd[1] ); 206 134 else if( *cmd[2] == 'b' ) 207 irc_ send_num( irc, 368, "%s :No bans possible", cmd[1] );135 irc_reply( irc, 368, "%s :No bans possible", cmd[1] ); 208 136 } 209 137 else 210 irc_ send_num( irc, 324, "%s +%s", cmd[1], ic->mode);211 } 212 else 213 { 214 if( nick_cmp( cmd[1], irc-> user->nick ) == 0 )138 irc_reply( irc, 324, "%s +%s", cmd[1], CMODE ); 139 } 140 else 141 { 142 if( nick_cmp( cmd[1], irc->nick ) == 0 ) 215 143 { 216 144 if( cmd[2] ) 217 145 irc_umode_set( irc, cmd[2], 0 ); 218 146 else 219 irc_ send_num( irc, 221, "+%s", irc->umode );147 irc_reply( irc, 221, "+%s", irc->umode ); 220 148 } 221 149 else 222 irc_send_num( irc, 502, ":Don't touch their modes" ); 223 } 224 } 225 226 static void irc_cmd_who( irc_t *irc, char **cmd ) 227 { 228 char *channel = cmd[1]; 229 irc_channel_t *ic; 230 231 if( !channel || *channel == '0' || *channel == '*' || !*channel ) 232 irc_send_who( irc, irc->users, "**" ); 233 else if( ( ic = irc_channel_by_name( irc, channel ) ) ) 234 irc_send_who( irc, ic->users, channel ); 235 else 236 irc_send_num( irc, 403, "%s :No such channel", channel ); 150 irc_reply( irc, 502, ":Don't touch their modes" ); 151 } 152 } 153 154 static void irc_cmd_names( irc_t *irc, char **cmd ) 155 { 156 irc_names( irc, cmd[1]?cmd[1]:irc->channel ); 157 } 158 159 static void irc_cmd_part( irc_t *irc, char **cmd ) 160 { 161 struct groupchat *c; 162 163 if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) 164 { 165 user_t *u = user_find( irc, irc->nick ); 166 167 /* Not allowed to leave control channel */ 168 irc_part( irc, u, irc->channel ); 169 irc_join( irc, u, irc->channel ); 170 } 171 else if( ( c = irc_chat_by_channel( irc, cmd[1] ) ) ) 172 { 173 user_t *u = user_find( irc, irc->nick ); 174 175 irc_part( irc, u, c->channel ); 176 177 if( c->ic ) 178 { 179 c->joined = 0; 180 c->ic->acc->prpl->chat_leave( c ); 181 } 182 } 183 else 184 { 185 irc_reply( irc, 403, "%s :No such channel", cmd[1] ); 186 } 187 } 188 189 static void irc_cmd_join( irc_t *irc, char **cmd ) 190 { 191 if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) 192 ; /* Dude, you're already there... 193 RFC doesn't have any reply for that though? */ 194 else if( cmd[1] ) 195 { 196 struct chat *c; 197 198 if( strchr( CTYPES, cmd[1][0] ) == NULL || cmd[1][1] == 0 ) 199 irc_reply( irc, 479, "%s :Invalid channel name", cmd[1] ); 200 else if( ( c = chat_bychannel( irc, cmd[1] ) ) && c->acc && c->acc->ic ) 201 chat_join( irc, c, cmd[2] ); 202 else 203 irc_reply( irc, 403, "%s :No such channel", cmd[1] ); 204 } 205 } 206 207 static void irc_cmd_invite( irc_t *irc, char **cmd ) 208 { 209 char *nick = cmd[1], *channel = cmd[2]; 210 struct groupchat *c = irc_chat_by_channel( irc, channel ); 211 user_t *u = user_find( irc, nick ); 212 213 if( u && c && ( u->ic == c->ic ) ) 214 if( c->ic && c->ic->acc->prpl->chat_invite ) 215 { 216 c->ic->acc->prpl->chat_invite( c, u->handle, NULL ); 217 irc_reply( irc, 341, "%s %s", nick, channel ); 218 return; 219 } 220 221 irc_reply( irc, 482, "%s :Invite impossible; User/Channel non-existent or incompatible", channel ); 237 222 } 238 223 239 224 static void irc_cmd_privmsg( irc_t *irc, char **cmd ) 240 225 { 241 irc_channel_t *ic; 242 irc_user_t *iu; 243 244 if( !cmd[2] ) 245 { 246 irc_send_num( irc, 412, ":No text to send" ); 247 } 248 else if( irc_channel_name_ok( cmd[1] ) && 249 ( ic = irc_channel_by_name( irc, cmd[1] ) ) ) 250 { 251 if( ic->f->privmsg ) 252 ic->f->privmsg( ic, cmd[2] ); 253 } 254 else if( ( iu = irc_user_by_name( irc, cmd[1] ) ) ) 255 { 256 if( iu->f->privmsg ) 257 iu->f->privmsg( iu, cmd[2] ); 258 } 259 else 260 { 261 irc_send_num( irc, 401, "%s :No such nick/channel", cmd[1] ); 262 } 263 264 265 #if 0 266 else if( irc->nick && g_strcasecmp( cmd[1], irc->nick ) == 0 ) 267 { 226 if ( !cmd[2] ) 227 { 228 irc_reply( irc, 412, ":No text to send" ); 229 } 230 else if ( irc->nick && g_strcasecmp( cmd[1], irc->nick ) == 0 ) 231 { 232 irc_write( irc, ":%s!%s@%s %s %s :%s", irc->nick, irc->user, irc->host, cmd[0], cmd[1], cmd[2] ); 268 233 } 269 234 else … … 306 271 irc_send( irc, cmd[1], cmd[2], ( g_strcasecmp( cmd[0], "NOTICE" ) == 0 ) ? OPT_AWAY : 0 ); 307 272 } 308 #endif 309 } 310 311 static void irc_cmd_nickserv( irc_t *irc, char **cmd ) 312 { 313 /* [SH] This aliases the NickServ command to PRIVMSG root */ 314 /* [TV] This aliases the NS command to PRIVMSG root as well */ 315 root_command( irc, cmd + 1 ); 316 } 317 318 319 320 #if 0 321 //#if 0 322 static void irc_cmd_oper( irc_t *irc, char **cmd ) 323 { 324 if( global.conf->oper_pass && 325 ( strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? 326 md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : 327 strcmp( cmd[2], global.conf->oper_pass ) == 0 ) ) 328 { 329 irc_umode_set( irc, "+o", 1 ); 330 irc_send_num( irc, 381, ":Password accepted" ); 331 } 332 else 333 { 334 irc_send_num( irc, 432, ":Incorrect password" ); 335 } 336 } 337 338 static void irc_cmd_invite( irc_t *irc, char **cmd ) 339 { 340 char *nick = cmd[1], *channel = cmd[2]; 341 struct groupchat *c = irc_chat_by_channel( irc, channel ); 342 user_t *u = user_find( irc, nick ); 343 344 if( u && c && ( u->ic == c->ic ) ) 345 if( c->ic && c->ic->acc->prpl->chat_invite ) 346 { 347 c->ic->acc->prpl->chat_invite( c, u->handle, NULL ); 348 irc_send_num( irc, 341, "%s %s", nick, channel ); 349 return; 350 } 351 352 irc_send_num( irc, 482, "%s :Invite impossible; User/Channel non-existent or incompatible", channel ); 273 } 274 275 static void irc_cmd_who( irc_t *irc, char **cmd ) 276 { 277 char *channel = cmd[1]; 278 user_t *u = irc->users; 279 struct groupchat *c; 280 GList *l; 281 282 if( !channel || *channel == '0' || *channel == '*' || !*channel ) 283 while( u ) 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 ); 286 u = u->next; 287 } 288 else if( g_strcasecmp( channel, irc->channel ) == 0 ) 289 while( u ) 290 { 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 ); 293 u = u->next; 294 } 295 else if( ( c = irc_chat_by_channel( irc, channel ) ) ) 296 for( l = c->in_room; l; l = l->next ) 297 { 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 ); 300 } 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:"**" ); 353 305 } 354 306 … … 368 320 { 369 321 if( u->online && u->away ) 370 irc_ send_num( irc, 302, ":%s=-%s@%s", u->nick, u->user, u->host );322 irc_reply( irc, 302, ":%s=-%s@%s", u->nick, u->user, u->host ); 371 323 else 372 irc_ send_num( irc, 302, ":%s=+%s@%s", u->nick, u->user, u->host );324 irc_reply( irc, 302, ":%s=+%s@%s", u->nick, u->user, u->host ); 373 325 } 374 326 } … … 425 377 buff[strlen(buff)-1] = '\0'; 426 378 427 irc_ send_num( irc, 303, ":%s", buff );379 irc_reply( irc, 303, ":%s", buff ); 428 380 } 429 381 … … 454 406 455 407 if( u && u->online ) 456 irc_ send_num( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" );408 irc_reply( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" ); 457 409 else 458 irc_ send_num( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" );410 irc_reply( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" ); 459 411 } 460 412 else if( cmd[i][0] == '-' ) … … 467 419 g_free( okey ); 468 420 469 irc_ send_num( irc, 602, "%s %s %s %d :%s", nick, "*", "*", 0, "Stopped watching" );421 irc_reply( irc, 602, "%s %s %s %d :%s", nick, "*", "*", 0, "Stopped watching" ); 470 422 } 471 423 } … … 511 463 u->away[j] = 0; 512 464 513 irc_ send_num( irc, 306, ":You're now away: %s", u->away );465 irc_reply( irc, 306, ":You're now away: %s", u->away ); 514 466 /* irc_umode_set( irc, irc->myhost, "+a" ); */ 515 467 } … … 519 471 u->away = NULL; 520 472 /* irc_umode_set( irc, irc->myhost, "-a" ); */ 521 irc_ send_num( irc, 305, ":Welcome back" );473 irc_reply( irc, 305, ":Welcome back" ); 522 474 } 523 475 … … 525 477 } 526 478 479 static void irc_cmd_whois( irc_t *irc, char **cmd ) 480 { 481 char *nick = cmd[1]; 482 user_t *u = user_find( irc, nick ); 483 484 if( u ) 485 { 486 irc_reply( irc, 311, "%s %s %s * :%s", u->nick, u->user, u->host, u->realname ); 487 488 if( u->ic ) 489 irc_reply( irc, 312, "%s %s.%s :%s network", u->nick, u->ic->acc->user, 490 u->ic->acc->server && *u->ic->acc->server ? u->ic->acc->server : "", 491 u->ic->acc->prpl->name ); 492 else 493 irc_reply( irc, 312, "%s %s :%s", u->nick, irc->myhost, IRCD_INFO ); 494 495 if( !u->online ) 496 irc_reply( irc, 301, "%s :%s", u->nick, "User is offline" ); 497 else if( u->away ) 498 irc_reply( irc, 301, "%s :%s", u->nick, u->away ); 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 ); 507 } 508 } 509 510 static void irc_cmd_whowas( irc_t *irc, char **cmd ) 511 { 512 /* For some reason irssi tries a whowas when whois fails. We can 513 ignore this, but then the user never gets a "user not found" 514 message from irssi which is a bit annoying. So just respond 515 with not-found and irssi users will get better error messages */ 516 517 irc_reply( irc, 406, "%s :Nick does not exist", cmd[1] ); 518 irc_reply( irc, 369, "%s :End of WHOWAS", cmd[1] ); 519 } 520 521 static void irc_cmd_nickserv( irc_t *irc, char **cmd ) 522 { 523 /* [SH] This aliases the NickServ command to PRIVMSG root */ 524 /* [TV] This aliases the NS command to PRIVMSG root as well */ 525 root_command( irc, cmd + 1 ); 526 } 527 528 static void irc_cmd_motd( irc_t *irc, char **cmd ) 529 { 530 irc_motd( irc ); 531 } 532 533 static void irc_cmd_pong( irc_t *irc, char **cmd ) 534 { 535 /* We could check the value we get back from the user, but in 536 fact we don't care, we're just happy he's still alive. */ 537 irc->last_pong = gettime(); 538 irc->pinging = 0; 539 } 540 527 541 static void irc_cmd_version( irc_t *irc, char **cmd ) 528 542 { 529 irc_ send_num( irc, 351, "bitlbee-%s. %s :%s/%s ", BITLBEE_VERSION, irc->myhost, ARCH, CPU );543 irc_reply( irc, 351, "bitlbee-%s. %s :%s/%s ", BITLBEE_VERSION, irc->myhost, ARCH, CPU ); 530 544 } 531 545 … … 558 572 ipc_to_master( cmd ); 559 573 560 irc_send_num( irc, 382, "%s :Rehashing", global.conf_file ); 561 } 562 #endif 574 irc_reply( irc, 382, "%s :Rehashing", global.conf_file ); 575 } 563 576 564 577 static const command_t irc_commands[] = { … … 568 581 { "quit", 0, irc_cmd_quit, 0 }, 569 582 { "ping", 0, irc_cmd_ping, 0 }, 570 { "pong", 0, irc_cmd_pong, IRC_CMD_LOGGED_IN }, 583 { "oper", 2, irc_cmd_oper, IRC_CMD_LOGGED_IN }, 584 { "mode", 1, irc_cmd_mode, IRC_CMD_LOGGED_IN }, 585 { "names", 0, irc_cmd_names, IRC_CMD_LOGGED_IN }, 586 { "part", 1, irc_cmd_part, IRC_CMD_LOGGED_IN }, 571 587 { "join", 1, irc_cmd_join, IRC_CMD_LOGGED_IN }, 572 { "names", 1, irc_cmd_names, IRC_CMD_LOGGED_IN }, 573 { "part", 1, irc_cmd_part, IRC_CMD_LOGGED_IN }, 574 { "whois", 1, irc_cmd_whois, IRC_CMD_LOGGED_IN }, 575 { "whowas", 1, irc_cmd_whowas, IRC_CMD_LOGGED_IN }, 576 { "motd", 0, irc_cmd_motd, IRC_CMD_LOGGED_IN }, 577 { "mode", 1, irc_cmd_mode, IRC_CMD_LOGGED_IN }, 588 { "invite", 2, irc_cmd_invite, IRC_CMD_LOGGED_IN }, 589 { "privmsg", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN }, 590 { "notice", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN }, 578 591 { "who", 0, irc_cmd_who, IRC_CMD_LOGGED_IN }, 579 { "privmsg", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN },580 { "nickserv", 1, irc_cmd_nickserv, IRC_CMD_LOGGED_IN },581 { "ns", 1, irc_cmd_nickserv, IRC_CMD_LOGGED_IN },582 #if 0583 { "oper", 2, irc_cmd_oper, IRC_CMD_LOGGED_IN },584 { "invite", 2, irc_cmd_invite, IRC_CMD_LOGGED_IN },585 { "notice", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN },586 592 { "userhost", 1, irc_cmd_userhost, IRC_CMD_LOGGED_IN }, 587 593 { "ison", 1, irc_cmd_ison, IRC_CMD_LOGGED_IN }, … … 589 595 { "topic", 1, irc_cmd_topic, IRC_CMD_LOGGED_IN }, 590 596 { "away", 0, irc_cmd_away, IRC_CMD_LOGGED_IN }, 597 { "whois", 1, irc_cmd_whois, IRC_CMD_LOGGED_IN }, 598 { "whowas", 1, irc_cmd_whowas, IRC_CMD_LOGGED_IN }, 599 { "nickserv", 1, irc_cmd_nickserv, IRC_CMD_LOGGED_IN }, 600 { "ns", 1, irc_cmd_nickserv, IRC_CMD_LOGGED_IN }, 601 { "motd", 0, irc_cmd_motd, IRC_CMD_LOGGED_IN }, 602 { "pong", 0, irc_cmd_pong, IRC_CMD_LOGGED_IN }, 591 603 { "version", 0, irc_cmd_version, IRC_CMD_LOGGED_IN }, 592 604 { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN }, … … 598 610 { "restart", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 599 611 { "kill", 2, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 600 #endif601 612 { NULL } 602 613 }; … … 617 628 if( irc_commands[i].flags & IRC_CMD_PRE_LOGIN && irc->status & USTATUS_LOGGED_IN ) 618 629 { 619 irc_ send_num( irc, 462, ":Only allowed before logging in" );630 irc_reply( irc, 462, ":Only allowed before logging in" ); 620 631 } 621 632 else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && !( irc->status & USTATUS_LOGGED_IN ) ) 622 633 { 623 irc_ send_num( irc, 451, ":Register first" );634 irc_reply( irc, 451, ":Register first" ); 624 635 } 625 636 else if( irc_commands[i].flags & IRC_CMD_OPER_ONLY && !strchr( irc->umode, 'o' ) ) 626 637 { 627 irc_ send_num( irc, 481, ":Permission denied - You're not an IRC operator" );638 irc_reply( irc, 481, ":Permission denied - You're not an IRC operator" ); 628 639 } 629 640 else if( n_arg < irc_commands[i].required_parameters ) 630 641 { 631 irc_ send_num( irc, 461, "%s :Need more parameters", cmd[0] );642 irc_reply( irc, 461, "%s :Need more parameters", cmd[0] ); 632 643 } 633 644 else if( irc_commands[i].flags & IRC_CMD_TO_MASTER ) … … 646 657 647 658 if( irc->status >= USTATUS_LOGGED_IN ) 648 irc_ send_num( irc, 421, "%s :Unknown command", cmd[0] );649 } 659 irc_reply( irc, 421, "%s :Unknown command", cmd[0] ); 660 }
Note: See TracChangeset
for help on using the changeset viewer.