diff options
| -rw-r--r-- | doc/user-guide/commands.xml | 15 | ||||
| -rw-r--r-- | protocols/twitter/twitter.c | 21 | 
2 files changed, 31 insertions, 5 deletions
| diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index 7a4baa73..1f463815 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -1022,6 +1022,21 @@  		</description>  	</bitlbee-setting> + +	<bitlbee-setting name="stream" type="boolean" scope="account"> +		<default>true</default> + +		<description> +			<para> +				For Twitter accounts, this setting enables use of the Streaming API. This automatically gives you incoming DMs as well. +			</para> +			 +			<para> +				For other Twitter-like services, this setting is not supported. +			</para> +		</description> + +	</bitlbee-setting>  	<bitlbee-setting name="target_url_length" type="integer" scope="account">  		<default>20</default> diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 6bde497a..b7eacc4b 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -64,13 +64,17 @@ static void twitter_main_loop_start(struct im_connection *ic)  	imcb_log(ic, "Getting initial statuses"); -	// Run this once. After this queue the main loop function. +	// Run this once. After this queue the main loop function (or open the +	// stream if available).  	twitter_main_loop(ic, -1, 0);  	if (set_getbool(&ic->acc->set, "stream")) {  		/* That fetch was just to get backlog, the stream will give  		   us the rest. \o/ */  		twitter_open_stream(ic); +		 +		/* Stream sends keepalives (empty lines) or actual data at +		   least twice a minute. Disconnect if this stops. */  		ic->flags |= OPT_PONGS;  	} else {  		/* Not using the streaming API, so keep polling the old- @@ -95,7 +99,6 @@ void twitter_login_finish(struct im_connection *ic)  		 !(td->flags & TWITTER_HAVE_FRIENDS)) {  		imcb_log(ic, "Getting contact list");  		twitter_get_friends_ids(ic, -1); -		//twitter_get_statuses_friends(ic, -1);  	} else  		twitter_main_loop_start(ic);  } @@ -288,12 +291,14 @@ static void twitter_init(account_t * acc)  	s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc); -	s = set_add(&acc->set, "stream", "true", set_eval_bool, acc); -	s->flags |= ACC_SET_OFFLINE_ONLY; +	if (strcmp(acc->prpl->name, "twitter") == 0) { +		s = set_add(&acc->set, "stream", "true", set_eval_bool, acc); +		s->flags |= ACC_SET_OFFLINE_ONLY; +	}  }  /** - * Login method. Since the twitter API works with seperate HTTP request we  + * Login method. Since the twitter API works with separate HTTP request we   * only save the user and pass to the twitter_data object.   */  static void twitter_login(account_t * acc) @@ -311,6 +316,12 @@ static void twitter_login(account_t * acc)  		return;  	} +	if (!strstr(url.host, "twitter.com") && +	    set_getbool(&ic->acc->set, "stream")) { +		imcb_error(ic, "Warning: The streaming API is only supported by Twitter, " +		               "and you seem to be connecting to a different service."); +	} +  	imcb_log(ic, "Connecting");  	twitter_connections = g_slist_append(twitter_connections, ic); | 
