diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-29 20:18:54 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-07-29 20:18:54 +0200 |
commit | f7ca5877b69d452ef2e2ab4dc4d06743072deca0 (patch) | |
tree | 6ce785e43326ef0b638105eaf4ccc2b1760bfc43 /irc_send.c | |
parent | 2fe5eb939ff77697b578bf45ba23cd99daee9c5f (diff) |
Restore default_target setting, kill last_root_cmd variable and just use
the last_channel variable, like for any other user.
Diffstat (limited to 'irc_send.c')
-rw-r--r-- | irc_send.c | 32 |
1 files changed, 15 insertions, 17 deletions
@@ -103,33 +103,31 @@ void irc_send_motd( irc_t *irc ) void irc_usermsg( irc_t *irc, char *format, ... ) { - irc_channel_t *ic; - irc_user_t *iu; + irc_channel_t *ic = NULL; + irc_user_t *iu = irc->root; char text[1024]; va_list params; + char *dst; va_start( params, format ); g_vsnprintf( text, sizeof( text ), format, params ); va_end( params ); - if( irc->last_root_cmd && - irc_channel_name_ok( irc->last_root_cmd ) && - ( ic = irc_channel_by_name( irc, irc->last_root_cmd ) ) && - ic->flags & IRC_CHANNEL_JOINED ) - irc_send_msg( irc->root, "PRIVMSG", irc->last_root_cmd, text, NULL ); - else if( irc->last_root_cmd && - ( iu = irc_user_by_name( irc, irc->last_root_cmd ) ) && - iu->f == &irc_user_root_funcs ) - irc_send_msg( iu, "PRIVMSG", irc->user->nick, text, NULL ); - else + /* Too similar to bee_irc_user_msg()... */ + if( iu->last_channel ) { - g_free( irc->last_root_cmd ); - irc->last_root_cmd = NULL; - - irc_send_msg( irc->root, "PRIVMSG", irc->user->nick, text, NULL ); + if( iu->last_channel->flags & IRC_CHANNEL_JOINED ) + ic = iu->last_channel; + else if( irc->default_channel->flags & IRC_CHANNEL_JOINED ) + ic = irc->default_channel; } - /*return( irc_msgfrom( irc, u->nick, text ) );*/ + if( ic ) + dst = ic->name; + else + dst = irc->user->nick; + + irc_send_msg( irc->root, "PRIVMSG", dst, text, NULL ); } void irc_send_join( irc_channel_t *ic, irc_user_t *iu ) |