aboutsummaryrefslogtreecommitdiffstats
path: root/root_commands.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2007-11-19 23:16:18 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2007-11-19 23:16:18 +0000
commit256899f2f9eaa43610af53704d5c7ccbd1aace3b (patch)
tree080ec69cc51b963efcd5002d9a15ec2f92df3d16 /root_commands.c
parentcd428e473fe4428041722fd373badef890edebd9 (diff)
parentef5c1855b406e462fb8b90b517f1672a47bcc4b5 (diff)
Merging Jabber groupchat support.
Diffstat (limited to 'root_commands.c')
-rw-r--r--root_commands.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/root_commands.c b/root_commands.c
index 59852de6..e9c71f04 100644
--- a/root_commands.c
+++ b/root_commands.c
@@ -929,24 +929,49 @@ static void cmd_join_chat( irc_t *irc, char **cmd )
chat = cmd[2];
if( cmd[3] )
{
- channel = g_strdup( cmd[3] );
+ if( cmd[3][0] != '#' && cmd[3][0] != '&' )
+ channel = g_strdup_printf( "&%s", cmd[3] );
+ else
+ channel = g_strdup( cmd[3] );
}
else
{
char *s;
- channel = g_strdup( chat );
+ 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];
- c = a->prpl->chat_join( ic, chat, nick, password );
+ 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;
+ }
- g_free( channel );
+ 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 );
+ }
}
const command_t commands[] = {