mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-22 02:23:41 +00:00
[twitter] Add custom handling for mentions
This commit is contained in:
parent
fd3eb35c33
commit
2f91ce87b7
1 changed files with 23 additions and 0 deletions
|
@ -553,6 +553,9 @@ function twitter_post_hook(App $a, array &$b)
|
|||
$connection->setTimeouts(10, 30);
|
||||
|
||||
$max_char = 280;
|
||||
|
||||
$b['body'] = twitter_update_mentions($b['body']);
|
||||
|
||||
$msgarr = ItemContent::getPlaintextPost($b, $max_char, true, 8);
|
||||
$msg = $msgarr["text"];
|
||||
|
||||
|
@ -1859,3 +1862,23 @@ function twitter_is_retweet(App $a, $uid, $body)
|
|||
|
||||
return !isset($result->errors);
|
||||
}
|
||||
|
||||
function twitter_update_mentions($body)
|
||||
{
|
||||
$URLSearchString = "^\[\]";
|
||||
$return = preg_replace_callback(
|
||||
"/@\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
|
||||
function ($matches) {
|
||||
if (strpos($matches[1], 'twitter.com')) {
|
||||
$return = '@' . substr($matches[1], strrpos($matches[1], '/') + 1);
|
||||
} else {
|
||||
$return = $matches[2] . ' (' . $matches[1] . ')';
|
||||
}
|
||||
|
||||
return $return;
|
||||
},
|
||||
$body
|
||||
);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue