2021-07-15 14:54:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\FTN\Process;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Carbon\CarbonInterface;
|
2021-07-18 12:10:21 +00:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2021-07-15 14:54:23 +00:00
|
|
|
|
|
|
|
use App\Classes\FTN\{Message,Process};
|
|
|
|
use App\Models\{Netmail,Setup};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process messages to Ping
|
|
|
|
*
|
|
|
|
* @package App\Classes\FTN\Process
|
|
|
|
*/
|
|
|
|
final class Ping extends Process
|
|
|
|
{
|
|
|
|
protected static array $logo = [
|
|
|
|
'ÚÄ¿þÚÄ¿ÚÄ¿',
|
|
|
|
'³ ³Â³ ³Àij',
|
|
|
|
'ÃÄÙÁÁ ÁÄÄÙ'
|
|
|
|
];
|
|
|
|
|
|
|
|
public static function handle(Message $msg): bool
|
|
|
|
{
|
|
|
|
if (strtolower($msg->user_to) !== 'ping')
|
|
|
|
return FALSE;
|
|
|
|
|
2021-07-18 12:10:21 +00:00
|
|
|
Log::info(sprintf('Processing PING message from (%s) [%s]',$msg->user_from,$msg->fftn));
|
|
|
|
|
2021-07-17 05:48:07 +00:00
|
|
|
$reply = sprintf("Your ping was received here on %s and it took %s to get here.\r",
|
2021-07-15 14:54:23 +00:00
|
|
|
Carbon::now()->toDateTimeString(),
|
|
|
|
$msg->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
|
|
|
|
);
|
|
|
|
|
2021-07-17 05:48:07 +00:00
|
|
|
$reply .= "\r";
|
|
|
|
$reply .= "\r";
|
|
|
|
$reply .= "Your message travelled along this path on the way here:\r";
|
2021-07-15 14:54:23 +00:00
|
|
|
foreach ($msg->via as $path)
|
2021-07-17 05:48:07 +00:00
|
|
|
$reply .= sprintf(" * %s\r",$path);
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2021-07-17 05:48:07 +00:00
|
|
|
$o = new Netmail;
|
2021-07-15 14:54:23 +00:00
|
|
|
$o->to = $msg->user_from;
|
|
|
|
$o->from = Setup::PRODUCT_NAME;
|
|
|
|
$o->subject = 'Ping Reply';
|
|
|
|
$o->fftn_id = ($x=$msg->tftn_o) ? $x->id : NULL;
|
|
|
|
$o->tftn_id = ($x=$msg->fftn_o) ? $x->id : NULL;
|
|
|
|
$o->msg = static::format_msg($reply);
|
|
|
|
$o->reply = $msg->msgid;
|
|
|
|
|
2021-07-18 12:10:21 +00:00
|
|
|
$o->tagline = 'My ping pong opponent was not happy with my serve. He kept returning it.';
|
2021-07-15 14:54:23 +00:00
|
|
|
$o->tearline = sprintf('--- %s (%s)',Setup::PRODUCT_NAME,(new Setup)->version);
|
|
|
|
$o->save();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|