Start of processing packets - implemented PING Responce to Netmail
This commit is contained in:
54
app/Classes/FTN/Process/Ping.php
Normal file
54
app/Classes/FTN/Process/Ping.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\FTN\Process;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonInterface;
|
||||
|
||||
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;
|
||||
|
||||
$reply = sprintf("Your ping was received here on %s and it took %s to get here.\n",
|
||||
Carbon::now()->toDateTimeString(),
|
||||
$msg->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
|
||||
);
|
||||
|
||||
$reply .= "\n";
|
||||
$reply .= "Your message travelled along this path to get here:\n";
|
||||
foreach ($msg->via as $path)
|
||||
$reply .= sprintf(" * %s\n",$path);
|
||||
|
||||
$o = new Netmail();
|
||||
$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;
|
||||
|
||||
$o->tagline = '... My ping pong opponent was not happy with my serve. He kept returning it.';
|
||||
$o->tearline = sprintf('--- %s (%s)',Setup::PRODUCT_NAME,(new Setup)->version);
|
||||
$o->save();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user