Massive rebranding under way. Removing twitter terminology replacing with fediverse terminology. Thanks Claude-code for the help. :)
This commit is contained in:
+130
-131
@@ -71,7 +71,7 @@ BEGIN {
|
||||
%opts_boolean = map { $_ => 1 } qw(
|
||||
ansi noansi verbose superverbose ttytteristas noprompt
|
||||
seven silent hold daemon script anonymous readline ssl
|
||||
newline vcheck verify noratelimit notrack nonewrts notimeline
|
||||
newline vcheck verify noratelimit notrack noreblogs notimeline
|
||||
synch exception_is_maskable mentions simplestart
|
||||
location readlinerepaint nocounter notifyquiet
|
||||
signals_use_posix dostream nostreamreplies streamallreplies
|
||||
@@ -85,13 +85,13 @@ BEGIN {
|
||||
nostreamreplies mentions wtrendurl atrendurl filterusers
|
||||
filterats filterrts filteratonly filterflags nofilter
|
||||
); %opts_urls = map {$_ => 1} qw(
|
||||
url dmurl uurl rurl wurl frurl rlurl update shorturl
|
||||
url dmurl uurl rurl wurl frurl rlurl update shoreblogurl
|
||||
apibase fediverseserver queryurl idurl delurl dmdelurl favsurl
|
||||
favurl favdelurl followurl leaveurl
|
||||
dmupdate credurl blockurl blockdelurl friendsurl
|
||||
modifyliurl adduliurl delliurl getliurl getlisurl getfliurl
|
||||
creliurl delliurl deluliurl crefliurl delfliurl
|
||||
getuliurl getufliurl dmsenturl rturl rtsbyurl dmidurl
|
||||
getuliurl getufliurl dmsenturl reblogurl rtsbyurl dmidurl
|
||||
statusliurl followliurl leaveliurl followersurl
|
||||
oauthurl oauthauthurl oauthaccurl oauthbase wtrendurl
|
||||
atrendurl frupdurl lookupidurl rtsofmeurl
|
||||
@@ -107,7 +107,7 @@ BEGIN {
|
||||
%opts_can_set = map { $_ => 1 } qw(
|
||||
url pause dmurl dmpause superverbose ansi verbose
|
||||
update uurl rurl wurl avatar ttytteristas frurl track
|
||||
rlurl noprompt shorturl newline wrap verify autosplit
|
||||
rlurl noprompt shoreblogurl newline wrap verify autosplit
|
||||
notimeline queryurl fediverseserver colourprompt colourme
|
||||
colourdm colourreply colourwarn coloursearch colourlist idurl
|
||||
urlopen delurl notrack dmdelurl favsurl
|
||||
@@ -117,7 +117,7 @@ BEGIN {
|
||||
nocounter linelength friendsurl followersurl lists
|
||||
modifyliurl adduliurl delliurl getliurl getlisurl getfliurl
|
||||
creliurl delliurl deluliurl crefliurl delfliurl atrendurl
|
||||
getuliurl getufliurl dmsenturl rturl rtsbyurl wtrendurl
|
||||
getuliurl getufliurl dmsenturl reblogurl rtsbyurl wtrendurl
|
||||
statusliurl followliurl leaveliurl dmidurl nostreamreplies
|
||||
frupdurl filterusers filterats filterrts filterflags
|
||||
filteratonly nofilter rtsofmeurl
|
||||
@@ -125,7 +125,7 @@ BEGIN {
|
||||
lynx curl seven silent maxhist noansi hold status
|
||||
daemon timestamp twarg user anonymous script readline
|
||||
leader ssl rc norc vcheck apibase notifytype exts
|
||||
nonewrts synch runcommand authtype oauthkey oauthsecret
|
||||
noreblogs synch runcommand authtype oauthkey oauthsecret
|
||||
tokenkey tokensecret credurl keyf readlinerepaint
|
||||
simplestart exception_is_maskable oldperl notco
|
||||
notify_tool_path oauthurl oauthauthurl oauthaccurl oauthbase
|
||||
@@ -221,7 +221,7 @@ EOF
|
||||
$uurl = "${apibase}/accounts/%I/statuses";
|
||||
$idurl = "${apibase}/statuses/%I";
|
||||
$delurl = "${apibase}/statuses/%I";
|
||||
$rturl = "${apibase}/statuses/%I/reblog";
|
||||
$reblogurl = "${apibase}/statuses/%I/reblog";
|
||||
$wurl = "${apibase}/accounts/%I";
|
||||
$followurl = "${apibase}/accounts/%I/follow";
|
||||
$leaveurl = "${apibase}/accounts/%I/unfollow";
|
||||
@@ -505,7 +505,7 @@ $alphabet = "abcdefghijkLmnopqrstuvwxyz";
|
||||
%store_hash = ();
|
||||
$mini_split = 250; # i.e., 10 tweets for the mini-menu (/th)
|
||||
# leaving 50 tweets for the foreground temporary menus
|
||||
$tweet_counter = 0;
|
||||
$post_counter = 0;
|
||||
%dm_store_hash = ();
|
||||
$dm_counter = 0;
|
||||
%id_cache = ();
|
||||
@@ -513,7 +513,7 @@ $dm_counter = 0;
|
||||
|
||||
# set up threading management
|
||||
$in_reply_to = 0;
|
||||
$expected_tweet_ref = undef;
|
||||
$expected_post_ref = undef;
|
||||
|
||||
# interpret -script at this level
|
||||
if ($script) {
|
||||
@@ -575,7 +575,7 @@ if (length($exts) && $exts ne '0') {
|
||||
|
||||
# these methods are multi-module safe
|
||||
foreach $arry (qw(
|
||||
handle exception tweettype conclude dmhandle dmconclude
|
||||
handle exception posttype conclude dmhandle dmconclude
|
||||
heartbeat precommand prepost postpost addaction
|
||||
eventhandle listhandle userhandle shutdown)) {
|
||||
if (defined($$arry)) {
|
||||
@@ -607,7 +607,7 @@ if (length($exts) && $exts ne '0') {
|
||||
|
||||
$handle = \&multihandle;
|
||||
$exception = \&multiexception;
|
||||
$tweettype = \&multitweettype;
|
||||
$posttype = \&multiposttype;
|
||||
$conclude = \&multiconclude;
|
||||
$dmhandle = \&multidmhandle;
|
||||
$dmconclude = \&multidmconclude;
|
||||
@@ -628,7 +628,7 @@ if (length($exts) && $exts ne '0') {
|
||||
|
||||
$handle = \&defaulthandle;
|
||||
$exception = \&defaultexception;
|
||||
$tweettype = \&defaulttweettype;
|
||||
$posttype = \&defaultposttype;
|
||||
$conclude = \&defaultconclude;
|
||||
$dmhandle = \&defaultdmhandle;
|
||||
$dmconclude = \&defaultdmconclude;
|
||||
@@ -761,7 +761,7 @@ $fediverseserver ||= "mastodon.social";
|
||||
$oauthbase ||= $apibase || "${http_proto}://${fediverseserver}";
|
||||
# this needs to be AFTER oauthbase so that apibase can set oauthbase.
|
||||
$apibase ||= "${http_proto}://${fediverseserver}/api/v1";
|
||||
$nonewrts ||= 0;
|
||||
$noreblogs ||= 0;
|
||||
|
||||
# special case: if we explicitly refuse backload, don't load initially.
|
||||
$backload = 30 if (!defined($backload)); # zero is valid!
|
||||
@@ -782,7 +782,7 @@ $uurl ||= "${apibase}/accounts/%I/statuses";
|
||||
$idurl ||= "${apibase}/statuses/%I";
|
||||
$delurl ||= "${apibase}/statuses/%I";
|
||||
|
||||
$rturl ||= "${apibase}/statuses/%I/reblog";
|
||||
$reblogurl ||= "${apibase}/statuses/%I/reblog";
|
||||
$rtsbyurl ||= "${apibase}/statuses/retweets/%I.json";
|
||||
$rtsofmeurl ||= "${apibase}/statuses/retweets_of_me.json";
|
||||
|
||||
@@ -834,8 +834,8 @@ $wtrendurl ||= "${apibase}/trends";
|
||||
$atrendurl ||= "${apibase}/trends";
|
||||
|
||||
# pick ONE!
|
||||
#$shorturl ||= "http://api.tr.im/v1/trim_simple?url=";
|
||||
$shorturl ||= "http://is.gd/api.php?longurl=";
|
||||
#$shoreblogurl ||= "http://api.tr.im/v1/trim_simple?url=";
|
||||
$shoreblogurl ||= "http://is.gd/api.php?longurl=";
|
||||
|
||||
# figure out the domain to stop shortener loops
|
||||
&generate_shortdomain;
|
||||
@@ -1916,11 +1916,11 @@ print $stdout "*** invalid UTF-8: partial delete of a wide character?\n";
|
||||
|
||||
if ($i) {
|
||||
print $stdout "(expanded to \"$_\")\n" ;
|
||||
$in_reply_to = $expected_tweet_ref->{'id_str'} || 0
|
||||
if (defined $expected_tweet_ref &&
|
||||
ref($expected_tweet_ref) eq 'HASH');
|
||||
$in_reply_to = $expected_post_ref->{'id_str'} || 0
|
||||
if (defined $expected_post_ref &&
|
||||
ref($expected_post_ref) eq 'HASH');
|
||||
} else {
|
||||
$expected_tweet_ref = undef;
|
||||
$expected_post_ref = undef;
|
||||
}
|
||||
|
||||
return 0 unless length; # actually possible to happen
|
||||
@@ -1950,13 +1950,13 @@ print $stdout "*** invalid UTF-8: partial delete of a wide character?\n";
|
||||
if (m#^/du(mp)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
my $code = lc($2);
|
||||
unless ($code =~ /^d[0-9][0-9]+$/) { # this is a DM.
|
||||
my $tweet = &get_tweet($code);
|
||||
my $post = &get_post($code);
|
||||
my $k;
|
||||
my $sn;
|
||||
my $id;
|
||||
my @superfields = (
|
||||
[ "user", "screen_name" ], # must always be first
|
||||
[ "retweeted_status", "id_str" ],
|
||||
[ "reblog", "id_str" ],
|
||||
[ "user", "geo_enabled" ],
|
||||
[ "place", "id" ],
|
||||
[ "place", "country_code" ],
|
||||
@@ -1987,7 +1987,7 @@ print $stdout "*** invalid UTF-8: partial delete of a wide character?\n";
|
||||
print $stdout "geo->coordinates (" .
|
||||
join(', ', @{ $tweet->{'geo'}->{'coordinates'} })
|
||||
. ")\n";
|
||||
foreach $k (sort keys %{ $tweet }) {
|
||||
foreach $k (sort keys %{ $post }) {
|
||||
next if (ref($tweet->{$k}));
|
||||
print $stdout
|
||||
substr("$k ", 0, 25) .
|
||||
@@ -2910,15 +2910,15 @@ EOF
|
||||
return 0;
|
||||
}
|
||||
my $code = lc($3);
|
||||
my $tweet = &get_tweet($code);
|
||||
my $post = &get_post($code);
|
||||
if (!defined($tweet)) {
|
||||
print $stdout "-- no such post (yet?): $code\n";
|
||||
return 0;
|
||||
}
|
||||
my $limit = 9;
|
||||
my $id = $tweet->{'retweeted_status'}->{'id_str'} ||
|
||||
my $id = $tweet->{'reblog'}->{'id_str'} ||
|
||||
$tweet->{'in_reply_to_status_id_str'};
|
||||
my $thread_ref = [ $tweet ];
|
||||
my $thread_ref = [ $post ];
|
||||
while ($id && $limit) {
|
||||
print $stdout "-- thread: fetching $id\n"
|
||||
if ($verbose);
|
||||
@@ -2929,7 +2929,7 @@ EOF
|
||||
if (defined($next) && ref($next) eq 'HASH') {
|
||||
push(@{ $thread_ref },
|
||||
&fix_geo_api_data($next));
|
||||
$id = $next->{'retweeted_status'}->{'id_str'}
|
||||
$id = $next->{'reblog'}->{'id_str'}
|
||||
|| $next->{'in_reply_to_status_id_str'}
|
||||
|| 0;
|
||||
}
|
||||
@@ -2958,7 +2958,7 @@ EOF
|
||||
$thing = "DM";
|
||||
$genurl = $dmidurl;
|
||||
} else {
|
||||
$hash = &get_tweet($code);
|
||||
$hash = &get_post($code);
|
||||
$thing = "tweet";
|
||||
$genurl = $idurl;
|
||||
}
|
||||
@@ -2976,9 +2976,9 @@ EOF
|
||||
}
|
||||
|
||||
# if a retweeted status, get the status.
|
||||
$hash = $hash->{'retweeted_status'}
|
||||
if (defined($hash->{'retweeted_status'}) &&
|
||||
ref($hash->{'retweeted_status'}) eq 'HASH');
|
||||
$hash = $hash->{'reblog'}
|
||||
if (defined($hash->{'reblog'}) &&
|
||||
ref($hash->{'reblog'}) eq 'HASH');
|
||||
|
||||
my $didprint = 0;
|
||||
# Twitter puts entities in multiple fields.
|
||||
@@ -3021,12 +3021,12 @@ EOF
|
||||
}
|
||||
if (m#^/(url|open) ([dDzZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
my $code = lc($2);
|
||||
my $tweet;
|
||||
my $post;
|
||||
my $genurl = undef;
|
||||
$urlshort = undef;
|
||||
|
||||
if ($code =~ /^d/ && length($code) > 2) {
|
||||
$tweet = &get_dm($code); # USO!
|
||||
$post = &get_dm($code); # USO!
|
||||
if (!defined($tweet)) {
|
||||
print $stdout
|
||||
"-- no such DM (yet?): $code\n";
|
||||
@@ -3034,7 +3034,7 @@ EOF
|
||||
}
|
||||
$genurl = $dmidurl;
|
||||
} else {
|
||||
$tweet = &get_tweet($code);
|
||||
$post = &get_post($code);
|
||||
if (!defined($tweet)) {
|
||||
print $stdout
|
||||
"-- no such post (yet?): $code\n";
|
||||
@@ -3046,7 +3046,7 @@ EOF
|
||||
# to be TOS-compliant, we must try entities first to use
|
||||
# t.co wrapped links. this is a tiny version of /entities.
|
||||
unless ($notco) {
|
||||
my $id = $tweet->{'retweeted_status'}->{'id_str'}
|
||||
my $id = $tweet->{'reblog'}->{'id_str'}
|
||||
|| $tweet->{'id_str'};
|
||||
my $hash;
|
||||
|
||||
@@ -3159,7 +3159,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
"-- hmm. seems contradictory. no dice.\n";
|
||||
return 0;
|
||||
}
|
||||
my $tweet = &get_tweet($code);
|
||||
my $post = &get_post($code);
|
||||
if (!defined($tweet)) {
|
||||
print $stdout "-- no such post (yet?): $code\n";
|
||||
return 0;
|
||||
@@ -3180,20 +3180,20 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
if (s#^/([oe]?)boost ([zZ]?[a-zA-Z]?[0-9]+)\s*##) {
|
||||
my $mode = $1;
|
||||
my $code = lc($2);
|
||||
my $tweet = &get_tweet($code);
|
||||
my $post = &get_post($code);
|
||||
if (!defined($tweet)) {
|
||||
print $stdout "-- no such post (yet?): $code\n";
|
||||
return 0;
|
||||
}
|
||||
# use a native retweet unless we can't (or user used /ort /ert)
|
||||
unless ($nonewrts || length || length($mode)) {
|
||||
unless ($noreblogs || length || length($mode)) {
|
||||
# we don't always get rs->text, so we simulate it.
|
||||
my $text = &descape($tweet->{'text'});
|
||||
$text =~ s/^RT \@[^\s]+:\s+//
|
||||
if ($tweet->{'retweeted_status'}->{'id_str'});
|
||||
if ($tweet->{'reblog'}->{'id_str'});
|
||||
print $stdout "-- status boosted\n"
|
||||
unless(&updatest($text, 1, 0, undef,
|
||||
$tweet->{'retweeted_status'}->{'id_str'}
|
||||
$tweet->{'reblog'}->{'id_str'}
|
||||
|| $tweet->{'id_str'}));
|
||||
return 0;
|
||||
}
|
||||
@@ -3213,7 +3213,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
goto TWEETPRINT; # fugly! FUGLY!
|
||||
}
|
||||
|
||||
if (m#^/(re)?rts?of?me?(\s+\+\d+)?$# && !$nonewrts) {
|
||||
if (m#^/(re)?rts?of?me?(\s+\+\d+)?$# && !$noreblogs) {
|
||||
#TODO
|
||||
# when more fields are added, integrate them over the JSON_ref
|
||||
my $mode = $1;
|
||||
@@ -3229,16 +3229,16 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (m#^/rts?of\s+([zZ]?[a-zA-Z]?[0-9]+)$# && !$nonewrts) {
|
||||
if (m#^/rts?of\s+([zZ]?[a-zA-Z]?[0-9]+)$# && !$noreblogs) {
|
||||
my $code = lc($1);
|
||||
my $tweet = &get_tweet($code);
|
||||
my $post = &get_post($code);
|
||||
my $id;
|
||||
|
||||
if (!defined($tweet)) {
|
||||
print $stdout "-- no such post (yet?): $code\n";
|
||||
return 0;
|
||||
}
|
||||
$id = $tweet->{'retweeted_status'}->{'id_str'} ||
|
||||
$id = $tweet->{'reblog'}->{'id_str'} ||
|
||||
$tweet->{'id_str'};
|
||||
if (!$id) {
|
||||
print $stdout "-- hmmm, that post is major bogus.\n";
|
||||
@@ -3262,7 +3262,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
}
|
||||
|
||||
# enable and disable NewRTs from users
|
||||
# we allow this even if newRTs are off from -nonewrts
|
||||
# we allow this even if newRTs are off from -noreblogs
|
||||
if (s#^/rts(on|off)\s+## && length) {
|
||||
&rtsonoffuser($_, 1, ($1 eq 'on'));
|
||||
return 0;
|
||||
@@ -3271,7 +3271,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
if (m#^/del(ete)?\s+([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
my $code = lc($2);
|
||||
unless ($code =~ /^d[0-9][0-9]+$/) { # this is a DM.
|
||||
my $tweet = &get_tweet($code);
|
||||
my $post = &get_post($code);
|
||||
if (!defined($tweet)) {
|
||||
print $stdout "-- no such post (yet?): $code\n";
|
||||
return 0;
|
||||
@@ -3347,7 +3347,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
my $mode = $1;
|
||||
my $code = lc($3);
|
||||
unless ($code =~ /^d[0-9][0-9]+/) { # this is a DM
|
||||
my $tweet = &get_tweet($code);
|
||||
my $post = &get_post($code);
|
||||
if (!defined($tweet)) {
|
||||
print $stdout "-- no such post (yet?): $code\n";
|
||||
return 0;
|
||||
@@ -3356,7 +3356,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
$_ = '@' . $target . " $_";
|
||||
unless ($mode eq 'v') {
|
||||
$in_reply_to = $tweet->{'id_str'};
|
||||
$expected_tweet_ref = $tweet;
|
||||
$expected_post_ref = $tweet;
|
||||
} else {
|
||||
$_ = ".$_";
|
||||
}
|
||||
@@ -3392,7 +3392,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
my $code = $5;
|
||||
|
||||
# common code from /vreply
|
||||
my $tweet = &get_tweet($code);
|
||||
my $post = &get_post($code);
|
||||
if (!defined($tweet)) {
|
||||
print $stdout "-- no such post (yet?): $code\n";
|
||||
return 0;
|
||||
@@ -3402,7 +3402,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) {
|
||||
$_ = '@' . $target;
|
||||
unless ($mode eq 'v') {
|
||||
$in_reply_to = $tweet->{'id_str'};
|
||||
$expected_tweet_ref = $tweet;
|
||||
$expected_post_ref = $tweet;
|
||||
} else {
|
||||
$_ = ".$_";
|
||||
}
|
||||
@@ -4274,7 +4274,7 @@ EOF
|
||||
$suspend_output = 0; # reset our status
|
||||
goto RESTART_SELECT;
|
||||
} elsif ($rout =~ /^pipet (..)/) {
|
||||
my $key = &get_tweet($1);
|
||||
my $key = &get_post($1);
|
||||
my $ms = $key->{'menu_select'} || 'XX';
|
||||
my $ds = $key->{'created_at'} || 'argh, no created_at';
|
||||
$ds =~ s/\s/_/g;
|
||||
@@ -4282,7 +4282,7 @@ EOF
|
||||
$src =~ s/\|//g; # shouldn't be any anyway.
|
||||
$key = substr(( "$ms ".($key->{'id_str'})." ".
|
||||
($key->{'in_reply_to_status_id_str'})." ".
|
||||
($key->{'retweeted_status'}->{'id_str'})." ".
|
||||
($key->{'reblog'}->{'id_str'})." ".
|
||||
($key->{'user'}->{'geo_enabled'} || "false") . " ".
|
||||
($key->{'geo'}->{'coordinates'}->[0]). " ".
|
||||
($key->{'geo'}->{'coordinates'}->[1]). " ".
|
||||
@@ -4292,7 +4292,7 @@ EOF
|
||||
unpack("${pack_magic}H*", $key->{'place'}->{'full_name'})." ".
|
||||
$key->{'tag'}->{'type'}. " ". # NO SPACES!
|
||||
unpack("${pack_magic}H*", $key->{'tag'}->{'payload'}). " ".
|
||||
($key->{'retweet_count'} || "0") . " " .
|
||||
($key->{'reblogs_count'} || "0") . " " .
|
||||
$key->{'user'}->{'screen_name'}." $ds $src|".
|
||||
unpack("${pack_magic}H*", $key->{'text'}).
|
||||
$space_pad), 0, 1024);
|
||||
@@ -4777,13 +4777,13 @@ sub handle_twitter_stream_event {
|
||||
$payload->{'tag'}->{'payload'} = 'stream';
|
||||
|
||||
# filter replies from streaming socket if the
|
||||
# user requested it. use $tweettype to determine
|
||||
# user requested it. use $posttype to determine
|
||||
# this so the user can interpose custom logic.
|
||||
if ($nostreamreplies) {
|
||||
my $sn = &descape(
|
||||
$payload->{'user'}->{'screen_name'});
|
||||
my $text = &descape($payload->{'text'});
|
||||
return if (&$tweettype($payload, $sn, $text) eq
|
||||
return if (&$posttype($payload, $sn, $text) eq
|
||||
'reply');
|
||||
}
|
||||
|
||||
@@ -4846,7 +4846,7 @@ sub handle_mastodon_stream_event {
|
||||
if ($nostreamreplies) {
|
||||
my $sn = &descape($payload->{'user'}->{'screen_name'});
|
||||
my $text = &descape($payload->{'text'});
|
||||
return if (&$tweettype($payload, $sn, $text) eq 'reply');
|
||||
return if (&$posttype($payload, $sn, $text) eq 'reply');
|
||||
}
|
||||
|
||||
# Filter and dedupe
|
||||
@@ -5123,7 +5123,7 @@ sub refresh {
|
||||
sub killtw { my $j = shift; $filtered++; $filter_next{$j->{'id_str'}}++
|
||||
if ($is_background); }
|
||||
|
||||
# handle (i.e., display) an array of tweets in standard format
|
||||
# handle (i.e., display) an array of posts in standard format
|
||||
sub tdisplay { # used by both synchronous /again and asynchronous refreshes
|
||||
my $my_json_ref = shift;
|
||||
my $class = shift;
|
||||
@@ -5141,13 +5141,13 @@ sub tdisplay { # used by both synchronous /again and asynchronous refreshes
|
||||
#TODO
|
||||
# generalize this at some point instead of hardcoded menu codes
|
||||
# maybe an ma0-mz9?
|
||||
$save_counter = $tweet_counter;
|
||||
$tweet_counter = $mini_split;
|
||||
$save_counter = $post_counter;
|
||||
$post_counter = $mini_split;
|
||||
for(0..9) {
|
||||
undef $store_hash{"zz$_"};
|
||||
}
|
||||
}# else {
|
||||
# $tweet_counter = $back_split;
|
||||
# $post_counter = $back_split;
|
||||
# %store_hash = ();
|
||||
#}
|
||||
}
|
||||
@@ -5182,16 +5182,16 @@ sub tdisplay { # used by both synchronous /again and asynchronous refreshes
|
||||
# and if the tweet has a retweeted status, do for
|
||||
# that.
|
||||
(&killtw($j), next) if
|
||||
($j->{'retweeted_status'} &&
|
||||
($j->{'reblog'} &&
|
||||
$filterusers_sub &&
|
||||
&$filterusers_sub(lc(&descape($j->
|
||||
{'retweeted_status'}->
|
||||
{'reblog'}->
|
||||
{'user'}->{'screen_name'}))));
|
||||
|
||||
# second, filterrts. this is almost as fast.
|
||||
(&killtw($j), next) if
|
||||
($filterrts_sub &&
|
||||
length($j->{'retweeted_status'}->{'id_str'})&&
|
||||
length($j->{'reblog'}->{'id_str'})&&
|
||||
&$filterrts_sub($sn));
|
||||
|
||||
# third, filteratonly. this has a fast case and a
|
||||
@@ -5213,12 +5213,12 @@ sub tdisplay { # used by both synchronous /again and asynchronous refreshes
|
||||
# damn it, user may actually want this tweet.
|
||||
# assign menu codes and place into caches
|
||||
$key = (($is_background) ? '' : 'z' ).
|
||||
substr($alphabet, $tweet_counter/10, 1) .
|
||||
$tweet_counter % 10;
|
||||
$tweet_counter =
|
||||
($tweet_counter == 259) ? $mini_split :
|
||||
($tweet_counter == ($mini_split - 1))
|
||||
? 0 : ($tweet_counter+1);
|
||||
substr($alphabet, $post_counter/10, 1) .
|
||||
$post_counter % 10;
|
||||
$post_counter =
|
||||
($post_counter == 259) ? $mini_split :
|
||||
($post_counter == ($mini_split - 1))
|
||||
? 0 : ($post_counter+1);
|
||||
$j->{'menu_select'} = $key;
|
||||
$key = lc($key);
|
||||
|
||||
@@ -5243,7 +5243,7 @@ sub tdisplay { # used by both synchronous /again and asynchronous refreshes
|
||||
undef))));
|
||||
}
|
||||
}
|
||||
$tweet_counter = $save_counter if ($save_counter > -1);
|
||||
$post_counter = $save_counter if ($save_counter > -1);
|
||||
sleep 5 while ($suspend_output > 0);
|
||||
&$exception(6,"*** warning: more tweets than menu codes; truncated\n")
|
||||
if (scalar(@{ $my_json_ref }) > $print_max);
|
||||
@@ -5489,7 +5489,7 @@ sub updatest {
|
||||
}
|
||||
}
|
||||
my $return = &backticks($baseagent, '/dev/null', undef,
|
||||
($rt_id) ? "$rturl/${rt_id}.json" : $update,
|
||||
($rt_id) ? "$reblogurl/${rt_id}.json" : $update,
|
||||
$i, 0, @wend);
|
||||
print $stdout "-- return --\n$return\n-- return --\n"
|
||||
if ($superverbose);
|
||||
@@ -5659,22 +5659,22 @@ sub graburl {
|
||||
}
|
||||
|
||||
# format a tweet based on user options
|
||||
sub standardtweet {
|
||||
sub standardpost {
|
||||
my $ref = shift;
|
||||
my $nocolour = shift;
|
||||
|
||||
my $sn = &descape($ref->{'user'}->{'screen_name'});
|
||||
my $tweet = &descape($ref->{'text'});
|
||||
my $post = &descape($ref->{'text'});
|
||||
|
||||
# Debug boost display
|
||||
if (exists($ref->{'boost_attribution'}) && $ref->{'boost_attribution'}) {
|
||||
print $stdout "-- DEBUG: standardtweet - user: '$sn', text: '$tweet', boost_attribution: '" . $ref->{'boost_attribution'} . "'\n" if ($verbose);
|
||||
print $stdout "-- DEBUG: standardpost - user: '$sn', text: '$post', boost_attribution: '" . $ref->{'boost_attribution'} . "'\n" if ($verbose);
|
||||
}
|
||||
|
||||
# Add boost attribution if this is a boosted post
|
||||
if (exists($ref->{'boost_attribution'}) && $ref->{'boost_attribution'}) {
|
||||
my $booster = &descape($ref->{'boost_attribution'});
|
||||
$tweet = "[boosted $booster] $tweet";
|
||||
$post = "[boosted $booster] $post";
|
||||
}
|
||||
my $colour;
|
||||
my $g;
|
||||
@@ -5683,7 +5683,7 @@ sub standardtweet {
|
||||
# wordwrap really ruins our day here, thanks a lot, @augmentedfourth
|
||||
# have to insinuate the ansi sequences after the string is wordwrapped
|
||||
|
||||
$g = $colour = ${'CC' . scalar(&$tweettype($ref, $sn, $tweet)) }
|
||||
$g = $colour = ${'CC' . scalar(&$posttype($ref, $sn, $tweet)) }
|
||||
unless ($nocolour);
|
||||
$colour = $OFF . $colour
|
||||
unless ($nocolour);
|
||||
@@ -5696,36 +5696,36 @@ sub standardtweet {
|
||||
$ref->{'geo'}->{'coordinates'}->[1] ne 'undef' &&
|
||||
length($ref->{'geo'}->{'coordinates'}->[0])) ||
|
||||
length($ref->{'place'}->{'id'})));
|
||||
$sn = "%$sn" if (length($ref->{'retweeted_status'}->{'id_str'}));
|
||||
$sn = "%$sn" if (length($ref->{'reblog'}->{'id_str'}));
|
||||
$sn = "*$sn" if ($ref->{'source'} =~ /TTYverse/ && $ttytteristas);
|
||||
# prepend list information, if this tweet originated from a list
|
||||
$sn = "($ref->{'tag'}->{'payload'})$sn"
|
||||
if (length($ref->{'tag'}->{'payload'}) &&
|
||||
$ref->{'tag'}->{'type'} eq 'list');
|
||||
$tweet = "<$sn> $tweet";
|
||||
$post = "<$sn> $post";
|
||||
# twitter doesn't always do this right.
|
||||
$h = $ref->{'retweet_count'}; $h += 0; #$h = "${h}+" if ($h >= 100);
|
||||
$h = $ref->{'reblogs_count'}; $h += 0; #$h = "${h}+" if ($h >= 100);
|
||||
# twitter doesn't always handle single retweets right. good f'n grief.
|
||||
$tweet = "(x${h}) $tweet" if ($h > 1 && !$nonewrts);
|
||||
$post = "(x${h}) $post" if ($h > 1 && !$noreblogs);
|
||||
# br3nda's modified timestamp patch
|
||||
if ($timestamp) {
|
||||
my ($time, $ts) = &$wraptime($ref->{'created_at'});
|
||||
$tweet = "[$ts] $tweet";
|
||||
$post = "[$ts] $post";
|
||||
}
|
||||
|
||||
# pull it all together
|
||||
$tweet = &wwrap($tweet, ($wrapseq <= 1) ? ((&$prompt(1))[1]) : 0)
|
||||
$post = &wwrap($post, ($wrapseq <= 1) ? ((&$prompt(1))[1]) : 0)
|
||||
if ($wrap); # remember to account for prompt length on #1
|
||||
$tweet =~ s/^([^<]*)<([^>]+)>/${g}\1<${EM}\2${colour}>/
|
||||
$post =~ s/^([^<]*)<([^>]+)>/${g}\1<${EM}\2${colour}>/
|
||||
unless ($nocolour);
|
||||
$tweet =~ s/\n*$//;
|
||||
$tweet .= ($nocolour) ? "\n" : "$OFF\n";
|
||||
$post =~ s/\n*$//;
|
||||
$post .= ($nocolour) ? "\n" : "$OFF\n";
|
||||
|
||||
# highlight anything that we have in track
|
||||
if(scalar(@tracktags)) { # I'm paranoid
|
||||
foreach $h (@tracktags) {
|
||||
$h =~ s/^"//; $h =~ s/"$//; # just in case
|
||||
$tweet =~ s/(^|[^a-zA-Z0-9])($h)([^a-zA-Z0-9]|$)/\1${EM}\2${colour}\3/ig
|
||||
$post =~ s/(^|[^a-zA-Z0-9])($h)([^a-zA-Z0-9]|$)/\1${EM}\2${colour}\3/ig
|
||||
unless ($nocolour);
|
||||
}
|
||||
}
|
||||
@@ -5733,15 +5733,15 @@ $tweet =~ s/(^|[^a-zA-Z0-9])($h)([^a-zA-Z0-9]|$)/\1${EM}\2${colour}\3/ig
|
||||
# smb's underline/bold patch goes on last (modified for lists)
|
||||
unless ($nocolour) {
|
||||
# only do this after the < > portion.
|
||||
my $k = index($tweet, ">");
|
||||
my $botsub = substr($tweet, $k);
|
||||
my $topsub = substr($tweet, 0, $k);
|
||||
my $k = index($post, ">");
|
||||
my $botsub = substr($post, $k);
|
||||
my $topsub = substr($post, 0, $k);
|
||||
$botsub =~
|
||||
s/(^|[^a-zA-Z0-9_])\@([a-zA-Z0-9_\/]+)/\1\@${UNDER}\2${colour}/g;
|
||||
$tweet = $topsub . $botsub;
|
||||
$post = $topsub . $botsub;
|
||||
}
|
||||
|
||||
return $tweet;
|
||||
return $post;
|
||||
}
|
||||
|
||||
# format a DM based on standard user options
|
||||
@@ -6079,8 +6079,8 @@ sub multiprepost {
|
||||
sub multipostpost {
|
||||
&multi_module_dispatch(\&defaultpostpost, \@m_postpost, 0, @_);
|
||||
}
|
||||
sub multitweettype {
|
||||
&multi_module_dispatch(\&defaulttweettype, \@m_tweettype, sub {
|
||||
sub multiposttype {
|
||||
&multi_module_dispatch(\&defaultposttype, \@m_posttype, sub {
|
||||
# if this module DID NOT call default, exit now.
|
||||
return (!$this_call_default);
|
||||
}, @_);
|
||||
@@ -6120,18 +6120,18 @@ sub defaultlisthandle {
|
||||
}
|
||||
sub defaulthandle {
|
||||
(&flag_default_call, return) if ($multi_module_context);
|
||||
my $tweet_ref = shift;
|
||||
my $post_ref = shift;
|
||||
my $class = shift;
|
||||
my $dclass = ($verbose) ? "{$class,$tweet_ref->{'id_str'}} " : '';
|
||||
my $sn = &descape($tweet_ref->{'user'}->{'screen_name'});
|
||||
my $tweet = &descape($tweet_ref->{'text'});
|
||||
my $dclass = ($verbose) ? "{$class,$post_ref->{'id_str'}} " : '';
|
||||
my $sn = &descape($post_ref->{'user'}->{'screen_name'});
|
||||
my $post = &descape($post_ref->{'text'});
|
||||
|
||||
# Debug: Check what data defaulthandle receives for boost posts
|
||||
if (exists($tweet_ref->{'boost_attribution'}) && $tweet_ref->{'boost_attribution'}) {
|
||||
print $stdout "-- DEBUG: defaulthandle received boost - user: '$sn', text: '$tweet', boost_attribution: '" . $tweet_ref->{'boost_attribution'} . "'\n" if ($verbose);
|
||||
if (exists($post_ref->{'boost_attribution'}) && $post_ref->{'boost_attribution'}) {
|
||||
print $stdout "-- DEBUG: defaulthandle received boost - user: '$sn', text: '$post', boost_attribution: '" . $post_ref->{'boost_attribution'} . "'\n" if ($verbose);
|
||||
}
|
||||
my $stweet = &standardtweet($tweet_ref);
|
||||
my $menu_select = $tweet_ref->{'menu_select'};
|
||||
my $spost = &standardpost($post_ref);
|
||||
my $menu_select = $post_ref->{'menu_select'};
|
||||
|
||||
$menu_select = (length($menu_select) && !$script)
|
||||
? (($menu_select =~ /^z/) ?
|
||||
@@ -6139,8 +6139,8 @@ sub defaulthandle {
|
||||
"${menu_select}> ")
|
||||
: '';
|
||||
|
||||
print $streamout $menu_select . $dclass . $stweet;
|
||||
&sendnotifies($tweet_ref, $class);
|
||||
print $streamout $menu_select . $dclass . $spost;
|
||||
&sendnotifies($post_ref, $class);
|
||||
return 1;
|
||||
}
|
||||
sub defaultuserhandle {
|
||||
@@ -6171,33 +6171,33 @@ EOF
|
||||
return;
|
||||
}
|
||||
sub sendnotifies { # this is a default subroutine of a sort, right?
|
||||
my $tweet_ref = shift;
|
||||
my $post_ref = shift;
|
||||
my $class = shift;
|
||||
|
||||
my $sn = &descape($tweet_ref->{'user'}->{'screen_name'});
|
||||
my $tweet = &descape($tweet_ref->{'text'});
|
||||
my $sn = &descape($post_ref->{'user'}->{'screen_name'});
|
||||
my $post = &descape($post_ref->{'text'});
|
||||
|
||||
# interactive? first time?
|
||||
unless (length($class) || !$last_id || !length($tweet)) {
|
||||
$class = scalar(&$tweettype($tweet_ref, $sn, $tweet));
|
||||
$class = scalar(&$posttype($post_ref, $sn, $tweet));
|
||||
¬ifytype_dispatch($class,
|
||||
&standardtweet($tweet_ref, 1), $tweet_ref)
|
||||
&standardpost($post_ref, 1), $post_ref)
|
||||
if ($notify_list{$class});
|
||||
}
|
||||
}
|
||||
|
||||
sub defaulttweettype {
|
||||
sub defaultposttype {
|
||||
(&flag_default_call, return) if ($multi_module_context);
|
||||
my $ref = shift;
|
||||
my $sn = shift;
|
||||
my $tweet = shift;
|
||||
my $post = shift;
|
||||
|
||||
# br3nda's and smb's modified colour patch
|
||||
unless ($anonymous) {
|
||||
if (lc($sn) eq $whoami) {
|
||||
# if it's me speaking, colour the line yellow
|
||||
return 'me';
|
||||
} elsif ($tweet =~ /\@$whoami(\b|$)/i) {
|
||||
} elsif ($post =~ /\@$whoami(\b|$)/i) {
|
||||
# if I'm in the tweet, colour red
|
||||
return 'reply';
|
||||
}
|
||||
@@ -6422,7 +6422,7 @@ sub notifier_libnotify {
|
||||
# this is the central routine that takes a rolling tweet code, figures
|
||||
# out where that tweet is, and returns something approximating a tweet
|
||||
# structure (or the actual tweet structure itself if it can).
|
||||
sub get_tweet {
|
||||
sub get_post {
|
||||
my $code = lc(shift);
|
||||
|
||||
#TODO
|
||||
@@ -6458,7 +6458,7 @@ sub get_tweet {
|
||||
$k =~ s/\s+$//; # remove trailing spaces
|
||||
print $stdout "-- background store fetch: $k\n" if ($verbose);
|
||||
($w->{'menu_select'}, $w->{'id_str'}, $w->{'in_reply_to_status_id_str'},
|
||||
$w->{'retweeted_status'}->{'id_str'},
|
||||
$w->{'reblog'}->{'id_str'},
|
||||
$w->{'user'}->{'geo_enabled'},
|
||||
$w->{'geo'}->{'coordinates'}->[0],
|
||||
$w->{'geo'}->{'coordinates'}->[1],
|
||||
@@ -6468,7 +6468,7 @@ sub get_tweet {
|
||||
$w->{'place'}->{'full_name'},
|
||||
$w->{'tag'}->{'type'},
|
||||
$w->{'tag'}->{'payload'},
|
||||
$w->{'retweet_count'},
|
||||
$w->{'reblogs_count'},
|
||||
$w->{'user'}->{'screen_name'}, $w->{'created_at'},
|
||||
$l) = split(/\s/, $k, 17);
|
||||
($w->{'source'}, $k) = split(/\|/, $l, 2);
|
||||
@@ -6490,12 +6490,12 @@ sub get_dm {
|
||||
my $w = {'sender' => {}};
|
||||
return undef if (length($code) < 3 || $code !~ s/^d//);
|
||||
|
||||
# Handle foreground/background like get_tweet does
|
||||
# Handle foreground/background like get_post does
|
||||
if ($is_background) {
|
||||
return $dm_store_hash{$code};
|
||||
}
|
||||
|
||||
# this is the aforementioned "similar code" (see get_tweet).
|
||||
# this is the aforementioned "similar code" (see get_post).
|
||||
# optimization: I doubt ANY of us can get DMIDs less than 9.
|
||||
return &grabjson("${dmidurl}?id=$code", 0, 0, 0, undef, 1)
|
||||
if ($code =~ /^[0-9]+$/ && (0+$code > 9));
|
||||
@@ -6639,7 +6639,7 @@ sub setvariable {
|
||||
# handle special values
|
||||
&generate_ansi if ($key eq 'ansi' ||
|
||||
$key =~ /^colour/);
|
||||
&generate_shortdomain if ($key eq 'shorturl');
|
||||
&generate_shortdomain if ($key eq 'shoreblogurl');
|
||||
&tracktags_makearray if ($key eq 'track');
|
||||
&filter_compile if ($key eq 'filter');
|
||||
¬ify_compile if ($key eq 'notifies');
|
||||
@@ -6735,19 +6735,19 @@ sub generate_shortdomain {
|
||||
my $x;
|
||||
my $y;
|
||||
|
||||
undef $shorturldomain;
|
||||
($shorturl =~ m#^http://([^/]+)/#) && ($x = $1);
|
||||
undef $shoreblogurldomain;
|
||||
($shoreblogurl =~ m#^http://([^/]+)/#) && ($x = $1);
|
||||
# chop off any leading hostname stuff (like api., etc.)
|
||||
while(1) {
|
||||
$y = $x;
|
||||
$x =~ s/^[^\.]*\.//;
|
||||
if ($x !~ /\./) { # a cut too far
|
||||
$shorturldomain = "http://$y/";
|
||||
$shoreblogurldomain = "http://$y/";
|
||||
last;
|
||||
}
|
||||
}
|
||||
print $stdout "-- warning: couldn't parse shortener service\n"
|
||||
if (!length($shorturldomain));
|
||||
if (!length($shoreblogurldomain));
|
||||
}
|
||||
|
||||
sub openurl {
|
||||
@@ -6768,9 +6768,9 @@ sub urlshorten {
|
||||
|
||||
$url = "http://gopher.floodgap.com/gopher/gw?".&url_oauth_sub($url)
|
||||
if ($url =~ m#^gopher://#);
|
||||
return $url if ($url =~ /^$shorturldomain/i); # stop loops
|
||||
return $url if ($url =~ /^$shoreblogurldomain/i); # stop loops
|
||||
$url = &url_oauth_sub($url);
|
||||
$cl = "$simple_agent \"${shorturl}$url\"";
|
||||
$cl = "$simple_agent \"${shoreblogurl}$url\"";
|
||||
print $stdout "$cl\n" if ($superverbose);
|
||||
chomp($rc = `$cl`);
|
||||
return ($urlshort = (($rc =~ m#^http://#) ? $rc : undef));
|
||||
@@ -7527,7 +7527,7 @@ sub destroy_all_tco {
|
||||
# - if the calling function has specified a tag, tag the tweets, since
|
||||
# we're iterating through them anyway. the tag should be a hashref payload.
|
||||
# - if the tweet is an newRT, unwrap it so that the full tweet text is
|
||||
# revealed (unless -nonewrts).
|
||||
# revealed (unless -noreblogs).
|
||||
# - if this appears to be a tweet, put in a stub geo hash if one does
|
||||
# not yet exist.
|
||||
# - if coordinates are flat string 'null', turn into a real null.
|
||||
@@ -7587,16 +7587,16 @@ sub normalizejson {
|
||||
}
|
||||
|
||||
# normalize newRTs
|
||||
# if we get newRTs with -nonewrts, oh well
|
||||
# if we get newRTs with -noreblogs, oh well
|
||||
my $boost_content = '';
|
||||
my $boost_attribution = '';
|
||||
my $boost_user = undef;
|
||||
|
||||
if (!$nonewrts && ($rt = $i->{'retweeted_status'})) {
|
||||
if (!$noreblogs && ($rt = $i->{'reblog'})) {
|
||||
# reconstruct the boost in fediverse format: <author> [boosted <booster@domain>] content
|
||||
# without truncation, but detco it first
|
||||
$rt = &destroy_all_tco($rt);
|
||||
$i->{'retweeted_status'} = $rt;
|
||||
$i->{'reblog'} = $rt;
|
||||
|
||||
# Get original author and content
|
||||
my $original_author = $rt->{'user'}->{'screen_name'} || 'unknown_user';
|
||||
@@ -7844,8 +7844,7 @@ sub map_single_status {
|
||||
$status->{'text'} = &html_to_text($status->{'content'});
|
||||
}
|
||||
$status->{'user'} = $status->{'account'} if exists($status->{'account'});
|
||||
$status->{'retweeted_status'} = $status->{'reblog'} if exists($status->{'reblog'});
|
||||
$status->{'retweet_count'} = $status->{'reblogs_count'} if exists($status->{'reblogs_count'});
|
||||
# reblog and reblogs_count fields are already in correct format for ActivityPub
|
||||
$status->{'favorite_count'} = $status->{'favourites_count'} if exists($status->{'favourites_count'});
|
||||
$status->{'in_reply_to_status_id_str'} = $status->{'in_reply_to_id'} if exists($status->{'in_reply_to_id'});
|
||||
|
||||
@@ -7859,9 +7858,9 @@ sub map_single_status {
|
||||
}
|
||||
|
||||
# Recursively map reblogged status - with depth limit to prevent infinite recursion
|
||||
if (exists($status->{'retweeted_status'})) {
|
||||
if (exists($status->{'reblog'})) {
|
||||
print $stdout "-- DEBUG: Processing reblogged status recursively (depth: $recursion_depth)\n" if ($verbose);
|
||||
$status->{'retweeted_status'} = &map_single_status($status->{'retweeted_status'}, $recursion_depth + 1);
|
||||
$status->{'reblog'} = &map_single_status($status->{'reblog'}, $recursion_depth + 1);
|
||||
}
|
||||
|
||||
return $status;
|
||||
|
||||
Reference in New Issue
Block a user