Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_im.c

    r911d97a re67e513  
    193193}
    194194
     195static 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;
     201        char *wrapped, *ts = NULL;
     202
     203        if( sent_at > 0 && set_getbool( &irc->b->set, "display_timestamps" ) )
     204                ts = irc_format_timestamp( irc, sent_at );
     205       
     206        dst = irc_user_msgdest(iu);
     207        if(dst != irc->user->nick) {
     208                /* if not messaging directly, call user by name */
     209                prefix = g_strdup_printf( "%s%s%s", irc->user->nick, set_getstr( &bee->set, "to_char" ), ts ? : "" );
     210        } else {
     211                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
    195223static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg_, time_t sent_at )
    196224{
    197         irc_t *irc = bee->ui_data;
    198225        irc_user_t *iu = (irc_user_t *) bu->ui_data;
    199         char *dst, *prefix = NULL;
    200         char *wrapped, *ts = NULL;
    201         irc_channel_t *ic = NULL;
    202226        char *msg = g_strdup( msg_ );
    203227        GSList *l;
    204        
    205         if( sent_at > 0 && set_getbool( &irc->b->set, "display_timestamps" ) )
    206                 ts = irc_format_timestamp( irc, sent_at );
    207        
    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;
    220                 prefix = g_strdup_printf( "%s%s%s", irc->user->nick, set_getstr( &bee->set, "to_char" ), ts ? : "" );
    221         }
    222         else
    223         {
    224                 dst = irc->user->nick;
    225                 prefix = ts;
    226                 ts = NULL;
    227         }
    228228       
    229229        for( l = irc_plugins; l; l = l->next )
     
    256256        }
    257257       
    258         wrapped = word_wrap( msg, 425 );
    259         irc_send_msg( iu, "PRIVMSG", dst, wrapped, prefix );
    260        
    261         g_free( wrapped );
    262         g_free( prefix );
     258    bee_irc_msg_from_user( iu, msg, sent_at );
     259
    263260        g_free( msg );
    264         g_free( ts );
    265        
    266261        return TRUE;
    267262}
     
    451446{
    452447        irc_user_t *iu = data;
    453         char *msg;
     448        char *msg = g_string_free( iu->pastebuf, FALSE );
    454449        GSList *l;
    455        
    456         msg = g_string_free( iu->pastebuf, FALSE );
    457         iu->pastebuf = NULL;
    458         iu->pastebuf_timer = 0;
    459450       
    460451        for( l = irc_plugins; l; l = l->next )
     
    483474       
    484475        g_free( msg );
     476        iu->pastebuf = NULL;
     477        iu->pastebuf_timer = 0;
    485478       
    486479        return FALSE;
     
    995988        else if( !acc->prpl->chat_join )
    996989        {
    997                 irc_usermsg( ic->irc, "Named chatrooms not supported on that account." );
     990                irc_rootmsg( ic->irc, "Named chatrooms not supported on that account." );
    998991                return SET_INVALID;
    999992        }
Note: See TracChangeset for help on using the changeset viewer.