aboutsummaryrefslogtreecommitdiffstats
path: root/irc_im.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@google.com>2010-07-05 13:01:28 +0100
committerWilmer van der Gaast <wilmer@google.com>2010-07-05 13:01:28 +0100
commit69b896b5967e5d13b1c60c68cb3bc7d4a0d5cd06 (patch)
tree4ae3696639aaef0ff003176a343abcb4fad5c8ac /irc_im.c
parent006a84f999248d1bc1c1e36fa3437765d4bd1142 (diff)
When addressing people in a chatroom, try to translate the nickname to the
original unstripped version (without ugly underscores, also).
Diffstat (limited to 'irc_im.c')
-rw-r--r--irc_im.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/irc_im.c b/irc_im.c
index c900e7ff..d7906cd5 100644
--- a/irc_im.c
+++ b/irc_im.c
@@ -602,10 +602,31 @@ static gboolean bee_irc_channel_chat_privmsg_cb( gpointer data, gint fd, b_input
static gboolean bee_irc_channel_chat_privmsg( irc_channel_t *ic, const char *msg )
{
struct groupchat *c = ic->data;
+ char *trans = NULL, *s;
if( c == NULL )
return FALSE;
- else if( set_getbool( &ic->irc->b->set, "paste_buffer" ) )
+
+ if( set_getbool( &ic->set, "translate_to_nicks" ) )
+ {
+ char nick[MAX_NICK_LENGTH+1];
+ irc_user_t *iu;
+
+ strncpy( nick, msg, MAX_NICK_LENGTH );
+ nick[MAX_NICK_LENGTH] = '\0';
+ if( ( s = strchr( nick, ':' ) ) || ( s = strchr( nick, ',' ) ) )
+ {
+ *s = '\0';
+ if( ( iu = irc_user_by_name( ic->irc, nick ) ) &&
+ iu->bu->nick && irc_channel_has_user( ic, iu ) )
+ {
+ trans = g_strconcat( iu->bu->nick, msg + ( s - nick ), NULL );
+ msg = trans;
+ }
+ }
+ }
+
+ if( set_getbool( &ic->irc->b->set, "paste_buffer" ) )
{
int delay;
@@ -622,11 +643,13 @@ static gboolean bee_irc_channel_chat_privmsg( irc_channel_t *ic, const char *msg
ic->pastebuf_timer = b_timeout_add( delay, bee_irc_channel_chat_privmsg_cb, ic );
+ g_free( trans );
return TRUE;
}
else
bee_chat_msg( ic->irc->b, c, msg, 0 );
+ g_free( trans );
return TRUE;
}
@@ -746,6 +769,7 @@ static gboolean bee_irc_channel_init( irc_channel_t *ic )
set_add( &ic->set, "chat_type", "groupchat", set_eval_chat_type, ic );
set_add( &ic->set, "nick", NULL, NULL, ic );
set_add( &ic->set, "room", NULL, NULL, ic );
+ set_add( &ic->set, "translate_to_nicks", "true", set_eval_bool, ic );
/* chat_type == groupchat */
ic->flags |= IRC_CHANNEL_TEMP;
@@ -789,6 +813,7 @@ static gboolean bee_irc_channel_free( irc_channel_t *ic )
set_del( &ic->set, "chat_type" );
set_del( &ic->set, "nick" );
set_del( &ic->set, "room" );
+ set_del( &ic->set, "translate_to_nicks" );
ic->flags &= ~IRC_CHANNEL_TEMP;