diff options
Diffstat (limited to 'root_commands.c')
-rw-r--r-- | root_commands.c | 119 |
1 files changed, 43 insertions, 76 deletions
diff --git a/root_commands.c b/root_commands.c index 5de616fb..e4e07605 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1,7 +1,7 @@ /********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * - * Copyright 2002-2004 Wilmer van der Gaast and others * + * Copyright 2002-2010 Wilmer van der Gaast and others * \********************************************************************/ /* User manager (root) commands */ @@ -143,6 +143,12 @@ static void cmd_identify( irc_t *irc, char **cmd ) storage_status_t status = storage_load( irc, cmd[1] ); char *account_on[] = { "account", "on", NULL }; + if( strchr( irc->umode, 'R' ) != NULL ) + { + irc_usermsg( irc, "You're already logged in." ); + return; + } + switch (status) { case STORAGE_INVALID_PASSWORD: irc_usermsg( irc, "Incorrect password" ); @@ -647,6 +653,21 @@ static void cmd_rename( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); } + else if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) + { + if( strchr( CTYPES, cmd[2][0] ) && nick_ok( cmd[2] + 1 ) ) + { + u = user_find( irc, irc->nick ); + + irc_part( irc, u, irc->channel ); + g_free( irc->channel ); + irc->channel = g_strdup( cmd[2] ); + irc_join( irc, u, irc->channel ); + + if( strcmp( cmd[0], "set_rename" ) != 0 ) + set_setstr( &irc->set, "control_channel", cmd[2] ); + } + } else if( user_find( irc, cmd[2] ) && ( nick_cmp( cmd[1], cmd[2] ) != 0 ) ) { irc_usermsg( irc, "Nick `%s' already exists", cmd[2] ); @@ -696,6 +717,20 @@ char *set_eval_root_nick( set_t *set, char *new_nick ) return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : SET_INVALID; } +char *set_eval_control_channel( set_t *set, char *new_name ) +{ + irc_t *irc = set->data; + + if( strcmp( irc->channel, new_name ) != 0 ) + { + char *cmd[] = { "set_rename", irc->channel, new_name, NULL }; + + cmd_rename( irc, cmd ); + } + + return strcmp( irc->channel, new_name ) == 0 ? new_name : SET_INVALID; +} + static void cmd_remove( irc_t *irc, char **cmd ) { user_t *u; @@ -907,7 +942,7 @@ static void cmd_blist( irc_t *irc, char **cmd ) else if( cmd[1] && g_strcasecmp( cmd[1], "online" ) == 0 ) online = 1; else - online = away = 1; + online = away = 1; if( strchr( irc->umode, 'b' ) != NULL ) format = "%s\t%s\t%s"; @@ -920,8 +955,13 @@ static void cmd_blist( irc_t *irc, char **cmd ) { if( online == 1 ) { + char st[256] = "Online"; + + if( u->status_msg ) + g_snprintf( st, sizeof( st ) - 1, "Online (%s)", u->status_msg ); + g_snprintf( s, sizeof( s ) - 1, "%s@%s %s(%s)", u->user, u->host, u->ic->acc->prpl->name, u->ic->acc->user ); - irc_usermsg( irc, format, u->nick, s, "Online" ); + irc_usermsg( irc, format, u->nick, s, st ); } n_online ++; @@ -1114,79 +1154,6 @@ static void cmd_chat( irc_t *irc, char **cmd ) { irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); } - - - -#if 0 - account_t *a; - struct im_connection *ic; - char *chat, *channel, *nick = NULL, *password = NULL; - struct groupchat *c; - - if( !( a = account_get( irc, cmd[1] ) ) ) - { - irc_usermsg( irc, "Invalid account" ); - return; - } - else if( !( a->ic && ( a->ic->flags & OPT_LOGGED_IN ) ) ) - { - irc_usermsg( irc, "That account is not on-line" ); - return; - } - else if( a->prpl->chat_join == NULL ) - { - irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); - return; - } - ic = a->ic; - - chat = cmd[2]; - if( cmd[3] ) - { - if( strchr( CTYPES, cmd[3][0] ) == NULL ) - channel = g_strdup_printf( "&%s", cmd[3] ); - else - channel = g_strdup( cmd[3] ); - } - else - { - char *s; - - channel = g_strdup_printf( "&%s", chat ); - if( ( s = strchr( channel, '@' ) ) ) - *s = 0; - } - if( cmd[3] && cmd[4] ) - nick = cmd[4]; - else - nick = irc->nick; - if( cmd[3] && cmd[4] && cmd[5] ) - password = cmd[5]; - - if( !nick_ok( channel + 1 ) ) - { - irc_usermsg( irc, "Invalid channel name: %s", channel ); - g_free( channel ); - return; - } - else if( g_strcasecmp( channel, irc->channel ) == 0 || irc_chat_by_channel( irc, channel ) ) - { - irc_usermsg( irc, "Channel already exists: %s", channel ); - g_free( channel ); - return; - } - - if( ( c = a->prpl->chat_join( ic, chat, nick, password ) ) ) - { - g_free( c->channel ); - c->channel = channel; - } - else - { - irc_usermsg( irc, "Tried to join chat, not sure if this was successful" ); - g_free( channel ); - } -#endif } const command_t commands[] = { |