Support vx multi-pic refresh
This commit is contained in:
@@ -56,11 +56,22 @@ class CallbackqueryCommand extends SystemCommand
|
||||
$attemptLimit = 3;
|
||||
$query = '?tmfx';
|
||||
|
||||
$parts = explode($query, $callbackQuery->getMessage()->getText());
|
||||
$currentAttempt = isset($parts[1]) ? intval($parts[1])+1 : 1;
|
||||
preg_match('/status\/\d+(?:\/photo\/(\d))?(?:\?tmfx(\d))?/', $callbackQuery->getMessage()->getText(), $matches);
|
||||
$currentAttempt = empty($matches[2]) ? 1 : intval($matches[2])+1;
|
||||
$photoNo = $matches[1] ?? null;
|
||||
// The proper way to refresh to a URL is to talk to @WebpageBot
|
||||
// A workaround is to just add a query string
|
||||
$newUrl = $parts[0] . $query . $currentAttempt;
|
||||
// But VXTwitter check for /photo/1, /photo/2, ... by looking at URI (including query string) ending with /1, /2
|
||||
// To maintain compatibility with both fx/vx, we will use https://vxtwitter.com/aaa/status/1234567890/photo/3?tmfx1/3
|
||||
$newUrl = explode($query, $callbackQuery->getMessage()->getText())[0];
|
||||
$newUrl = explode('/photo/', $newUrl)[0];
|
||||
if ($photoNo) {
|
||||
$newUrl .= '/photo/' . $photoNo;
|
||||
}
|
||||
$newUrl .= $query . $currentAttempt;
|
||||
if ($photoNo) {
|
||||
$newUrl .= '/' . $photoNo;
|
||||
}
|
||||
|
||||
$keyboard = $callbackQuery->getMessage()->getReplyMarkup();
|
||||
if ($currentAttempt >= $attemptLimit) {
|
||||
|
||||
Reference in New Issue
Block a user