Index: protocols/bee.h
===================================================================
--- protocols/bee.h	(revision 7b87539aedd967884d4e4eed75d1052a233720eb)
+++ protocols/bee.h	(revision 203a2d2e8857e4c83f8f5e1a89de03ea08538cb2)
@@ -80,4 +80,5 @@
 	bee_t *bee;
 	void *ui_data;
+	void *data; /* Can be used by the IM module. */
 } bee_user_t;
 
Index: protocols/bee_user.c
===================================================================
--- protocols/bee_user.c	(revision 7b87539aedd967884d4e4eed75d1052a233720eb)
+++ protocols/bee_user.c	(revision 203a2d2e8857e4c83f8f5e1a89de03ea08538cb2)
@@ -43,4 +43,6 @@
 	if( bee->ui->user_new )
 		bee->ui->user_new( bee, bu );
+	if( ic->acc->prpl->buddy_data_add )
+		ic->acc->prpl->buddy_data_add( bu );
 	
 	/* Offline by default. This will set the right flags. */
@@ -57,4 +59,6 @@
 	if( bee->ui->user_free )
 		bee->ui->user_free( bee, bu );
+	if( bu->ic->acc->prpl->buddy_data_free )
+		bu->ic->acc->prpl->buddy_data_free( bu );
 	
 	g_free( bu->handle );
Index: protocols/nogaim.h
===================================================================
--- protocols/nogaim.h	(revision 7b87539aedd967884d4e4eed75d1052a233720eb)
+++ protocols/nogaim.h	(revision 203a2d2e8857e4c83f8f5e1a89de03ea08538cb2)
@@ -247,4 +247,7 @@
 	void (* transfer_request) (struct im_connection *, file_transfer_t *ft, char *handle );
 	
+	void (* buddy_data_add) (struct bee_user *bu);
+	void (* buddy_data_free) (struct bee_user *bu);
+	
 	/* Some placeholders so eventually older plugins may cooperate with newer BitlBees. */
 	void *resv1;
Index: protocols/twitter/twitter.c
===================================================================
--- protocols/twitter/twitter.c	(revision 7b87539aedd967884d4e4eed75d1052a233720eb)
+++ protocols/twitter/twitter.c	(revision 203a2d2e8857e4c83f8f5e1a89de03ea08538cb2)
@@ -395,4 +395,14 @@
 //}
 
+static void twitter_buddy_data_add( struct bee_user *bu )
+{
+	bu->data = g_new0( struct twitter_user_data, 1 );
+}
+
+static void twitter_buddy_data_free( struct bee_user *bu )
+{
+	g_free( bu->data );
+}
+
 static void twitter_handle_command( struct im_connection *ic, char *message )
 {
@@ -408,5 +418,5 @@
 		return;
 	}
-	else if( !set_getbool( &ic->set, "commands" ) )
+	else if( !set_getbool( &ic->acc->set, "commands" ) )
 	{
 		/* Not supporting commands. */
@@ -491,4 +501,6 @@
 	ret->rem_deny = twitter_rem_deny;
 	ret->send_typing = twitter_send_typing;
+	ret->buddy_data_add = twitter_buddy_data_add;
+	ret->buddy_data_free = twitter_buddy_data_free;
 	ret->handle_cmp = g_strcasecmp;
 	
Index: protocols/twitter/twitter.h
===================================================================
--- protocols/twitter/twitter.h	(revision 7b87539aedd967884d4e4eed75d1052a233720eb)
+++ protocols/twitter/twitter.h	(revision 203a2d2e8857e4c83f8f5e1a89de03ea08538cb2)
@@ -58,4 +58,10 @@
 };
 
+struct twitter_user_data
+{
+	guint64 last_id;
+	time_t last_time;
+};
+
 /**
  * This has the same function as the msn_connections GSList. We use this to 
Index: protocols/twitter/twitter_lib.c
===================================================================
--- protocols/twitter/twitter_lib.c	(revision 7b87539aedd967884d4e4eed75d1052a233720eb)
+++ protocols/twitter/twitter_lib.c	(revision 203a2d2e8857e4c83f8f5e1a89de03ea08538cb2)
@@ -431,8 +431,9 @@
  *  - the next_cursor.
  */
-static xt_status twitter_xt_get_status_list( struct xt_node *node, struct twitter_xml_list *txl )
+static xt_status twitter_xt_get_status_list( struct im_connection *ic, struct xt_node *node, struct twitter_xml_list *txl )
 {
 	struct twitter_xml_status *txs;
 	struct xt_node *child;
+	bee_user_t *bu;
 
 	// Set the type of the list.
@@ -449,4 +450,16 @@
 			// Put the item in the front of the list.
 			txl->list = g_slist_prepend (txl->list, txs);
+			
+			if (txs->user && txs->user->screen_name &&
+			    (bu = bee_user_by_handle(ic->bee, ic, txs->user->screen_name)))
+			{
+				struct twitter_user_data *tud = bu->data;
+				
+				if (txs->id > tud->last_id)
+				{
+					tud->last_id = txs->id;
+					tud->last_time = txs->created_at;
+				}
+			}
 		}
 		else if ( g_strcasecmp( "next_cursor", child->name ) == 0)
@@ -627,5 +640,5 @@
 	xt_feed( parser, req->reply_body, req->body_size );
 	// The root <statuses> node should hold the list of statuses <status>
-	twitter_xt_get_status_list(parser->root, txl);
+	twitter_xt_get_status_list(ic, parser->root, txl);
 	xt_free( parser );
 
