Changeset 6761a40


Ignore:
Timestamp:
2010-03-28T02:44:19Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
3923003
Parents:
410bf6d
Message:

Restored multi-line message support.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • irc.h

    r410bf6d r6761a40  
    197197void irc_send_whois( irc_user_t *iu );
    198198void irc_send_who( irc_t *irc, GSList *l, const char *channel );
    199 void irc_send_msg( irc_user_t *iu, const char *type, const char *dst, const char *msg );
     199void irc_send_msg( irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix );
     200void irc_send_msg_raw( irc_user_t *iu, const char *type, const char *dst, const char *msg );
    200201
    201202/* irc_user.c */
  • irc_send.c

    r410bf6d r6761a40  
    124124            ( ic = irc_channel_by_name( irc, irc->last_root_cmd ) ) &&
    125125            ic->flags & IRC_CHANNEL_JOINED )
    126                 irc_send_msg( irc->root, "PRIVMSG", irc->last_root_cmd, text );
     126                irc_send_msg( irc->root, "PRIVMSG", irc->last_root_cmd, text, NULL );
    127127        else if( irc->last_root_cmd &&
    128128                 ( iu = irc_user_by_name( irc, irc->last_root_cmd ) ) &&
    129129                 iu->f == &irc_user_root_funcs )
    130                 irc_send_msg( iu, "PRIVMSG", irc->user->nick, text );
     130                irc_send_msg( iu, "PRIVMSG", irc->user->nick, text, NULL );
    131131        else
    132132        {
     
    134134                irc->last_root_cmd = NULL;
    135135               
    136                 irc_send_msg( irc->root, "PRIVMSG", irc->user->nick, text );
     136                irc_send_msg( irc->root, "PRIVMSG", irc->user->nick, text, NULL );
    137137        }
    138138       
     
    254254}
    255255
    256 void irc_send_msg( irc_user_t *iu, const char *type, const char *dst, const char *msg )
     256void irc_send_msg( irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix )
     257{
     258        char last = 0;
     259        const char *s = msg, *line = msg;
     260        char raw_msg[strlen(msg)+1024];
     261       
     262        while( !last )
     263        {
     264                if( *s == '\r' && *(s+1) == '\n' )
     265                        s++;
     266                if( *s == '\n' )
     267                {
     268                        last = s[1] == 0;
     269                }
     270                else
     271                {
     272                        last = s[0] == 0;
     273                }
     274                if( *s == 0 || *s == '\n' )
     275                {
     276                        if( g_strncasecmp( line, "/me ", 4 ) == 0 && ( !prefix || !*prefix ) &&
     277                            g_strcasecmp( type, "PRIVMSG" ) == 0 )
     278                        {
     279                                strcpy( raw_msg, "\001ACTION " );
     280                                strncat( raw_msg, line + 4, s - line - 4 );
     281                                strcat( raw_msg, "\001" );
     282                                irc_send_msg_raw( iu, type, dst, raw_msg );
     283                        }
     284                        else
     285                        {
     286                                *raw_msg = '\0';
     287                                if( prefix && *prefix )
     288                                        strcpy( raw_msg, prefix );
     289                                strncat( raw_msg, line, s - line );
     290                                irc_send_msg_raw( iu, type, dst, raw_msg );
     291                        }
     292                        line = s + 1;
     293                }
     294                s ++;
     295        }
     296}
     297
     298void irc_send_msg_raw( irc_user_t *iu, const char *type, const char *dst, const char *msg )
    257299{
    258300        irc_write( iu->irc, ":%s!%s@%s %s %s :%s",
  • irc_user.c

    r410bf6d r6761a40  
    132132static gboolean self_privmsg( irc_user_t *iu, const char *msg )
    133133{
    134         irc_send_msg( iu, "PRIVMSG", iu->nick, msg );
     134        irc_send_msg_raw( iu, "PRIVMSG", iu->nick, msg );
    135135       
    136136        return TRUE;
Note: See TracChangeset for help on using the changeset viewer.