Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_im.c

    re67e513 r911d97a  
    193193}
    194194
    195 static void bee_irc_msg_from_user( irc_user_t *iu, const char *msg, time_t sent_at )
    196 {
    197         irc_t *irc = iu->irc;
    198         bee_t *bee = irc->b;
    199         const char *dst;
    200         char *prefix = NULL;
     195static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg_, time_t sent_at )
     196{
     197        irc_t *irc = bee->ui_data;
     198        irc_user_t *iu = (irc_user_t *) bu->ui_data;
     199        char *dst, *prefix = NULL;
    201200        char *wrapped, *ts = NULL;
    202 
     201        irc_channel_t *ic = NULL;
     202        char *msg = g_strdup( msg_ );
     203        GSList *l;
     204       
    203205        if( sent_at > 0 && set_getbool( &irc->b->set, "display_timestamps" ) )
    204206                ts = irc_format_timestamp( irc, sent_at );
    205207       
    206         dst = irc_user_msgdest(iu);
    207         if(dst != irc->user->nick) {
    208                 /* if not messaging directly, call user by name */
     208        /* Too similar to irc_usermsg()... */
     209        if( iu->last_channel )
     210        {
     211                if( iu->last_channel->flags & IRC_CHANNEL_JOINED )
     212                        ic = iu->last_channel;
     213                else
     214                        ic = irc_channel_with_user( irc, iu );
     215        }
     216       
     217        if( ic )
     218        {
     219                dst = ic->name;
    209220                prefix = g_strdup_printf( "%s%s%s", irc->user->nick, set_getstr( &bee->set, "to_char" ), ts ? : "" );
    210         } else {
     221        }
     222        else
     223        {
     224                dst = irc->user->nick;
    211225                prefix = ts;
    212                 ts = NULL;      /* don't doulbe-free */
    213         }
    214 
    215         wrapped = word_wrap( msg, 425 );
    216         irc_send_msg( iu, "PRIVMSG", dst, wrapped, prefix );
    217        
    218         g_free( wrapped );
    219         g_free( prefix );
    220         g_free( ts );
    221 }
    222 
    223 static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg_, time_t sent_at )
    224 {
    225         irc_user_t *iu = (irc_user_t *) bu->ui_data;
    226         char *msg = g_strdup( msg_ );
    227         GSList *l;
     226                ts = NULL;
     227        }
    228228       
    229229        for( l = irc_plugins; l; l = l->next )
     
    256256        }
    257257       
    258     bee_irc_msg_from_user( iu, msg, sent_at );
    259 
     258        wrapped = word_wrap( msg, 425 );
     259        irc_send_msg( iu, "PRIVMSG", dst, wrapped, prefix );
     260       
     261        g_free( wrapped );
     262        g_free( prefix );
    260263        g_free( msg );
     264        g_free( ts );
     265       
    261266        return TRUE;
    262267}
     
    446451{
    447452        irc_user_t *iu = data;
    448         char *msg = g_string_free( iu->pastebuf, FALSE );
     453        char *msg;
    449454        GSList *l;
     455       
     456        msg = g_string_free( iu->pastebuf, FALSE );
     457        iu->pastebuf = NULL;
     458        iu->pastebuf_timer = 0;
    450459       
    451460        for( l = irc_plugins; l; l = l->next )
     
    474483       
    475484        g_free( msg );
    476         iu->pastebuf = NULL;
    477         iu->pastebuf_timer = 0;
    478485       
    479486        return FALSE;
     
    988995        else if( !acc->prpl->chat_join )
    989996        {
    990                 irc_rootmsg( ic->irc, "Named chatrooms not supported on that account." );
     997                irc_usermsg( ic->irc, "Named chatrooms not supported on that account." );
    991998                return SET_INVALID;
    992999        }
Note: See TracChangeset for help on using the changeset viewer.