Index: doc/user-guide/commands.xml
===================================================================
--- doc/user-guide/commands.xml	(revision 06eef808b0ce5d7d7056240be6286aa79ac6a9ec)
+++ doc/user-guide/commands.xml	(revision a5c6ebd43dd69a7c4c2648ed09a7ebaf53cfc1b0)
@@ -930,4 +930,8 @@
 			
 			<para>
+				With a ! prefix an inverted channel can be created, for example with this setting set to <emphasis>!group</emphasis> you can create a channel with all users <emphasis>not</emphasis> in that group.
+			</para>
+			
+			<para>
 				Note that, when creating a new channel, BitlBee will try to preconfigure the channel for you, based on the channel name. See <emphasis>help channels</emphasis>.
 			</para>
Index: irc.h
===================================================================
--- irc.h	(revision 06eef808b0ce5d7d7056240be6286aa79ac6a9ec)
+++ irc.h	(revision a5c6ebd43dd69a7c4c2648ed09a7ebaf53cfc1b0)
@@ -207,9 +207,11 @@
 typedef enum
 {
-	IRC_CC_TYPE_DEFAULT,
-	IRC_CC_TYPE_REST,
-	IRC_CC_TYPE_GROUP,
-	IRC_CC_TYPE_ACCOUNT,
-	IRC_CC_TYPE_PROTOCOL,
+	IRC_CC_TYPE_DEFAULT  = 0x00001,
+	IRC_CC_TYPE_REST     = 0x00002, /* Still not implemented. */
+	IRC_CC_TYPE_GROUP    = 0x00004,
+	IRC_CC_TYPE_ACCOUNT  = 0x00008,
+	IRC_CC_TYPE_PROTOCOL = 0x00010,
+	IRC_CC_TYPE_MASK     = 0x000ff,
+	IRC_CC_TYPE_INVERT   = 0x00100,
 } irc_control_channel_type_t;
 
Index: irc_channel.c
===================================================================
--- irc_channel.c	(revision 06eef808b0ce5d7d7056240be6286aa79ac6a9ec)
+++ irc_channel.c	(revision a5c6ebd43dd69a7c4c2648ed09a7ebaf53cfc1b0)
@@ -670,5 +670,5 @@
 	
 	icc->account = acc;
-	if( icc->type == IRC_CC_TYPE_ACCOUNT )
+	if( ( icc->type & IRC_CC_TYPE_MASK ) == IRC_CC_TYPE_ACCOUNT )
 		bee_irc_channel_update( ic->irc, ic, NULL );
 	
@@ -680,15 +680,25 @@
 	struct irc_channel *ic = set->data;
 	struct irc_control_channel *icc = ic->data;
-	
-	if( strcmp( value, "all" ) == 0 )
-		icc->type = IRC_CC_TYPE_DEFAULT;
-	else if( strcmp( value, "rest" ) == 0 )
-		icc->type = IRC_CC_TYPE_REST;
-	else if( strcmp( value, "group" ) == 0 )
-		icc->type = IRC_CC_TYPE_GROUP;
-	else if( strcmp( value, "account" ) == 0 )
-		icc->type = IRC_CC_TYPE_ACCOUNT;
-	else if( strcmp( value, "protocol" ) == 0 )
-		icc->type = IRC_CC_TYPE_PROTOCOL;
+	char *s;
+	
+	icc->type &= ~( IRC_CC_TYPE_MASK | IRC_CC_TYPE_INVERT );
+	
+	s = value;
+	if( s[0] == '!' )
+	{
+		icc->type |= IRC_CC_TYPE_INVERT;
+		s ++;
+	}
+	
+	if( strcmp( s, "all" ) == 0 )
+		icc->type |= IRC_CC_TYPE_DEFAULT;
+	else if( strcmp( s, "rest" ) == 0 )
+		icc->type |= IRC_CC_TYPE_REST;
+	else if( strcmp( s, "group" ) == 0 )
+		icc->type |= IRC_CC_TYPE_GROUP;
+	else if( strcmp( s, "account" ) == 0 )
+		icc->type |= IRC_CC_TYPE_ACCOUNT;
+	else if( strcmp( s, "protocol" ) == 0 )
+		icc->type |= IRC_CC_TYPE_PROTOCOL;
 	else
 		return SET_INVALID;
@@ -704,5 +714,5 @@
 	
 	icc->group = bee_group_by_name( ic->irc->b, value, TRUE );
-	if( icc->type == IRC_CC_TYPE_GROUP )
+	if( ( icc->type & IRC_CC_TYPE_MASK ) == IRC_CC_TYPE_GROUP )
 		bee_irc_channel_update( ic->irc, ic, NULL );
 	
@@ -720,5 +730,5 @@
 	
 	icc->protocol = prpl;
-	if( icc->type == IRC_CC_TYPE_PROTOCOL )
+	if( ( icc->type & IRC_CC_TYPE_MASK ) == IRC_CC_TYPE_PROTOCOL )
 		bee_irc_channel_update( ic->irc, ic, NULL );
 	
@@ -776,20 +786,30 @@
 {
 	struct irc_control_channel *icc = ic->data;
+	gboolean ret = FALSE;
 	
 	if( iu->bu == NULL )
 		return FALSE;
 	
-	switch( icc->type )
+	switch( icc->type & IRC_CC_TYPE_MASK )
 	{
 	case IRC_CC_TYPE_GROUP:
-		return iu->bu->group == icc->group;
+		ret = iu->bu->group == icc->group;
+		break;
 	case IRC_CC_TYPE_ACCOUNT:
-		return iu->bu->ic->acc == icc->account;
+		ret = iu->bu->ic->acc == icc->account;
+		break;
 	case IRC_CC_TYPE_PROTOCOL:
-		return iu->bu->ic->acc->prpl == icc->protocol;
+		ret = iu->bu->ic->acc->prpl == icc->protocol;
+		break;
 	case IRC_CC_TYPE_DEFAULT:
 	default:
-		return TRUE;
-	}
+		ret = TRUE;
+		break;
+	}
+	
+	if( icc->type & IRC_CC_TYPE_INVERT )
+		ret = !ret;
+	
+	return ret;
 }
 
