From 23efee674a0b83c82530f01f7c07da9d28bd8c15 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 17 Mar 2022 19:17:31 -0700 Subject: [PATCH] Plugin/UrlTitles: update user-agents --- lib/PBot/Plugin/UrlTitles.pm | 13 ++++++++++--- lib/PBot/VERSION.pm | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/PBot/Plugin/UrlTitles.pm b/lib/PBot/Plugin/UrlTitles.pm index 56dbaf58..85905270 100644 --- a/lib/PBot/Plugin/UrlTitles.pm +++ b/lib/PBot/Plugin/UrlTitles.pm @@ -18,8 +18,7 @@ use JSON::XS; use constant { TIMEOUT => 30, - USER_AGENT => 'Mozilla/5.0 (compatible)', - MAX_SIZE => 1024 * 200, + MAX_SIZE => 1024 * 800, }; sub initialize { @@ -148,7 +147,15 @@ sub get_title { my $ua = LWP::UserAgent::Paranoid->new(request_timeout => TIMEOUT); - $ua->agent(USER_AGENT); + my $user_agent; + + if ($url =~ /twitter.com/) { + $user_agent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +https://www.google.com/bot.html)', + } else { + $user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0'; + } + + $ua->agent($user_agent); $ua->max_size(MAX_SIZE); my $response = $ua->get($url); diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 9d05e5b0..38b1ea7b 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4514, + BUILD_REVISION => 4515, BUILD_DATE => "2022-03-17", };