diff options
-rw-r--r-- | irc_channel.c | 35 | ||||
-rw-r--r-- | irc_commands.c | 3 | ||||
-rw-r--r-- | irc_im.c | 2 |
3 files changed, 34 insertions, 6 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; } diff --git a/irc_commands.c b/irc_commands.c index 35169607..dd7cc730 100644 --- a/irc_commands.c +++ b/irc_commands.c @@ -287,7 +287,10 @@ static void irc_cmd_privmsg( irc_t *irc, char **cmd ) iu->f->ctcp( iu, ctcp ); } else if( iu->f->privmsg ) + { + iu->flags |= IRC_USER_PRIVATE; iu->f->privmsg( iu, cmd[2] ); + } } else { @@ -125,7 +125,7 @@ static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, t else { dst = ic->name; - prefix = g_strdup_printf( "%s%s%s", irc->user->nick, set_getstr( &bee->set, "to_char" ), ts ); + prefix = g_strdup_printf( "%s%s%s", irc->user->nick, set_getstr( &bee->set, "to_char" ), ts ? : "" ); } wrapped = word_wrap( msg, 425 ); |