diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-04-13 02:04:55 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-04-13 02:04:55 +0200 |
commit | 7b59872d86160099968d0f8cdafc2853b074d39b (patch) | |
tree | 59e3d7ec91c305bcabf4daea5f754ab15cbc787b | |
parent | 89c11e735164b7212d27bb64ff1a00ac50b9c746 (diff) |
Support for simple VERSION/PING CTCPs to root.
-rw-r--r-- | irc.h | 1 | ||||
-rw-r--r-- | irc_send.c | 13 | ||||
-rw-r--r-- | irc_user.c | 7 |
3 files changed, 21 insertions, 0 deletions
@@ -200,6 +200,7 @@ void irc_send_whois( irc_user_t *iu ); void irc_send_who( irc_t *irc, GSList *l, const char *channel ); void irc_send_msg( irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix ); void irc_send_msg_raw( irc_user_t *iu, const char *type, const char *dst, const char *msg ); +void irc_send_msg_f( irc_user_t *iu, const char *type, const char *dst, const char *format, ... ) G_GNUC_PRINTF( 4, 5 ); void irc_send_nick( irc_user_t *iu, const char *new ); /* irc_user.c */ @@ -302,6 +302,19 @@ void irc_send_msg_raw( irc_user_t *iu, const char *type, const char *dst, const iu->nick, iu->user, iu->host, type, dst, msg ); } +void irc_send_msg_f( irc_user_t *iu, const char *type, const char *dst, const char *format, ... ) +{ + char text[IRC_MAX_LINE]; + va_list params; + + va_start( params, format ); + g_vsnprintf( text, IRC_MAX_LINE, format, params ); + va_end( params ); + + irc_write( iu->irc, ":%s!%s@%s %s %s :%s", + iu->nick, iu->user, iu->host, type, dst, text ); +} + void irc_send_nick( irc_user_t *iu, const char *new ) { irc_write( iu->irc, ":%s!%s@%s NICK %s", @@ -150,6 +150,13 @@ static gboolean root_ctcp( irc_user_t *iu, char * const *ctcp ) { if( g_strcasecmp( ctcp[0], "VERSION" ) == 0 ) { + irc_send_msg_f( iu, "NOTICE", iu->irc->user->nick, "\001%s %s\001", + ctcp[0], "BitlBee " BITLBEE_VERSION " " ARCH "/" CPU ); + } + else if( g_strcasecmp( ctcp[0], "PING" ) == 0 ) + { + irc_send_msg_f( iu, "NOTICE", iu->irc->user->nick, "\001%s %s\001", + ctcp[0], ctcp[1] ? : "" ); } return TRUE; |