Changeset 6761a40
- Timestamp:
- 2010-03-28T02:44:19Z (15 years ago)
- Branches:
- master
- Children:
- 3923003
- Parents:
- 410bf6d
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.h
r410bf6d r6761a40 197 197 void irc_send_whois( irc_user_t *iu ); 198 198 void 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 ); 199 void irc_send_msg( irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix ); 200 void irc_send_msg_raw( irc_user_t *iu, const char *type, const char *dst, const char *msg ); 200 201 201 202 /* irc_user.c */ -
irc_send.c
r410bf6d r6761a40 124 124 ( ic = irc_channel_by_name( irc, irc->last_root_cmd ) ) && 125 125 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 ); 127 127 else if( irc->last_root_cmd && 128 128 ( iu = irc_user_by_name( irc, irc->last_root_cmd ) ) && 129 129 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 ); 131 131 else 132 132 { … … 134 134 irc->last_root_cmd = NULL; 135 135 136 irc_send_msg( irc->root, "PRIVMSG", irc->user->nick, text );136 irc_send_msg( irc->root, "PRIVMSG", irc->user->nick, text, NULL ); 137 137 } 138 138 … … 254 254 } 255 255 256 void irc_send_msg( irc_user_t *iu, const char *type, const char *dst, const char *msg ) 256 void 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 298 void irc_send_msg_raw( irc_user_t *iu, const char *type, const char *dst, const char *msg ) 257 299 { 258 300 irc_write( iu->irc, ":%s!%s@%s %s %s :%s", -
irc_user.c
r410bf6d r6761a40 132 132 static gboolean self_privmsg( irc_user_t *iu, const char *msg ) 133 133 { 134 irc_send_msg ( iu, "PRIVMSG", iu->nick, msg );134 irc_send_msg_raw( iu, "PRIVMSG", iu->nick, msg ); 135 135 136 136 return TRUE;
Note: See TracChangeset
for help on using the changeset viewer.