Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mastodonの鍵トゥを片っ端から消して回るスクリプト 自己責任
use strict;
use warnings;
use utf8;
use Furl;
use JSON qw/decode_json/;
my $domain = '<YOUR MASTODON DOMAIN>';
my $access_token = '<YOUR MASTODON ACCESS TOKEN>';
my $account_id = '<YOUR MASTODON ACCOUNT ID (number)>';
my $fetch_statuses_interval = 2; # Limit: 300/5min(By default)
my $delete_status_interval = 61; # Limit: 30/30min(By default)
my $furl = Furl->new(headers => ['Authorization' => "Bearer ${access_token}"]);
my $max_id = '9223372036854775807'; #7FFFFFFFFFFFFFFF
my $fetched_statuses_count = 0;
my $deleted_statuses_count = 0;
while(1) {
sleep $fetch_statuses_interval;
my $statuses = decode_json($furl->get("https://${domain}/api/v1/accounts/${account_id}/statuses?limit=40&exclude_replies=false&max_id=${max_id}")->content);
$fetched_statuses_count += scalar(@$statuses);
print $fetched_statuses_count." statuses fetched\n";
for my $status (@$statuses) {
if($status->{visibility} eq 'private') {
sleep $delete_status_interval;
print "Deleted: $status->{id}, total: ${deleted_statuses_count}\n";
last if scalar(@$statuses) < 40;
$max_id = $statuses->[-1]{id};
print "Done\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment