diff options
-rw-r--r-- | chat.c | 2 | ||||
-rw-r--r-- | irc.c | 6 | ||||
-rw-r--r-- | irc.h | 2 | ||||
-rw-r--r-- | irc_commands.c | 37 | ||||
-rw-r--r-- | root_commands.c | 25 |
5 files changed, 49 insertions, 23 deletions
@@ -138,7 +138,7 @@ int chat_chancmp( char *a, char *b ) int chat_chanok( char *a ) { - if( strchr( "&#", a[0] ) != NULL ) + if( strchr( CTYPES, a[0] ) != NULL ) return nick_ok( a + 1 ); else return 0; @@ -780,7 +780,9 @@ void irc_login( irc_t *irc ) irc_reply( irc, 2, ":Host %s is running BitlBee " BITLBEE_VERSION " " ARCH "/" CPU ".", irc->myhost ); irc_reply( irc, 3, ":%s", IRCD_INFO ); irc_reply( irc, 4, "%s %s %s %s", irc->myhost, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES ); - irc_reply( irc, 5, "PREFIX=(ov)@+ CHANTYPES=#& CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", CMODES, MAX_NICK_LENGTH - 1 ); + irc_reply( irc, 5, "PREFIX=(ov)@+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d NETWORK=BitlBee " + "CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 :are supported by this server", + CTYPES, CMODES, MAX_NICK_LENGTH - 1 ); irc_motd( irc ); irc->umode[0] = '\0'; irc_umode_set( irc, "+" UMODE, 1 ); @@ -1021,7 +1023,7 @@ int irc_send( irc_t *irc, char *nick, char *s, int flags ) struct groupchat *c = NULL; user_t *u = NULL; - if( *nick == '#' || *nick == '&' ) + if( strchr( CTYPES, *nick ) ) { if( !( c = irc_chat_by_channel( irc, nick ) ) ) { @@ -37,6 +37,7 @@ #define CMODES "nt" #define CMODE "t" #define UMODE "s" +#define CTYPES "&#" typedef enum { @@ -95,7 +96,6 @@ typedef struct irc } irc_t; #include "user.h" -// #include "nick.h" extern GSList *irc_connection_list; diff --git a/irc_commands.c b/irc_commands.c index fb2bc7cf..d083f714 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -124,7 +124,7 @@ static void irc_cmd_oper( irc_t *irc, char **cmd ) static void irc_cmd_mode( irc_t *irc, char **cmd ) { - if( *cmd[1] == '#' || *cmd[1] == '&' ) + if( strchr( CTYPES, *cmd[1] ) ) { if( cmd[2] ) { @@ -192,26 +192,27 @@ static void irc_cmd_join( irc_t *irc, char **cmd ) RFC doesn't have any reply for that though? */ else if( cmd[1] ) { - if( ( cmd[1][0] == '#' || cmd[1][0] == '&' ) && cmd[1][1] ) + struct groupchat *gc; + struct chat *c; + user_t *u; + + if( strchr( CTYPES, cmd[1][0] ) == NULL || cmd[1][1] == 0 ) + { + irc_reply( irc, 403, "%s :No such channel", cmd[1] ); + return; + } + + if( ( c = chat_bychannel( irc, cmd[1] ) ) ) { - user_t *u = user_find( irc, cmd[1] + 1 ); + char *nick = set_getstr( &c->set, "nick" ); - if( u && u->ic && u->ic->acc->prpl->chat_with ) - { - irc_reply( irc, 403, "%s :Initializing groupchat in a different channel", cmd[1] ); - - if( !u->ic->acc->prpl->chat_with( u->ic, u->handle ) ) - { - irc_usermsg( irc, "Could not open a groupchat with %s.", u->nick ); - } - } - else if( u ) - { - irc_reply( irc, 403, "%s :Groupchats are not possible with %s", cmd[1], cmd[1]+1 ); - } - else + if( nick == NULL ) + nick = irc->nick; + + if( ( gc = c->acc->prpl->chat_join( c->acc->ic, c->handle, nick, NULL ) ) ) { - irc_reply( irc, 403, "%s :No such nick", cmd[1] ); + g_free( gc->channel ); + gc->channel = g_strdup( c->channel ); } } else diff --git a/root_commands.c b/root_commands.c index 83620173..97cadffe 100644 --- a/root_commands.c +++ b/root_commands.c @@ -1050,6 +1050,29 @@ static void cmd_chat( irc_t *irc, char **cmd ) { cmd_set_real( irc, cmd + 1, cmd_chat_set_findhead ); } + else if( g_strcasecmp( cmd[1], "with" ) == 0 ) + { + user_t *u; + + if( !cmd[2] ) + { + irc_usermsg( irc, "Not enough parameters given (need %d)", 2 ); + return; + } + + if( ( u = user_find( irc, cmd[2] ) ) && u->ic && u->ic->acc->prpl->chat_with ) + { + if( !u->ic->acc->prpl->chat_with( u->ic, u->handle ) ) + { + irc_usermsg( irc, "(Possible) failure while trying to open " + "a groupchat with %s.", u->nick ); + } + } + else + { + irc_usermsg( irc, "Can't open a groupchat with %s.", cmd[2] ); + } + } else { irc_usermsg( irc, "Unknown command: %s %s. Please use \x02help commands\x02 to get a list of available commands.", "chat", cmd[1] ); @@ -1083,7 +1106,7 @@ static void cmd_chat( irc_t *irc, char **cmd ) chat = cmd[2]; if( cmd[3] ) { - if( cmd[3][0] != '#' && cmd[3][0] != '&' ) + if( strchr( CTYPES, cmd[3][0] ) == NULL ) channel = g_strdup_printf( "&%s", cmd[3] ); else channel = g_strdup( cmd[3] ); |