diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-03 22:36:43 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-05-03 22:36:43 +0100 |
commit | 999769119e85518cc46b3ed64cb8781695fefbdc (patch) | |
tree | bb3de27f9cc7d5a17adeed633f390a23da85596a /protocols | |
parent | 6824fb355a31ed46c22740ef184332440d3981ce (diff) |
Check Tweet length on the BitlBee side already.
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/twitter/twitter.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 9c7b060c..98e85641 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -143,10 +143,24 @@ static char *set_eval_mode( set_t *set, char *value ) return NULL; } +static gboolean twitter_length_check( struct im_connection *ic, gchar *msg ) +{ + int max = set_getint( &ic->acc->set, "message_length" ), len; + + if( max == 0 || ( len = g_utf8_strlen( msg, -1 ) ) <= max ) + return TRUE; + + imcb_error( ic, "Maximum message length exceeded: %d > %d", len, max ); + + return FALSE; +} + static void twitter_init( account_t *acc ) { set_t *s; + s = set_add( &acc->set, "message_length", "140", set_eval_int, acc ); + s = set_add( &acc->set, "mode", "one", set_eval_mode, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; @@ -230,7 +244,7 @@ static int twitter_buddy_msg( struct im_connection *ic, char *who, char *message return FALSE; } } - else + else if( twitter_length_check(ic, message) ) twitter_post_status(ic, message); } else @@ -261,7 +275,7 @@ static void twitter_remove_buddy( struct im_connection *ic, char *who, char *gro static void twitter_chat_msg( struct groupchat *c, char *message, int flags ) { - if( c && message ) + if( c && message && twitter_length_check(c->ic, message)) twitter_post_status(c->ic, message); } |