Index: irc.c
===================================================================
--- irc.c	(revision ebb95b68792dde490a1ea1042209525f176af58d)
+++ irc.c	(revision 50e1776cb0c76b3328d458dd8a1bfb379b6b0e43)
@@ -788,17 +788,12 @@
 void irc_topic( irc_t *irc, char *channel )
 {
-	if( g_strcasecmp( channel, irc->channel ) == 0 )
-	{
+	struct groupchat *c = irc_chat_by_channel( irc, channel );
+	
+	if( c && c->topic )
+		irc_reply( irc, 332, "%s :%s", channel, c->topic );
+	else if( g_strcasecmp( channel, irc->channel ) == 0 )
 		irc_reply( irc, 332, "%s :%s", channel, CONTROL_TOPIC );
-	}
 	else
-	{
-		struct groupchat *c = irc_chat_by_channel( irc, channel );
-		
-		if( c )
-			irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title );
-		else
-			irc_reply( irc, 331, "%s :No topic for this channel", channel );
-	}
+		irc_reply( irc, 331, "%s :No topic for this channel", channel );
 }
 
Index: irc_commands.c
===================================================================
--- irc_commands.c	(revision ebb95b68792dde490a1ea1042209525f176af58d)
+++ irc_commands.c	(revision 50e1776cb0c76b3328d458dd8a1bfb379b6b0e43)
@@ -421,8 +421,19 @@
 static void irc_cmd_topic( irc_t *irc, char **cmd )
 {
-	if( cmd[2] )
-		irc_reply( irc, 482, "%s :Cannot change topic", cmd[1] );
-	else
-		irc_topic( irc, cmd[1] );
+	char *channel = cmd[1];
+	char *topic = cmd[2];
+	
+	if( topic )
+	{
+		/* Send the topic */
+		struct groupchat *c = irc_chat_by_channel( irc, channel );
+		if( c && c->ic && c->ic->acc->prpl->chat_topic )
+			c->ic->acc->prpl->chat_topic( c, topic );
+	}
+	else
+	{
+		/* Get the topic */
+		irc_topic( irc, channel );
+	}
 }
 
Index: protocols/nogaim.c
===================================================================
--- protocols/nogaim.c	(revision ebb95b68792dde490a1ea1042209525f176af58d)
+++ protocols/nogaim.c	(revision 50e1776cb0c76b3328d458dd8a1bfb379b6b0e43)
@@ -760,4 +760,27 @@
 }
 
+void imcb_chat_topic( struct groupchat *c, char *who, char *topic )
+{
+	struct im_connection *ic = c->ic;
+	user_t *u = NULL;
+	
+	if( who == NULL)
+		u = user_find( ic, ic->irc->mynick );
+	else if( g_strcasecmp( who, ic->acc->user ) == 0 )
+		u = user_find( ic, ic->irc->nick );
+	else
+		u = user_findhandle( ic, who );
+	
+	if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
+	    ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
+		strip_html( topic );
+	
+	g_free( c->topic );
+	c->topic = g_strdup( topic );
+	
+	if( c->joined && u )
+		irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic );
+}
+
 struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
 {
@@ -777,4 +800,5 @@
 	c->title = g_strdup( handle );
 	c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
+	c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title );
 	
 	if( set_getbool( &ic->irc->set, "debug" ) )
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision ebb95b68792dde490a1ea1042209525f176af58d)
+++ protocols/nogaim.h	(revision 50e1776cb0c76b3328d458dd8a1bfb379b6b0e43)
@@ -110,4 +110,7 @@
 	 * chat using imcb_chat_new(). */
 	char *title;
+	/* Use imcb_chat_topic() to change this variable otherwise the user
+	 * won't notice the topic change. */
+	char *topic;
 	char joined;
 	/* This is for you, you can add your own structure here to extend this
@@ -212,4 +215,9 @@
 	struct groupchat *
 	     (* chat_join)	(struct im_connection *, char *room, char *nick, char *password);
+	/* Change the topic, if supported. Note that BitlBee expects the IM
+	   server to confirm the topic change with a regular topic change
+	   event. If it doesn't do that, you have to fake it to make it
+	   visible to the user. */
+	void (* chat_topic)	(struct groupchat *, char *message);
 	
 	/* You can tell what away states your protocol supports, so that
@@ -293,4 +301,6 @@
 /* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */
 G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at );
+/* To tell BitlBee 'who' changed the topic of 'c' to 'topic'. */
+G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topic );
 G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c );
 
