+ ¬ice("DM caused an error: $@");
+ return;
+ }
+}
+
+sub cmd_retweet {
+ my ( $data, $server, $win ) = @_;
+
+ return unless &logged_in($twit);
+
+ $data =~ s/^\s+|\s+$//;
+ unless ($data) {
+ ¬ice("Usage: /retweet <nick[:num]> [comment]");
+ return;
+ }
+
+ my ( $id, $data ) = split ' ', $data, 2;
+
+ &cmd_retweet_as( "$user $id $data", $server, $win );
+}
+
+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+$//;
+ my ( $username, $id, $data ) = split ' ', $data, 3;
+
+ unless ($username) {
+ ¬ice("Usage: /retweet_as <username> <nick[:num]> [comment]");
+ return;
+ }
+
+ return unless $username = &valid_username($username);
+
+ my $nick;
+ $id =~ s/[^\w\d\-:]+//g;
+ ( $nick, $id ) = split /:/, $id;
+ unless ( exists $id_map{ lc $nick } ) {
+ ¬ice("Can't find a tweet from $nick to retweet!");
+ return;
+ }
+
+ $id = $id_map{__indexes}{$nick} unless $id;
+ unless ( $id_map{ lc $nick }[$id] ) {
+ ¬ice("Can't find a tweet numbered $id from $nick to retweet!");