mirror of
https://github.com/danog/magnaluna.git
synced 2024-11-30 04:19:16 +01:00
Validate songs
This commit is contained in:
parent
f042b56771
commit
266aaf96b3
20
magna.php
20
magna.php
@ -29,6 +29,7 @@ use danog\MadelineProto\EventHandler\SimpleFilter\Incoming;
|
|||||||
use danog\MadelineProto\EventHandler\SimpleFilter\IsReply;
|
use danog\MadelineProto\EventHandler\SimpleFilter\IsReply;
|
||||||
use danog\MadelineProto\Exception;
|
use danog\MadelineProto\Exception;
|
||||||
use danog\MadelineProto\LocalFile;
|
use danog\MadelineProto\LocalFile;
|
||||||
|
use danog\MadelineProto\Ogg;
|
||||||
use danog\MadelineProto\RPCErrorException;
|
use danog\MadelineProto\RPCErrorException;
|
||||||
use danog\MadelineProto\SimpleEventHandler;
|
use danog\MadelineProto\SimpleEventHandler;
|
||||||
use danog\MadelineProto\Tools;
|
use danog\MadelineProto\Tools;
|
||||||
@ -164,10 +165,24 @@ class MyEventHandler extends SimpleEventHandler
|
|||||||
private $my_users;
|
private $my_users;
|
||||||
private $me;
|
private $me;
|
||||||
public $calls = [];
|
public $calls = [];
|
||||||
|
private array $songs = [];
|
||||||
public function onStart(): void
|
public function onStart(): void
|
||||||
{
|
{
|
||||||
$this->me = '@' . ((($this->getSelf())['username']) ?? 'magnaluna');
|
$this->me = '@' . ((($this->getSelf())['username']) ?? 'magnaluna');
|
||||||
|
|
||||||
|
$songs = glob('*ogg');
|
||||||
|
if (!$songs) {
|
||||||
|
throw new \AssertionError('No songs defined! Convert some songs by sending them to https://t.me/libtgvoipbot and putting them in the current directory');
|
||||||
|
}
|
||||||
|
foreach ($songs as $song) {
|
||||||
|
try {
|
||||||
|
Ogg::validateOgg(new LocalFile($song));
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
throw new AssertionError("An error occurred during validation of $song, please convert the file using convert.php or @libtgvoipbot!", 0, $e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->songs = $songs;
|
||||||
|
|
||||||
$this->programmed_call = [];
|
$this->programmed_call = [];
|
||||||
foreach ($this->programmed_call as $key => [$user, $time]) {
|
foreach ($this->programmed_call as $key => [$user, $time]) {
|
||||||
continue;
|
continue;
|
||||||
@ -217,10 +232,7 @@ class MyEventHandler extends SimpleEventHandler
|
|||||||
}
|
}
|
||||||
public function configureCall(VoIP $call): void
|
public function configureCall(VoIP $call): void
|
||||||
{
|
{
|
||||||
$songs = glob('*ogg');
|
$songs = $this->songs;
|
||||||
if (!$songs) {
|
|
||||||
throw new \AssertionError('No songs defined! Convert some songs by sending them to https://t.me/libtgvoipbot and putting them in the current directory');
|
|
||||||
}
|
|
||||||
$songs_length = count($songs);
|
$songs_length = count($songs);
|
||||||
|
|
||||||
for ($x = 0; $x < $songs_length; $x++) {
|
for ($x = 0; $x < $songs_length; $x++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user