reply( message: "This bot can be used to convert files to be played by a @MadelineProto Telegram webradio!". "\n\nSee https://docs.madelineproto.xyz/docs/CALLS.html for more info, and call @magicalcrazypony to hear some nice tunes!". "\n\nSend me an audio file to start.". "\n\nPowered by @MadelineProto, [source code](https://github.com/danog/MadelineProto/blob/v8/examples/libtgvoipbot.php).", parseMode: ParseMode::MARKDOWN ); } #[Handler] public function convertCmd((Incoming&Message&HasAudio)|(Incoming&Message&HasDocument) $message): void { $reply = $message->reply("Conversion in progress..."); async(function () use ($message, $reply): void { $pipe = self::getStreamPipe(); $sink = $pipe->getSink(); async( Ogg::convert(...), $message->media->getStream(), $sink )->finally($sink->close(...)); $this->sendDocument( peer: $message->chatId, file: $pipe->getSource(), fileName: $message->media->fileName.".ogg", replyToMsgId: $message->id ); })->finally($reply->delete(...)); } } if (!getenv('TOKEN')) { throw new AssertionError("You must define a TOKEN environment variable with the token of the bot!"); } LibtgvoipEventHandler::startAndLoopBot($argv[1] ?? 'libtgvoipbot.madeline', getenv('TOKEN'));