From 8fbec0a4dc99d059b4c4c9434e979ecf26aa8f17 Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Thu, 24 Oct 2024 07:50:26 +0200 Subject: [PATCH] =?UTF-8?q?Updated=20to=20cope=20with=20new=20=E2=80=9Cget?= =?UTF-8?q?tlds=E2=80=9D=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/clitools/getinstinfo.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/clitools/getinstinfo.php b/web/clitools/getinstinfo.php index eca85d3..5d4622a 100755 --- a/web/clitools/getinstinfo.php +++ b/web/clitools/getinstinfo.php @@ -32,7 +32,7 @@ require '../lib/ght.php'; require '../lib/fnum.php'; require '../lib/supplangs.php'; require '../lib/gettlds.php'; -require '../lib/mastodon_postlen.php'; +require '../lib/mastodon-postLength.php'; require '../lib/ckratelimit.php'; require '../lib/vendor/autoload.php'; use LanguageDetection\Language; @@ -826,7 +826,9 @@ if ($instanswered && !$opts['dryrun'] && isset($idata['blocks'])) { if ($opts['_sendtoot'] && $instanswered && $idata['IsMastodon'] && $idata['FirstSeen']==$now) { $lc=['decimal_point'=>'.', 'thousands_sep'=>',']; - gettlds(); + $tldsre=gettlds(__DIR__.'/tlds.txt',true); + if (!is_null($tldsre['warnings'])) + eecho(2,"gettlds: {$tldsre['warnings']}\n"); eecho(0,'«'.$opts['hostname'].'»: this instance is new, trying to send an announcement toot about it...'.N); $endpoint='https://'.$opts['bothost'].'/api/v1/statuses'; $toot='A new Mastodon instance, https://'.$opts['hostname'].', has been found by the crawler at https://mastodon.help'.N.N.'Name: '; @@ -858,8 +860,8 @@ if ($opts['_sendtoot'] && $instanswered && $idata['IsMastodon'] && $idata['First (is_null($idata['ShortDesc'])) ? $toot.='unspecified' : $toot.=$idata['ShortDesc']; $toot.=N.N.'Long description: '; (is_null($idata['LongDesc'])) ? $toot.='unspecified' : $toot.=html2text($idata['LongDesc']); - if (postlen($toot)>$opts['botmaxchars']) { - while (postlen($toot)+13>$opts['botmaxchars']) + if (postLength($toot,$tldsre['tlds'])>$opts['botmaxchars']) { + while (postLength($toot,$tldsre['tlds'])+13>$opts['botmaxchars']) $toot=preg_replace('#\s+(\S|\n)+$#u','',$toot); $toot.=' [continues…]'; }