Index: irc.h
===================================================================
--- irc.h	(revision ad404ab26aa3cfdfc3c76f6926e556e333d02753)
+++ irc.h	(revision 7b71feb6f88b7e14199b8f7e9930f76d5324e356)
@@ -193,4 +193,10 @@
 	struct bee_group *group;
 	struct account *account;
+};
+
+struct irc_groupchat_stub
+{
+	struct account *acc;
+	char *room;
 };
 
Index: irc_channel.c
===================================================================
--- irc_channel.c	(revision ad404ab26aa3cfdfc3c76f6926e556e333d02753)
+++ irc_channel.c	(revision 7b71feb6f88b7e14199b8f7e9930f76d5324e356)
@@ -313,7 +313,25 @@
 }
 
+static gboolean groupchat_stub_join( irc_channel_t *ic )
+{
+	struct irc_groupchat_stub *igs = ic->data;
+	
+	if( igs && igs->acc->ic && igs->acc->prpl->chat_join )
+	{
+		ic->flags |= IRC_CHANNEL_CHAT_PICKME;
+		igs->acc->prpl->chat_join( igs->acc->ic, igs->room, ic->irc->user->nick, NULL );
+		ic->flags &= ~IRC_CHANNEL_CHAT_PICKME;
+		return FALSE;
+	}
+	else
+	{
+		irc_send_num( ic->irc, 403, "%s :Can't join channel, account offline?", ic->name );
+		return FALSE;
+	}
+}
+
 static const struct irc_channel_funcs groupchat_stub_funcs = {
 	NULL,
-	NULL,
+	groupchat_stub_join,
 	NULL,
 	NULL,
Index: irc_commands.c
===================================================================
--- irc_commands.c	(revision ad404ab26aa3cfdfc3c76f6926e556e333d02753)
+++ irc_commands.c	(revision 7b71feb6f88b7e14199b8f7e9930f76d5324e356)
@@ -139,4 +139,12 @@
 		return; /* Dude, you're already there...
 		           RFC doesn't have any reply for that though? */
+	
+	if( ic->f->join && !ic->f->join( ic ) )
+		/* The story is: FALSE either means the handler showed an error
+		   message, or is doing some work before the join should be
+		   confirmed. (In the latter case, the caller should take care
+		   of that confirmation.)
+		   TRUE means all's good, let the user join the channel right away. */
+		return;
 	
 	irc_channel_add_user( ic, irc->user );
Index: root_commands.c
===================================================================
--- root_commands.c	(revision ad404ab26aa3cfdfc3c76f6926e556e333d02753)
+++ root_commands.c	(revision 7b71feb6f88b7e14199b8f7e9930f76d5324e356)
@@ -940,15 +940,4 @@
 }
 
-#if 0
-static set_t **cmd_chat_set_findhead( irc_t *irc, char *id )
-{
-	struct chat *c;
-	
-	if( ( c = chat_get( irc, id ) ) )
-		return &c->set;
-	else
-		return NULL;
-}
-
 static void cmd_chat( irc_t *irc, char **cmd )
 {
@@ -959,8 +948,9 @@
 	{
 		char *channel, *s;
+		struct irc_channel *ic;
 		
 		MIN_ARGS( 3 );
 		
-		if( !( acc = account_get( irc, cmd[2] ) ) )
+		if( !( acc = account_get( irc->b, cmd[2] ) ) )
 		{
 			irc_usermsg( irc, "Invalid account" );
@@ -981,51 +971,19 @@
 		if( strchr( CTYPES, channel[0] ) == NULL )
 		{
-			s = g_strdup_printf( "%c%s", CTYPES[0], channel );
+			s = g_strdup_printf( "#%s", channel );
 			g_free( channel );
 			channel = s;
 		}
 		
-		if( ( c = chat_add( irc, acc, cmd[3], channel ) ) )
-			irc_usermsg( irc, "Chatroom added successfully." );
-		else
-			irc_usermsg( irc, "Could not add chatroom." );
-		
-		g_free( channel );
-	}
-	else if( g_strcasecmp( cmd[1], "list" ) == 0 )
-	{
-		int i = 0;
-		
-		if( strchr( irc->umode, 'b' ) )
-			irc_usermsg( irc, "Chatroom list:" );
-		
-		for( c = irc->chatrooms; c; c = c->next )
-		{
-			irc_usermsg( irc, "%2d. %s(%s) %s, %s", i, c->acc->prpl->name,
-			                  c->acc->user, c->handle, c->channel );
+		if( ( ic = irc_channel_new( irc, channel ) ) )
+		{
+			struct irc_groupchat_stub *igs;
 			
-			i ++;
-		}
-		irc_usermsg( irc, "End of chatroom list" );
-	}
-	else if( g_strcasecmp( cmd[1], "set" ) == 0 )
-	{
-		MIN_ARGS( 2 );
-		
-		cmd_set_real( irc, cmd + 1, cmd_chat_set_findhead, NULL );
-	}
-	else if( g_strcasecmp( cmd[1], "del" ) == 0 )
-	{
-		MIN_ARGS( 2 );
-		
-		if( ( c = chat_get( irc, cmd[2] ) ) )
-		{
-			chat_del( irc, c );
-		}
-		else
-		{
-			irc_usermsg( irc, "Could not remove chat." );
-		}
-	}
+			ic->data = igs = g_new0( struct irc_groupchat_stub, 1 );
+			igs->acc = acc;
+			igs->room = g_strdup( cmd[3] );
+		}
+	}
+	/*
 	else if( g_strcasecmp( cmd[1], "with" ) == 0 )
 	{
@@ -1047,4 +1005,5 @@
 		}
 	}
+	*/
 	else
 	{
@@ -1052,5 +1011,4 @@
 	}
 }
-#endif
 
 static void cmd_transfer( irc_t *irc, char **cmd )
@@ -1137,7 +1095,5 @@
 	{ "transfer",       0, cmd_transfer,       0 },
 	{ "yes",            0, cmd_yesno,          0 },
-#if 0
 	{ "chat",           1, cmd_chat,           0 },
-#endif
 	{ NULL }
 };
