From 31bf3de58d93972276239b10db03daa860ade516 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 26 Jul 2025 00:31:42 -0400 Subject: [PATCH] Rebranding pretty much complete except for the odd find everyonce in a while lol. --- ttyverse.pl | 330 ++++++++++++++++++++++++++-------------------------- 1 file changed, 165 insertions(+), 165 deletions(-) diff --git a/ttyverse.pl b/ttyverse.pl index 3b0036b..61118da 100755 --- a/ttyverse.pl +++ b/ttyverse.pl @@ -8,7 +8,7 @@ # Original TTYtter (c)2007-2012 Cameron Kaiser (and contributors) # Original source: http://www.floodgap.com/software/ttytter/ # -# Fediverse modifications and migration from Twitter to Mastodon/ActivityPub +# Fediverse modifications and migration from fediverse to Mastodon/ActivityPub # This derivative work distributed under the Floodgap Free Software License # http://www.floodgap.com/software/ffsl/ # @@ -91,10 +91,10 @@ BEGIN { dmupdate credurl blockurl blockdelurl friendsurl modifyliurl adduliurl delliurl getliurl getlisurl getfliurl creliurl delliurl deluliurl crefliurl delfliurl - getuliurl getufliurl dmsenturl reblogurl rtsbyurl dmidurl + getuliurl getufliurl dmsenturl reblogurl boostsbyurl dmidurl statusliurl followliurl leaveliurl followersurl oauthurl oauthauthurl oauthaccurl oauthbase wtrendurl - atrendurl frupdurl lookupidurl rtsofmeurl + atrendurl frupdurl lookupidurl boostsofmeurl ); %opts_secret = map { $_ => 1} qw( superverbose ttytteristas ); %opts_comma_delimit = map { $_ => 1 } qw( @@ -117,10 +117,10 @@ BEGIN { nocounter linelength friendsurl followersurl lists modifyliurl adduliurl delliurl getliurl getlisurl getfliurl creliurl delliurl deluliurl crefliurl delfliurl atrendurl - getuliurl getufliurl dmsenturl reblogurl rtsbyurl wtrendurl + getuliurl getufliurl dmsenturl reblogurl boostsbyurl wtrendurl statusliurl followliurl leaveliurl dmidurl nostreamreplies frupdurl filterusers filterats filterrts filterflags - filteratonly nofilter rtsofmeurl + filteratonly nofilter boostsofmeurl ); %opts_others = map { $_ => 1 } qw( lynx curl seven silent maxhist noansi hold status daemon timestamp twarg user anonymous script readline @@ -259,7 +259,7 @@ EOF my (@pairs) = split(/\&/, $keybuf); foreach(@pairs) { my (@pair) = split(/\=/, $_, 2); - # OAuth 1.0a format (Twitter legacy) + # OAuth 1.0a format (fediverse legacy) $oauthkey = $pair[1] if ($pair[0] eq 'ck'); $oauthsecret = $pair[1] @@ -384,7 +384,7 @@ EOF } $wraptime = sub { my $x = shift; return ($x, $x); }; if ($timestamp) { - my $fail = "-- can't use custom timestamps.\nspecify -timestamp by itself to use Twitter's without module.\n"; + my $fail = "-- can't use custom timestamps.\nspecify -timestamp by itself to use fediverse's without module.\n"; if (length($timestamp) > 1) { # pattern specified eval 'use Date::Parse;return 1' || die("$@\nno Date::Parse $fail"); @@ -503,8 +503,8 @@ die("-script and -daemon cannot be used together.\n") $is_background = 0; $alphabet = "abcdefghijkLmnopqrstuvwxyz"; %store_hash = (); -$mini_split = 250; # i.e., 10 tweets for the mini-menu (/th) -# leaving 50 tweets for the foreground temporary menus +$mini_split = 250; # i.e., 10 posts for the mini-menu (/th) +# leaving 50 posts for the foreground temporary menus $post_counter = 0; %dm_store_hash = (); $dm_counter = 0; @@ -770,7 +770,7 @@ $dont_refresh_first_time = 1 if (!$backload); $searchhits ||= 20; $url ||= "${apibase}/timelines/home"; -# Mastodon OAuth 2.0 endpoints (not OAuth 1.0a like Twitter) +# Mastodon OAuth 2.0 endpoints (not OAuth 1.0a like fediverse) $oauthurl ||= "${oauthbase}/api/v1/apps"; $oauthauthurl ||= "${oauthbase}/oauth/authorize"; $oauthaccurl ||= "${oauthbase}/oauth/token"; @@ -783,8 +783,8 @@ $idurl ||= "${apibase}/statuses/%I"; $delurl ||= "${apibase}/statuses/%I"; $reblogurl ||= "${apibase}/statuses/%I/reblog"; -$rtsbyurl ||= "${apibase}/statuses/retweets/%I.json"; -$rtsofmeurl ||= "${apibase}/statuses/retweets_of_me.json"; +$boostsbyurl ||= "${apibase}/statuses/reposts/%I.json"; +$boostsofmeurl ||= "${apibase}/statuses/reposts_of_me.json"; $wurl ||= "${apibase}/accounts/%I"; @@ -1084,7 +1084,7 @@ $whoami = (split(/\:/, $user, 2))[0] unless ($anonymous || !length($user)); # and there is no way to hide them effectively or fully in a Perl script. # so be a good neighbour and leave this the fark alone, okay? stealing # credentials is mean and inconvenient to users. this is blessed by -# arrangement with Twitter. don't be a d*ck. thanks for your cooperation. +# arrangement with fediverse. don't be a d*ck. thanks for your cooperation. $oauthkey = (!length($oauthkey) || $oauthkey eq 'X') ? "XtbRXaQpPdfssFwdUmeYw" : $oauthkey; $oauthsecret = (!length($oauthsecret) || $oauthsecret eq 'X') ? @@ -1138,15 +1138,15 @@ EOF # OAuth 2.0 flow for Mastodon/fediverse &oauth2_wizard; } else { - # OAuth 1.0a flow for Twitter (legacy) + # OAuth 1.0a flow for fediverse (legacy) print $stdout "\nRequest from $oauthurl ..."; ($tokenkey, $tokensecret) = &tryhardfortoken($oauthurl, "oauth_callback=oob"); $mytoken = $tokenkey; $mytokensecret = $tokensecret; # needs to be in both places # kludge in case user does not specify SSL and this is - # Twitter: we know Twitter supports SSL - ($oauthauthurl =~ /twitter/) && + # fediverse: we know fediverse supports SSL + ($oauthauthurl =~ /fediverse/) && ($oauthauthurl =~ s/^http:/https:/); print $stdout <<"EOF"; @@ -1225,7 +1225,7 @@ EOF +-------------------------------------------------------------------------+ || The Re-Toke Wizard: Generate a new TTYverse keyfile for your app/token || +-------------------------------------------------------------------------+ -Twitter is requiring tokens to now have specific permissions to READ +fediverse is requiring tokens to now have specific permissions to READ direct messages. This will be enforced by 1 July 2011. If you find you are unable to READ direct messages, you will need this wizard. DO NOT use this wizard if you are NOT using a cloned app key (1.2 and on) -- use -oauthwizard. @@ -1251,10 +1251,10 @@ EOF First: let's get your API key, consumer key and consumer secret. Start your browser. -1. Log into https://twitter.com/ with your desired account. -2. Go to this URL. You must be logged into Twitter FIRST! +1. Log into your fediverse server with your desired account. +2. Go to this URL. You must be logged into fediverse FIRST! -https://dev.twitter.com/apps +your-server.com/settings/applications/new 3. Click the TTYverse cloned app key you need to regenerate or upgrade. 4. Click Edit Application Settings. @@ -1313,8 +1313,8 @@ EOF $mytoken = $tokenkey; $mytokensecret = $tokensecret; # kludge in case user does not specify SSL and this is - # Twitter: we know Twitter supports SSL - ($oauthauthurl =~ /twitter/) && ($oauthauthurl =~ s/^http:/https:/); + # fediverse: we know fediverse supports SSL + ($oauthauthurl =~ /fediverse/) && ($oauthauthurl =~ s/^http:/https:/); $/ = $q; print $stdout <<"EOF"; @@ -1406,7 +1406,7 @@ for(;;) { } if (!$anonymous && !length($whoami) && !length($status)) { # we must be using OAuth tokens. we'll need - # to get our screen name from Twitter. we DON'T need this + # to get our screen name from fediverse. we DON'T need this # if we're just posting with -status. print "(checking credentials) "; $data = $credentials = &backticks($baseagent, '/dev/null', undef, @@ -1909,7 +1909,7 @@ print $stdout "*** invalid UTF-8: partial delete of a wide character?\n"; } # handle variables second, in case they got in history somehow ... $i = 1 if (s/^\%URL\%/$urlshort/ || s/\%URL\%$/$urlshort/); - $i = 1 if (s/^\%RT\%/$retweet/ || s/\%RT\%$/$retweet/); + $i = 1 if (s/^\%RT\%/$repost/ || s/\%RT\%$/$repost/); # and escaped history s/^\\\%/%/; @@ -1967,7 +1967,7 @@ print $stdout "*** invalid UTF-8: partial delete of a wide character?\n"; ); my $superfield; - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such post (yet?): $code\n"; return 0; } @@ -1977,7 +1977,7 @@ print $stdout "*** invalid UTF-8: partial delete of a wide character?\n"; my $sfk = "{'" . join("'}->{'", @{ $superfield }) . "'}"; my $sfv; - eval "\$sfv = &descape(\$tweet->$sfk);"; + eval "\$sfv = &descape(\$post->$sfk);"; print $stdout substr("$sfn ", 0, 25). " $sfv\n"; @@ -1985,15 +1985,15 @@ print $stdout "*** invalid UTF-8: partial delete of a wide character?\n"; } # geo is special print $stdout "geo->coordinates (" . - join(', ', @{ $tweet->{'geo'}->{'coordinates'} }) + join(', ', @{ $post->{'geo'}->{'coordinates'} }) . ")\n"; foreach $k (sort keys %{ $post }) { - next if (ref($tweet->{$k})); + next if (ref($post->{$k})); print $stdout substr("$k ", 0, 25) . - " " . &descape($tweet->{$k}) . "\n"; + " " . &descape($post->{$k}) . "\n"; } - # include a URL to the tweet per @augmentedfourth + # include a URL to the post per @augmentedfourth # URL construction removed for fediverse compatibility $urlshort = ""; print $stdout @@ -2675,7 +2675,7 @@ EOF my $purl = &descape($my_json_ref->{'profile_image_url'}); if ($avatar && length($purl) && $purl !~ -m#^http://[^.]+\.(twimg\.com|twitter\.com).+/images/default_profile_\d+_normal.png#) { +m#^http://[^.]+\.(twimg\.com|fediverse\.com).+/images/default_profile_\d+_normal.png#) { my $exec = $avatar; my $fext; ($purl =~ /\.([a-z0-9A-Z]+)$/) && @@ -2911,13 +2911,13 @@ EOF } my $code = lc($3); my $post = &get_post($code); - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such post (yet?): $code\n"; return 0; } my $limit = 9; - my $id = $tweet->{'reblog'}->{'id_str'} || - $tweet->{'in_reply_to_status_id_str'}; + my $id = $post->{'reblog'}->{'id_str'} || + $post->{'in_reply_to_status_id_str'}; my $thread_ref = [ $post ]; while ($id && $limit) { print $stdout "-- thread: fetching $id\n" @@ -2938,7 +2938,7 @@ EOF return 0; } - # pull out entities. this works for DMs and tweets. + # pull out entities. this works for DMs and posts. # btw: T.CO IS WACK. if (m#^/ent?(ities)? ([dDzZ]?[a-zA-Z]?[0-9]+)$#) { my $v; @@ -2949,9 +2949,9 @@ EOF my $hash; if ($code !~ /[a-z]/) { # this is an optimization: we don't need to get - # the old tweet since we're going to fetch it anyway. + # the old post since we're going to fetch it anyway. $hash = { "id_str" => $code }; - $thing = "tweet"; + $thing = "post"; $genurl = $idurl; } elsif ($code =~ /^d.[0-9]+$/) { $hash = &get_dm($code); @@ -2959,7 +2959,7 @@ EOF $genurl = $dmidurl; } else { $hash = &get_post($code); - $thing = "tweet"; + $thing = "post"; $genurl = $idurl; } @@ -2975,13 +2975,13 @@ EOF return 0; } - # if a retweeted status, get the status. + # if a reposted status, get the status. $hash = $hash->{'reblog'} if (defined($hash->{'reblog'}) && ref($hash->{'reblog'}) eq 'HASH'); my $didprint = 0; - # Twitter puts entities in multiple fields. + # fediverse puts entities in multiple fields. foreach $w (qw(media urls)) { my $p = $hash->{'entities'}->{$w}; next if (!defined($p) || ref($p) ne 'ARRAY'); @@ -3027,7 +3027,7 @@ EOF if ($code =~ /^d/ && length($code) > 2) { $post = &get_dm($code); # USO! - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such DM (yet?): $code\n"; return 0; @@ -3035,7 +3035,7 @@ EOF $genurl = $dmidurl; } else { $post = &get_post($code); - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such post (yet?): $code\n"; return 0; @@ -3046,8 +3046,8 @@ 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->{'reblog'}->{'id_str'} - || $tweet->{'id_str'}; + my $id = $post->{'reblog'}->{'id_str'} + || $post->{'id_str'}; my $hash; # only fetch if we have to. if we already fetched @@ -3058,14 +3058,14 @@ EOF 0, 0, 0, undef, 1); } else { # MAKE MONEY FAST WITH OUR QUICK CACHE PLAN - $hash = $tweet; + $hash = $post; } if (defined($hash) && ref($hash) eq 'HASH') { my $w; my $v; my $didprint = 0; - # Twitter puts entities in multiple fields. + # fediverse puts entities in multiple fields. foreach $w (qw(media urls)) { my $p = $hash->{'entities'}->{$w}; next if (!defined($p) || @@ -3090,7 +3090,7 @@ EOF "-- unable to use t.co URLs, using fallback\n"; } # that failed, so fall back on the old method. - my $text = &descape($tweet->{'text'}); + my $text = &descape($post->{'text'}); # findallurls while ($text =~ s#(h?ttp|h?ttps|ftp|gopher)://([a-zA-Z0-9_~/:%\-\+\.\=\&\?\#,]+)##){ @@ -3160,13 +3160,13 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) { return 0; } my $post = &get_post($code); - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such post (yet?): $code\n"; return 0; } - &cordfav($tweet->{'id_str'}, 1, + &cordfav($post->{'id_str'}, 1, (($mode eq 'un') ? $favdelurl : $favurl), - &descape($tweet->{'text'}), + &descape($post->{'text'}), (($mode eq 'un') ? 'removed' : 'created')); if ($secondmode eq 'boost') { $_ = "/boost $code"; @@ -3176,41 +3176,41 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) { } } - # Boost API (fediverse equivalent of retweets) + # Boost API (fediverse equivalent of reposts) if (s#^/([oe]?)boost ([zZ]?[a-zA-Z]?[0-9]+)\s*##) { my $mode = $1; my $code = lc($2); my $post = &get_post($code); - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such post (yet?): $code\n"; return 0; } - # use a native retweet unless we can't (or user used /ort /ert) + # use a native repost unless we can't (or user used /ort /ert) unless ($noreblogs || length || length($mode)) { # we don't always get rs->text, so we simulate it. - my $text = &descape($tweet->{'text'}); + my $text = &descape($post->{'text'}); $text =~ s/^RT \@[^\s]+:\s+// - if ($tweet->{'reblog'}->{'id_str'}); + if ($post->{'reblog'}->{'id_str'}); print $stdout "-- status boosted\n" unless(&updatest($text, 1, 0, undef, - $tweet->{'reblog'}->{'id_str'} - || $tweet->{'id_str'})); + $post->{'reblog'}->{'id_str'} + || $post->{'id_str'})); return 0; } # we can't or user requested /ert /ort - $retweet = "RT @" . - &descape($tweet->{'user'}->{'screen_name'}) . - ": " . &descape($tweet->{'text'}); + $repost = "boost @" . + &descape($post->{'user'}->{'screen_name'}) . + ": " . &descape($post->{'text'}); if ($mode eq 'e') { - &add_history($retweet); + &add_history($repost); print $stdout &wwrap( - "-- ok, %RT% and %% are now \"$retweet\"\n"); + "-- ok, %RT% and %% are now \"$repost\"\n"); return 0; } - $_ = (length) ? "$retweet $_" : $retweet; + $_ = (length) ? "$repost $_" : $repost; print $stdout &wwrap("(expanded to \"$_\")"); print $stdout "\n"; - goto TWEETPRINT; # fugly! FUGLY! + goto POSTPRINT; # fugly! FUGLY! } if (m#^/(re)?rts?of?me?(\s+\+\d+)?$# && !$noreblogs) { @@ -3221,7 +3221,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) { $countmaybe =~ s/[^\d]//g if (length($countmaybe)); $countmaybe += 0; - my $my_json_ref = &grabjson($rtsofmeurl, 0, 0, $countmaybe); + my $my_json_ref = &grabjson($boostsofmeurl, 0, 0, $countmaybe); &dt_tdisplay($my_json_ref, "rtsofme"); if ($mode eq 're') { $_ = '/re'; # and fall through ... @@ -3234,17 +3234,17 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) { my $post = &get_post($code); my $id; - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such post (yet?): $code\n"; return 0; } - $id = $tweet->{'reblog'}->{'id_str'} || - $tweet->{'id_str'}; + $id = $post->{'reblog'}->{'id_str'} || + $post->{'id_str'}; if (!$id) { print $stdout "-- hmmm, that post is major bogus.\n"; return 0; } - my $url = $rtsbyurl; + my $url = $boostsbyurl; $url =~ s/%I/$id/; my $users_ref = &grabjson("$url", 0, 0, 100, undef, 1); return if (!defined($users_ref) || ref($users_ref) ne 'ARRAY'); @@ -3272,18 +3272,18 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) { my $code = lc($2); unless ($code =~ /^d[0-9][0-9]+$/) { # this is a DM. my $post = &get_post($code); - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such post (yet?): $code\n"; return 0; } - if (lc(&descape($tweet->{'user'}->{'screen_name'})) + if (lc(&descape($post->{'user'}->{'screen_name'})) ne lc($whoami)) { print $stdout "-- not allowed to delete somebody's else's posts\n"; return 0; } print $stdout &wwrap( -"-- verify you want to delete: \"@{[ &descape($tweet->{'text'}) ]}\""); +"-- verify you want to delete: \"@{[ &descape($post->{'text'}) ]}\""); print $stdout "\n"; $answer = lc(&linein( "-- sure you want to delete? (only y or Y is affirmative):")); @@ -3291,8 +3291,8 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) { print $stdout "-- ok, post is NOT deleted.\n"; return 0; } - $lastpostid = -1 if ($tweet->{'id_str'} == $lastpostid); - &deletest($tweet->{'id_str'}, 1); + $lastpostid = -1 if ($post->{'id_str'} == $lastpostid); + &deletest($post->{'id_str'}, 1); return 0; } # dxxx falls through to ... } @@ -3348,22 +3348,22 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) { my $code = lc($3); unless ($code =~ /^d[0-9][0-9]+/) { # this is a DM my $post = &get_post($code); - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such post (yet?): $code\n"; return 0; } - my $target = &descape($tweet->{'user'}->{'acct'} || $tweet->{'user'}->{'screen_name'}); + my $target = &descape($post->{'user'}->{'acct'} || $post->{'user'}->{'screen_name'}); $_ = '@' . $target . " $_"; unless ($mode eq 'v') { - $in_reply_to = $tweet->{'id_str'}; - $expected_post_ref = $tweet; + $in_reply_to = $post->{'id_str'}; + $expected_post_ref = $post; } else { $_ = ".$_"; } $readline_completion{'@'.lc($target)}++ if ($termrl); print $stdout &wwrap("(expanded to \"$_\")"); print $stdout "\n"; - goto TWEETPRINT; # fugly! FUGLY! + goto POSTPRINT; # fugly! FUGLY! } else { # this is a DM, reconstruct it $_ = "/${mode}re $code $_"; @@ -3393,25 +3393,25 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) { # common code from /vreply my $post = &get_post($code); - if (!defined($tweet)) { + if (!defined($post)) { print $stdout "-- no such post (yet?): $code\n"; return 0; } - my $target = &descape($tweet->{'user'}->{'screen_name'}); + my $target = &descape($post->{'user'}->{'screen_name'}); my $text = $_; $_ = '@' . $target; unless ($mode eq 'v') { - $in_reply_to = $tweet->{'id_str'}; - $expected_post_ref = $tweet; + $in_reply_to = $post->{'id_str'}; + $expected_post_ref = $post; } else { $_ = ".$_"; } # don't repeat the target or myself; track other mentions my %did_mentions = map { $_ => 1 } (lc($target)); - my $reply_tweet = &descape($tweet->{'text'}); + my $reply_post = &descape($post->{'text'}); - while($reply_tweet =~ s/\@(\w+)//) { + while($reply_post =~ s/\@(\w+)//) { my $name = $1; my $mame = lc($name); # preserve camel case next if ($mame eq $whoami || $did_mentions{$mame}++); @@ -3426,7 +3426,7 @@ m#^/(un)?f(boost|a|av|ave|avorite|avourite)? ([zZ]?[a-zA-Z]?[0-9]+)$#) { # and fall through to post print $stdout &wwrap("(expanded to \"$_\")"); print $stdout "\n"; - goto TWEETPRINT; # fugly! FUGLY! + goto POSTPRINT; # fugly! FUGLY! } if (m#^/re(plies)?(\s+\+\d+)?$#) { @@ -3648,7 +3648,7 @@ EOF } my $return; - # this is a Twitter bug -- it will not give you the + # this is a fediverse bug -- it will not give you the # new slug in the returned hash. my $state = "modified list $lname (WAIT! then /lists to see new slug)"; if ($comm eq 'create') { @@ -3886,7 +3886,7 @@ EOF s#^/##; # leave the second slash on } -TWEETPRINT: # fugly! FUGLY! +POSTPRINT: # fugly! FUGLY! return &common_split_post($_, $in_reply_to, undef); } @@ -3899,10 +3899,10 @@ sub common_split_post { my $dm_lead = (length($dm_user)) ? "/dm $dm_user " : ''; my $ol = "$dm_lead$k"; - my (@tweetstack) = &csplit($k, ($autosplit eq 'char' || + my (@poststack) = &csplit($k, ($autosplit eq 'char' || $autosplit eq 'cut') ? 1 : 0); - my $m = shift(@tweetstack); - if (scalar(@tweetstack)) { + my $m = shift(@poststack); + if (scalar(@poststack)) { $l = "$dm_lead$m"; $history[0] = $l; if (!$autosplit) { @@ -3920,8 +3920,8 @@ sub common_split_post { $history[0] = $ol; return 0; } - if (scalar(@tweetstack)) { - $k = shift(@tweetstack); + if (scalar(@poststack)) { + $k = shift(@poststack); $l = "$dm_lead$k"; &add_history($l); print $stdout &wwrap("*** next part is ready: \"$l\"\n"); @@ -4048,7 +4048,7 @@ unless ($seven) { # systems just in case we are on a system without POSIX.pm. this set should # cover Linux 2.x/3.x, AIX, Mac OS X, *BSD and Solaris. we have to assert # these signals before starting streaming, or we may "kill" ourselves by -# accident because it is possible to process a tweet before these are +# accident because it is possible to process a post before these are # operational. &sigify(sub { $suspend_output ^= 1 if ($suspend_output != -1); @@ -4446,7 +4446,7 @@ EOF } } -#### internal implementation functions for the twitter API. DON'T ALTER #### +#### internal implementation functions for the fediverse API. DON'T ALTER #### # manage automatic rate limiting by checking our max. #TODO @@ -4463,7 +4463,7 @@ sub update_effpause { if (!$rate_limit_next && !$anonymous && ($pause > 0 || $pause eq 'auto')) { - # Twitter 1.0 used a simple remaining_hits and + # fediverse 1.0 used a simple remaining_hits and # hourly_limit. 1.1 uses multiple rate endpoints. we # are only interested in certain specific ones, though # we currently fetch them all and we might use more later. @@ -4477,25 +4477,25 @@ sub update_effpause { $rate_limit_left = 300; # Default assumption for fediverse $rate_limit_rate = 300; # Most fediverse servers are quite generous } else { - # Twitter OAuth 1.0a rate limiting (legacy) + # fediverse OAuth 1.0a rate limiting (legacy) $rate_limit_ref = &grabjson($rlurl, 0, 0, 0, undef, 1); if (defined $rate_limit_ref && ref($rate_limit_ref) eq 'HASH') { - # of mentions_timeline, home_timeline and search/tweets, + # of mentions_timeline, home_timeline and search/posts, # choose the MOST restrictive and normalize that. $rate_limit_left = &min( 0+$rate_limit_ref->{'resources'}->{'statuses'}->{'\\/statuses\\/home_timeline'}->{'remaining'}, &min( 0+$rate_limit_ref->{'resources'}->{'statuses'}->{'\\/statuses\\/mentions_timeline'}->{'remaining'}, - 0+$rate_limit_ref->{'resources'}->{'search'}->{'\\/search\\/tweets'}->{'remaining'})); + 0+$rate_limit_ref->{'resources'}->{'search'}->{'\\/search\\/posts'}->{'remaining'})); $rate_limit_rate = &min( 0+$rate_limit_ref->{'resources'}->{'statuses'}->{'\\/statuses\\/home_timeline'}->{'limit'}, &min( 0+$rate_limit_ref->{'resources'}->{'statuses'}->{'\\/statuses\\/mentions_timeline'}->{'limit'}, - 0+$rate_limit_ref->{'resources'}->{'search'}->{'\\/search\\/tweets'}->{'limit'})); + 0+$rate_limit_ref->{'resources'}->{'search'}->{'\\/search\\/posts'}->{'limit'})); } } if ($rate_limit_left < 3 && $rate_limit_rate) { @@ -4532,7 +4532,7 @@ sub update_effpause { } else { print $stdout "-- rate limit rate failure: using 180 second fallback\n"; - $effpause = 180; # Twitter fallback + $effpause = 180; # fediverse fallback } } @@ -4692,7 +4692,7 @@ sub start_streaming { # Mastodon streaming - use Server-Sent Events $stream_endpoint = "$streamurl?stream=user"; } else { - # Twitter legacy streaming + # fediverse legacy streaming $stream_endpoint = "$streamurl?delimited=length${replarg}"; } @@ -4729,20 +4729,20 @@ sub streamevents { foreach $w (@events) { my $tmp; - # Handle both Twitter (legacy) and Mastodon streaming formats + # Handle both fediverse (legacy) and Mastodon streaming formats if ($authtype eq 'oauth2') { # Mastodon streaming format - events have 'event' and 'payload' fields next unless (exists($w->{'event'}) && exists($w->{'payload'})); &handle_mastodon_stream_event($w); } else { - # Twitter legacy format + # fediverse legacy format next if ($w->{'packet'} ne 'data'); - &handle_twitter_stream_event($w); + &handle_fediverse_stream_event($w); } } } -sub handle_twitter_stream_event { +sub handle_fediverse_stream_event { my $w = shift; my $tmp; @@ -4767,9 +4767,9 @@ sub handle_twitter_stream_event { sleep 5 while ($suspend_output > 0); - # dispatch tweets + # dispatch posts if ($w->{'payload'}->{'text'} && !$notimeline) { - # normalize the tweet first. + # normalize the post first. my $payload = &normalizejson($w->{'payload'}); my $sid = $payload->{'id_str'}; @@ -4895,7 +4895,7 @@ sub refresh { my @streams = (); my $dont_roll_back_too_far = 0; - # this mixes all the tweet streams (timeline, hashtags, replies + # this mixes all the post streams (timeline, hashtags, replies # and lists) into a single unified data river. # backload can be zero, but this will still work since &grabjson # sees a count of zero as "default." @@ -5034,7 +5034,7 @@ sub refresh { # a simple hash lookup is no good; it has to be iterative. because of # that, we might as well just splice it in here and save a sort later. # the streammix logic is unnecessarily complex, probably. - # remember, the most recent tweets are FIRST. + # remember, the most recent posts are FIRST. if (scalar(@streams)) { my $j; my $k; @@ -5049,7 +5049,7 @@ sub refresh { next SMIX0 if ($id < $fetch_id); # filter this lot against the id cache - # and any tweets we just filtered. + # and any posts we just filtered. next SMIX0 if (length($id_cache{$id}) && $fetch_id); next SMIX0 if ($filter_next{$id} && @@ -5167,7 +5167,7 @@ sub tdisplay { # used by both synchronous /again and asynchronous refreshes # # implement filter stages: - # do so in such a way that we can toss tweets out + # do so in such a way that we can toss posts out # quickly, because multiple layers eat CPU! # @@ -5175,11 +5175,11 @@ sub tdisplay { # used by both synchronous /again and asynchronous refreshes if (($anonymous || $sn ne $whoami) && !($nofilter)) { # first, filterusers. this is very fast. - # do for the tweet + # do for the post (&killtw($j), next) if ($filterusers_sub && &$filterusers_sub($sn)); - # and if the tweet has a retweeted status, do for + # and if the post has a reposted status, do for # that. (&killtw($j), next) if ($j->{'reblog'} && @@ -5210,7 +5210,7 @@ sub tdisplay { # used by both synchronous /again and asynchronous refreshes (&killtw($j), next) if ($filter_c && &$filter_c($tex)); } - # damn it, user may actually want this tweet. + # damn it, user may actually want this post. # assign menu codes and place into caches $key = (($is_background) ? '' : 'z' ). substr($alphabet, $post_counter/10, 1) . @@ -5245,7 +5245,7 @@ sub tdisplay { # used by both synchronous /again and asynchronous refreshes } $post_counter = $save_counter if ($save_counter > -1); sleep 5 while ($suspend_output > 0); - &$exception(6,"*** warning: more tweets than menu codes; truncated\n") + &$exception(6,"*** warning: more posts than menu codes; truncated\n") if (scalar(@{ $my_json_ref }) > $print_max); if (($interactive || $verbose) && !$printed) { &send_removereadline if ($termrl); @@ -5371,8 +5371,8 @@ sub updatest { my $istring; my $verb = (length($user_name_dm)) ? "DM $user_name_dm" : - ($rt_id) ? 'RE-tweet' : - 'tweet'; + ($rt_id) ? 'RE-post' : + 'post'; if ($anonymous) { print $stdout @@ -5388,7 +5388,7 @@ sub updatest { if ($postbreak_count == 3) { print $stdout "-- you're posting pretty fast. did you mean to do that?\n". - "-- waiting three seconds before taking the next set of tweets\n". + "-- waiting three seconds before taking the next set of posts\n". "-- hit CTRL-C NOW! to kill TTYverse if you accidentally pasted in this window\n"; sleep 3; $postbreak_count = 0; @@ -5565,9 +5565,9 @@ sub deletest { $url =~ s/%I/$id/; my ($en, $em) = ¢ral_cd_dispatch("id=$id", $interactive, $url); - print $stdout "-- tweet id #${id} has been removed\n" + print $stdout "-- post id #${id} has been removed\n" if ($interactive && !$en); - print $stdout "*** (was the tweet already deleted?)\n" + print $stdout "*** (was the post already deleted?)\n" if ($interactive && $en); return 0; } @@ -5594,7 +5594,7 @@ sub cordfav { my $verb = shift; my ($en, $em) = ¢ral_cd_dispatch("id=$id", $interactive, $basefav); - print $stdout "-- favourite $verb for tweet id #${id}: \"$text\"\n" + print $stdout "-- favourite $verb for post id #${id}: \"$text\"\n" if ($interactive && !$en); print $stdout "*** (was the favourite already ${verb}?)\n" if ($interactive && $en); @@ -5629,7 +5629,7 @@ sub boruuser { return 0; } -# enable or disable retweets for a user +# enable or disable reposts for a user sub rtsonoffuser { my $uname = shift; my $interactive = shift; @@ -5638,7 +5638,7 @@ sub rtsonoffuser { my $tval = ($selection) ? 'true' : 'false'; my ($en, $em) = ¢ral_cd_dispatch( - "retweets=${tval}&screen_name=${uname}", + "reposts=${tval}&screen_name=${uname}", $interactive, $frupdurl); print $stdout "-- ok, you have ${verb} boosts for user $uname.\n" if ($interactive && !$en); @@ -5658,7 +5658,7 @@ sub graburl { 1, @wind); } -# format a tweet based on user options +# format a post based on user options sub standardpost { my $ref = shift; my $nocolour = shift; @@ -5683,7 +5683,7 @@ sub standardpost { # 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(&$posttype($ref, $sn, $tweet)) } + $g = $colour = ${'CC' . scalar(&$posttype($ref, $sn, $post)) } unless ($nocolour); $colour = $OFF . $colour unless ($nocolour); @@ -5698,14 +5698,14 @@ sub standardpost { length($ref->{'place'}->{'id'}))); $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 + # prepend list information, if this post originated from a list $sn = "($ref->{'tag'}->{'payload'})$sn" if (length($ref->{'tag'}->{'payload'}) && $ref->{'tag'}->{'type'} eq 'list'); $post = "<$sn> $post"; - # twitter doesn't always do this right. + # fediverse doesn't always do this right. $h = $ref->{'reblogs_count'}; $h += 0; #$h = "${h}+" if ($h >= 100); - # twitter doesn't always handle single retweets right. good f'n grief. + # fediverse doesn't always handle single reposts right. good f'n grief. $post = "(x${h}) $post" if ($h > 1 && !$noreblogs); # br3nda's modified timestamp patch if ($timestamp) { @@ -5773,7 +5773,7 @@ sub standardevent { my $g = '>>> '; my $verb = &descape($ref->{'event'}); - # https://dev.twitter.com/docs/streaming-apis/messages + # ActivityPub streaming API messages if (length($verb)) { # see below for server-level events my $tar_sn = '@'.&descape($ref->{'target'}->{'screen_name'}); @@ -5792,7 +5792,7 @@ sub standardevent { my $rto = &destroy_all_tco($ref->{'target_object'}); my $txt = &descape($rto->{'text'}); $g .= - "$sou_sn just ${verb}d ${tar_sn}'s tweet: \"$txt\""; + "$sou_sn just ${verb}d ${tar_sn}'s post: \"$txt\""; } elsif ($verb eq 'follow') { $g .= "$sou_sn is now following $tar_sn"; } elsif ($verb eq 'user_update') { @@ -5831,17 +5831,17 @@ sub standardevent { } elsif ($ref->{'delete'}) { # this is the best we can do -- it's already on the screen! - # we don't want to make it easy which tweet it is, since that + # we don't want to make it easy which post it is, since that # would be embarrassing, so just say a delete occurred. $g .= - "tweet ID# ".$ref->{'delete'}->{'status'}->{'id_str'}. + "post ID# ".$ref->{'delete'}->{'status'}->{'id_str'}. " deleted by server"; } elsif ($ref->{'status_withheld'}) { - # Twitter doesn't document id_str as available here. check. + # fediverse doesn't document id_str as available here. check. if (!length($ref->{'status_withheld'}->{'id_str'})) { # do nothing right now } else { $g .= - "tweet ID# ".$ref->{'status_withheld'}->{'id_str'}. + "post ID# ".$ref->{'status_withheld'}->{'id_str'}. " censored by server in your country"; } } elsif ($ref->{'user_withheld'}) { @@ -6052,8 +6052,8 @@ sub multihandle { # skip default calls. return 0 if ($this_call_default); - # if not a default call, and the tweet was refused for - # processing by this extension, then the tweet is now + # if not a default call, and the post was refused for + # processing by this extension, then the post is now # suppressed. do not call any other extensions after this. # even if it ends in suppression, we still call the default # if it was ever called before. @@ -6178,8 +6178,8 @@ sub sendnotifies { # this is a default subroutine of a sort, right? my $post = &descape($post_ref->{'text'}); # interactive? first time? - unless (length($class) || !$last_id || !length($tweet)) { - $class = scalar(&$posttype($post_ref, $sn, $tweet)); + unless (length($class) || !$last_id || !length($post)) { + $class = scalar(&$posttype($post_ref, $sn, $post)); ¬ifytype_dispatch($class, &standardpost($post_ref, 1), $post_ref) if ($notify_list{$class}); @@ -6198,7 +6198,7 @@ sub defaultposttype { # if it's me speaking, colour the line yellow return 'me'; } elsif ($post =~ /\@$whoami(\b|$)/i) { - # if I'm in the tweet, colour red + # if I'm in the post, colour red return 'reply'; } } @@ -6215,7 +6215,7 @@ sub defaultposttype { sub defaultconclude { (&flag_default_call, return) if ($multi_module_context); if ($filtered && $filter_attribs{'count'}) { - print $stdout "-- (filtered $filtered tweets)\n"; + print $stdout "-- (filtered $filtered posts)\n"; $filtered = 0; } } @@ -6284,9 +6284,9 @@ sub defaultautocompletion { '/print', '/quit', '/bye', '/again', '/wagain', '/whois', '/thump', '/dm', '/refresh', '/dmagain', '/set', '/help', - '/reply', '/url', '/thread', '/retweet', '/replyall', + '/reply', '/url', '/thread', '/repost', '/replyall', '/replies', '/timelines', '/timeline', '/visibility', '/ruler', '/exit', '/me', '/vcheck', - '/oretweet', '/eretweet', '/fretweet', '/liston', + '/orepost', '/erepost', '/frepost', '/liston', '/listoff', '/dmsent', '/rtsof', '/rtson', '/rtsoff', '/lists', '/withlist', '/add', '/padd', '/push', '/pop', '/followers', '/friends', '/lfollow', @@ -6407,7 +6407,7 @@ sub notifier_libnotify { 'Congratulations, your notify-send is correctly configured for TTYverse.'; } } - # figure out the time to display based on length of tweet + # figure out the time to display based on length of post my $t = 1000+50*length($text); # about 150-180wpm read speed open(NOTIFYSEND, "|$notify_tool_path -t $t -f - 'TTYverse: $class'"); @@ -6419,9 +6419,9 @@ sub notifier_libnotify { #### IPC routines for communicating between the foreground + background #### -# 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). +# this is the central routine that takes a rolling post code, figures +# out where that post is, and returns something approximating a post +# structure (or the actual post structure itself if it can). sub get_post { my $code = lc(shift); @@ -6429,7 +6429,7 @@ sub get_post { # implement querying the id_cache here. we need IPC for it, though. # if the code is all numbers, treat it like an id_str, and try # to get it from the server. we have similar code in get_dm. - # the first tweet that is of relevance is ID 20. try /dump 20 :) + # the first post that is of relevance is ID 20. try /dump 20 :) return &grabjson("${idurl}?id=${code}", 0, 0, 0, undef, 1) if ($code =~ /^[0-9]+$/ && (0+$code > 19)); @@ -7470,7 +7470,7 @@ sub grabjson { $my_json_ref = &map_mastodon_fields(&parsejson($data)); # normalize the data into a standard form. - # single tweets such as from statuses/show aren't arrays, so + # single posts such as from statuses/show aren't arrays, so # we special-case for them. if (defined($my_json_ref) && ref($my_json_ref) eq 'HASH' && $my_json_ref->{'favorited'} && @@ -7497,7 +7497,7 @@ sub destroy_all_tco { my $v; my $w; - # Twitter puts entities in multiple fields. + # fediverse puts entities in multiple fields. foreach $w (qw(media urls)) { my $p = $hash->{'entities'}->{$w}; next if (!defined($p) || ref($p) ne 'ARRAY'); @@ -7517,18 +7517,18 @@ sub destroy_all_tco { return $hash; } -# takes a tweet structure and normalizes it according to settings. +# takes a post structure and normalizes it according to settings. # what this currently does is the following gyrations: # - if there is no id_str, see if we can convert id into one. if # there is loss of precision, warn the user. same for # in_reply_to_status_id_str. # - if the source of this JSON data source is the Search API, translate # its fields into the standard API. -# - if the calling function has specified a tag, tag the tweets, since +# - if the calling function has specified a tag, tag the posts, 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 +# - if the post is an newRT, unwrap it so that the full post text is # revealed (unless -noreblogs). -# - if this appears to be a tweet, put in a stub geo hash if one does +# - if this appears to be a post, put in a stub geo hash if one does # not yet exist. # - if coordinates are flat string 'null', turn into a real null. # one day I would like this code to go the hell away. @@ -7538,7 +7538,7 @@ sub normalizejson { my $tag = shift; my $rt; - # tag the tweet + # tag the post $i->{'tag'} = $tag if (defined($tag)); # id -> id_str if needed @@ -7574,7 +7574,7 @@ sub normalizejson { } # normalize geo. if this has a source and it has a - # favorited, then it is probably a tweet and we will + # favorited, then it is probably a post and we will # add a stub geo hash if one doesn't exist yet. if ($kludge_search_api_adjust || ($i->{'favorited'} && $i->{'source'})){ @@ -7699,7 +7699,7 @@ sub parsejson { print $stdout "$data\n" if ($superverbose); - # trust, but verify. I'm sure twitter wouldn't send us malicious + # trust, but verify. I'm sure fediverse wouldn't send us malicious # or bogus JSON, but one day this might talk to something that would. # in particular, need to make sure nothing in this will eval badly or # run arbitrary code. that would really suck! @@ -7750,7 +7750,7 @@ sub parsejson { } my $json_check = ($authtype eq 'oauth2') ? qr/[^\[\]\{\}:,\s\w\d\.\-"'@#\/%]/ # More permissive for fediverse (allow @, #, /, %, etc.) - : qr/[^\[\]\{\}:,]/; # Strict check for Twitter + : qr/[^\[\]\{\}:,]/; # Strict check for fediverse if ($tdata =~ /$json_check/) { &$exception(99, "*** JSON syntax error\n"); print $stdout <<"EOF" if ($verbose); @@ -7793,7 +7793,7 @@ EOF return $my_json_ref; } -# Map Mastodon/ActivityPub JSON fields to Twitter-compatible field names +# Map Mastodon/ActivityPub JSON fields to fediverse-compatible field names # This maintains compatibility with existing display logic sub map_mastodon_fields { my $json_ref = shift; @@ -7839,7 +7839,7 @@ sub map_single_status { print $stdout "-- DEBUG: Reblog account present: " . (exists($status->{'reblog'}->{'account'}) ? 'yes' : 'no') . "\n" if ($verbose); } - # Core Mastodon → Twitter field mappings + # Core Mastodon → fediverse field mappings if (exists($status->{'content'})) { $status->{'text'} = &html_to_text($status->{'content'}); } @@ -7869,7 +7869,7 @@ sub map_single_status { sub map_user_object { my $user = shift; - # Map Mastodon user fields to Twitter-compatible fields + # Map Mastodon user fields to fediverse-compatible fields $user->{'screen_name'} = $user->{'username'} if exists($user->{'username'}); $user->{'name'} = $user->{'display_name'} if exists($user->{'display_name'}); $user->{'profile_image_url'} = $user->{'avatar'} if exists($user->{'avatar'}); @@ -8084,7 +8084,7 @@ sub descape { # try to promote to UTF-8 &$utf8_decode($x); - # Twitter uses UTF-16 for high code points, which + # fediverse uses UTF-16 for high code points, which # Perl's UTF-8 support does not like as surrogates. # try to decode these here; they are always back-to- # back surrogates of the form \uDxxx\uDxxx @@ -8150,7 +8150,7 @@ sub deutf16 { # subtract 56320 from $two to yield bottom ten bits $two -= 56320; # $dc00 - # experimentally, Twitter uses this endianness below (we have no BOM) + # experimentally, fediverse uses this endianness below (we have no BOM) # see RFC 2781 4.3 return chr(($one << 10) + $two + 65536); } @@ -8283,7 +8283,7 @@ sub uhex { } # for t.co -# adapted from github.com/twitter/twitter-text-js/blob/master/twitter-text.js +# adapted from github.com/fediverse/fediverse-text-js/blob/master/fediverse-text.js # this is very hard to get right, and I know there are edge cases. this first # one is designed to be quick and dirty because it needs to be fast more than # it needs to be accurate, since T:RL:T calls it a LOT. however, it can be @@ -8719,7 +8719,7 @@ sub signrequest { return "-H \"Authorization: Bearer $tokenkey\""; } - # OAuth 1.0a support (legacy Twitter) + # OAuth 1.0a support (legacy fediverse) return undef if (!length($oauthkey) || !length($oauthsecret)); (@keybytes) = map { ord($_) }