Skip to content
Permalink
Browse files
Remove twitter DM length limit. Send the whole message.
  • Loading branch information
neotsn committed Jan 9, 2016
1 parent 0c3c7a7 commit 4c51efcfe61b13b5e992b2a07467a4f611143d6e
Showing with 1 addition and 27 deletions.
  1. +1 −27 includes/classes/Advisory.php
@@ -145,33 +145,7 @@ public function prepareTwitterMessage($statement, $area, $state, $cwa)
$statement = 'Spotter activation canceled.';
}

$message = trim($area . ', ' . $state . ': ' . $statement);

$arrayWords = explode(' ', $message);
$messageLength = strlen($message);

// Max size of each line
$maxLineLength = 114;
$shortMessage = '';

// Auxiliar counters, foreach will use them
$currentLength = 0;

foreach ($arrayWords as $word) {
// +1 because the word will receive back the space in the end that it loses in explode()
$wordLength = strlen($word) + 1;

if (($currentLength + $wordLength) <= $maxLineLength) {
$shortMessage .= $word . ' ';

$currentLength += $wordLength;
} else {
break;
}
}

$shortMessage = trim($shortMessage); // trim it up
$shortMessage .= ($currentLength < $messageLength) ? '...' : ''; // add the dots if needed
$shortMessage = trim($area . ', ' . $state . ': ' . $statement); // trim it up
$shortMessage .= ' ' . strtr(URL_NWS_ADVISORY, array('%o' => $cwa)); // add the URL

$this->statement_hash = md5($shortMessage);

0 comments on commit 4c51efc

Please sign in to comment.