From f012a9f0bb363cfcbdb6f2d563254ffba26b9fc8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 1 Apr 2010 23:25:41 -0400 Subject: Can receive messages again. --- irc_im.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'irc_im.c') diff --git a/irc_im.c b/irc_im.c index 9a4ce176..e13a9ab4 100644 --- a/irc_im.c +++ b/irc_im.c @@ -62,6 +62,9 @@ static gboolean bee_irc_user_new( bee_t *bee, bee_user_t *bu ) iu->user = g_strdup( bu->handle ); } + if( set_getbool( &bee->set, "private" ) ) + iu->flags |= IRC_USER_PRIVATE; + iu->f = &irc_user_im_funcs; //iu->last_typing_notice = 0; @@ -89,10 +92,38 @@ static gboolean bee_irc_user_status( bee_t *bee, bee_user_t *bu, bee_user_t *old return TRUE; } +static gboolean bee_irc_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, time_t sent_at ) +{ + irc_t *irc = bee->ui_data; + irc_channel_t *ic = irc->channels->data; + irc_user_t *iu = (irc_user_t *) bu->ui_data; + char *dst, *prefix = NULL; + char *wrapped; + + if( iu->flags & IRC_USER_PRIVATE ) + { + dst = irc->user->nick; + } + else + { + dst = ic->name; + prefix = g_strdup_printf( "%s%s", irc->user->nick, set_getstr( &bee->set, "to_char" ) ); + } + + wrapped = word_wrap( msg, 425 ); + irc_send_msg( iu, "PRIVMSG", dst, wrapped, prefix ); + + g_free( wrapped ); + g_free( prefix ); + + return TRUE; +} + const struct bee_ui_funcs irc_ui_funcs = { bee_irc_user_new, bee_irc_user_free, bee_irc_user_status, + bee_irc_user_msg, }; -- cgit v1.2.3