<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,7 +11,7 @@ $Data::Dumper::Indent = 1;
 use vars qw($VERSION %IRSSI);
 
 $VERSION = &quot;2.2.3beta&quot;;
-my ($REV) = '$Rev: 616 $' =~ /(\d+)/;
+my ($REV) = '$Rev: 618 $' =~ /(\d+)/;
 %IRSSI = (
     authors     =&gt; 'Dan Boger',
     contact     =&gt; 'zigdon@gmail.com',
@@ -20,7 +20,7 @@ my ($REV) = '$Rev: 616 $' =~ /(\d+)/;
       . 'Can optionally set your bitlbee /away message to same',
     license =&gt; 'GNU GPL v2',
     url     =&gt; 'http://twirssi.com',
-    changed =&gt; '$Date: 2009-04-21 12:20:40 -0700 (Tue, 21 Apr 2009) $',
+    changed =&gt; '$Date: 2009-04-22 16:03:14 -0700 (Wed, 22 Apr 2009) $',
 );
 
 my $window;
@@ -30,12 +30,14 @@ my $user;
 my $defservice;
 my $poll;
 my $last_poll;
-my $last_friends_poll = time;
+my $last_friends_poll = 0;
 my %nicks;
 my %friends;
 my %tweet_cache;
 my %id_map;
-my $failwhale            = 0;
+my $failwhale  = 0;
+my $first_call = 1;
+
 my %irssi_to_mirc_colors = (
     '%k' =&gt; '01',
     '%r' =&gt; '05',
@@ -771,10 +773,12 @@ sub get_updates {
             $error++ unless &amp;do_updates( $fh, $_, $twits{$_}, \%context_cache );
         }
 
+        print $fh &quot;__friends__\n&quot;;
         if (
             time - $last_friends_poll &gt;
             Irssi::settings_get_int('twitter_friends_poll') )
         {
+            print $fh &quot;__updated &quot;, time, &quot;\n&quot;;
             my ( $added, $removed ) = &amp;load_friends($fh);
             if ( $added + $removed ) {
                 print $fh &quot;type:debug %R***%n Friends list updated: &quot;,
@@ -783,11 +787,8 @@ sub get_updates {
                     sprintf( &quot;%d removed&quot;, $removed ) ),
                   &quot;\n&quot;;
             }
-
-            $last_friends_poll = time;
         }
 
-        print $fh &quot;__friends__\n&quot;;
         foreach ( sort keys %friends ) {
             print $fh &quot;$_ $friends{$_}\n&quot;;
         }
@@ -1015,15 +1016,17 @@ sub monitor_child {
 
     # first time we run we don't want to print out *everything*, so we just
     # pretend
-    my $suppress = 0;
-    $suppress = 1 unless keys %tweet_cache;
 
     if ( open FILE, $filename ) {
         my @lines;
         my %new_cache;
         while (&lt;FILE&gt;) {
-            chomp;
             last if /^__friends__/;
+            unless (/\n$/) {    # skip partial lines
+                                # print &quot;Skipping partial line: $_&quot; if &amp;debug;
+                next;
+            }
+            chomp;
             my $hilight = 0;
             my %meta;
 
@@ -1113,8 +1116,9 @@ sub monitor_child {
             } elsif ( $meta{type} eq 'searchid' ) {
                 print &quot;Search '$meta{topic}' returned id $meta{id}&quot; if &amp;debug;
                 if (
+                    not
                     exists $id_map{__searches}{ $meta{account} }{ $meta{topic} }
-                    and $meta{id} &gt;=
+                    or $meta{id} &gt;=
                     $id_map{__searches}{ $meta{account} }{ $meta{topic} } )
                 {
                     $id_map{__searches}{ $meta{account} }{ $meta{topic} } =
@@ -1138,6 +1142,12 @@ sub monitor_child {
 
         %friends = ();
         while (&lt;FILE&gt;) {
+            if (/^__updated (\d+)$/) {
+                $last_friends_poll = $1;
+                print &quot;Friend list updated&quot; if &amp;debug;
+                next;
+            }
+
             if (/^-- (\d+)$/) {
                 ($new_last_poll) = ($1);
                 last;
@@ -1149,7 +1159,7 @@ sub monitor_child {
         if ($new_last_poll) {
             print &quot;new last_poll    = $new_last_poll&quot; if &amp;debug;
             print &quot;new last_poll_id = &quot;, Dumper( $id_map{__last_id} ) if &amp;debug;
-            if ($suppress) {
+            if ($first_call) {
                 print &quot;First call, not printing updates&quot; if &amp;debug;
             } else {
                 foreach my $line (@lines) {
@@ -1189,7 +1199,8 @@ sub monitor_child {
                     &amp;ccrap(&quot;Failed to write replies to $file: $!&quot;);
                 }
             }
-            $failwhale = 0;
+            $failwhale  = 0;
+            $first_call = 0;
             return;
         }
     }</diff>
      <filename>twirssi.pl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a66a6f421e3cd0f4537f5868b2bc95acd021e8fe</id>
    </parent>
  </parents>
  <author>
    <name>Dan Boger</name>
    <email>zigdon@irc.peeron.com</email>
  </author>
  <url>http://github.com/bssteph/twirssi/commit/9f73fa0dc6d86b68bd6dc293600d44f6832258ef</url>
  <id>9f73fa0dc6d86b68bd6dc293600d44f6832258ef</id>
  <committed-date>2009-04-22T16:03:29-07:00</committed-date>
  <authored-date>2009-04-22T16:03:29-07:00</authored-date>
  <message>r618 - Fix reduced friends polling rate so that it actually works.  Make monitor_file ignore lines that are not complete</message>
  <tree>0d82ede489943d79b85947cae89f862d8d6f94b3</tree>
  <committer>
    <name>Dan Boger</name>
    <email>zigdon@irc.peeron.com</email>
  </committer>
</commit>
