aboutsummaryrefslogtreecommitdiffstats
path: root/irc_channel.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-05-02 19:48:26 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-05-02 19:48:26 +0100
commitbce78c8e6b9363175943a1b10df76fdbd87ba0c8 (patch)
tree20b02a4b702e05ecaecc7d07d82dcf0fcdf6ab1b /irc_channel.c
parenta4cdf43ba4247914985765ef26a1d77239a15a10 (diff)
Restored classical control channel behaviour (the ability to talk to
contacts in there).
Diffstat (limited to 'irc_channel.c')
-rw-r--r--irc_channel.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/irc_channel.c b/irc_channel.c
index 27f33619..60c2e422 100644
--- a/irc_channel.c
+++ b/irc_channel.c
@@ -144,13 +144,38 @@ gboolean irc_channel_name_ok( const char *name )
/* Channel-type dependent functions, for control channels: */
static gboolean control_channel_privmsg( irc_channel_t *ic, const char *msg )
{
- char cmd[strlen(msg)+1];
+ irc_t *irc = ic->irc;
+ const char *s;
- g_free( ic->irc->last_root_cmd );
- ic->irc->last_root_cmd = g_strdup( ic->name );
+ /* Scan for non-whitespace chars followed by a colon: */
+ for( s = msg; *s && !isspace( *s ) && *s != ':'; s ++ ) {}
- strcpy( cmd, msg );
- root_command_string( ic->irc, cmd );
+ if( *s == ':' )
+ {
+ char to[s-msg+1];
+ irc_user_t *iu;
+
+ strncpy( to, msg, s - msg );
+ while( *(++s) && isspace( *s ) ) {}
+
+ iu = irc_user_by_name( irc, to );
+ if( iu && iu->f->privmsg )
+ {
+ iu->flags &= ~IRC_USER_PRIVATE;
+ iu->f->privmsg( iu, s );
+ }
+ }
+ else
+ {
+ /* TODO: Maybe just use root->privmsg here now? */
+ char cmd[strlen(msg)+1];
+
+ g_free( ic->irc->last_root_cmd );
+ ic->irc->last_root_cmd = g_strdup( ic->name );
+
+ strcpy( cmd, msg );
+ root_command_string( ic->irc, cmd );
+ }
return TRUE;
}