use vars qw($VERSION %IRSSI);
-$VERSION = "2.4.1beta";
+$VERSION = "2.4.2beta";
%IRSSI = (
authors => 'Dan Boger',
contact => 'zigdon@gmail.com',
sub cmd_retweet_as {
my ( $data, $server, $win ) = @_;
- unless ( Irssi::settings_get_bool("twirssi_track_replies") ) {
- ¬ice("twirssi_track_replies is required in order to reteet.");
- return;
- }
-
return unless &logged_in($twit);
$data =~ s/^\s+|\s+$//;
sub cmd_reply_as {
my ( $data, $server, $win ) = @_;
- unless ( Irssi::settings_get_bool("twirssi_track_replies") ) {
- ¬ice("twirssi_track_replies is required in order to reply to "
- . "specific tweets. Either enable it, or just use /tweet "
- . "\@username <text>." );
- return;
- }
-
return unless &logged_in($twit);
$data =~ s/^\s+|\s+$//;
return unless &logged_in($twit);
my ( $fh, $filename ) = File::Temp::tempfile();
- binmode( $fh, ":utf8" );
+ binmode( $fh, ":" . &get_charset );
$child_pid = fork();
if ($child_pid) { # parent
}
$id_map{__searches}{$username}{$topic} = $search->{max_id};
+ $topic =~ s/ /%20/g;
printf $fh "id:%s account:%s type:searchid topic:%s\n",
$search->{max_id}, $username, $topic;
# pretend
if ( open FILE, $filename ) {
- binmode FILE, ":utf8";
+ binmode FILE, ":" . &get_charset;
my @lines;
my %new_cache;
while (<FILE>) {
my %meta;
foreach my $key (qw/id account nick type topic/) {
- if (s/^$key:(\S+)\s*//) {
+ if (s/^$key:((?:\S|\\ )+)\s*//) {
$meta{$key} = $1;
+ $meta{$key} =~ s/%20/ /g;
}
}
}
my $marker = "";
- if ( $meta{type} ne 'dm'
- and Irssi::settings_get_bool("twirssi_track_replies")
- and $meta{nick}
- and $meta{id} )
+ if ($meta{type} ne 'dm' and $meta{nick} and $meta{id} )
{
$marker = ( $id_map{__indexes}{ $meta{nick} } + 1 ) % 100;
$id_map{ lc $meta{nick} }[$marker] = $meta{id};
Irssi::pidwait_remove($child_pid);
# and that we don't leave any zombies behind, somehow
- wait();
+ waitpid( -1, WNOHANG );
# save id_map hash
if ( keys %id_map
} else {
print "Giving up on polling $filename" if &debug;
Irssi::pidwait_remove($child_pid);
- wait();
+ waitpid( -1, WNOHANG );
unlink $filename unless &debug;
return unless Irssi::settings_get_bool("twirssi_notify_timeouts");
return 60;
}
+sub get_charset {
+ my $charset = Irssi::settings_get_str("twirssi_charset");
+ return "utf8" if $charset =~ /^\s*$/;
+ return $charset;
+}
+
sub hilight {
my $text = shift;
"Set short_url_args to username,API_key or change your",
"short_url_provider."
);
- return decode "utf8", $data;
+ return decode &get_charset, $data;
}
}
}
}
- return decode "utf8", $data;
+ return decode &get_charset, $data;
}
sub normalize_username {
);
Irssi::settings_add_int( "twirssi", "twitter_poll_interval", 300 );
+Irssi::settings_add_str( "twirssi", "twirssi_charset", "utf8" );
Irssi::settings_add_str( "twirssi", "twitter_window", "twitter" );
Irssi::settings_add_str( "twirssi", "bitlbee_server", "bitlbee" );
Irssi::settings_add_str( "twirssi", "short_url_provider", "TinyURL" );
Irssi::settings_add_bool( "twirssi", "show_own_tweets", 1 );
Irssi::settings_add_bool( "twirssi", "twirssi_debug", 0 );
Irssi::settings_add_bool( "twirssi", "twirssi_first_run", 1 );
-Irssi::settings_add_bool( "twirssi", "twirssi_track_replies", 1 );
Irssi::settings_add_bool( "twirssi", "twirssi_replies_autonick", 1 );
Irssi::settings_add_bool( "twirssi", "twirssi_use_reply_aliases", 0 );
Irssi::settings_add_bool( "twirssi", "twirssi_notify_timeouts", 1 );