danog\MadelineProto\AsyncTools
Author: Daniil Gentili daniil@daniil.it
Async tools.
Constants
danog\MadelineProto\AsyncTools::ALL_MIMES:
Method list:
rethrow(\Throwable $e): voidcallFork(\Generator|\Amp\Future|callable $callable, mixed ...$args): \Amp\Future<T>flock(string $file, integer $operation, float $polling = 0.1, ?\Amp\Cancellation $token = NULL, ?\Closure $failureCb = NULL): ($token is null ? Closure(): void : (Closure(): void | null))sleep(float $time): voidreadLine(string $prompt = '', ?\Amp\Cancellation $cancel = NULL): stringecho(string $string): voidmbStrlen(string $text): intmbSubstr(string $text, integer $offset, (null|int) $length = NULL): stringmbStrSplit(string $text, integer $length): array<string>htmlToMessageEntities(string $html): \danog\MadelineProto\TextEntitiesmarkdownToMessageEntities(string $markdown): \danog\MadelineProto\TextEntitiesentitiesToHtml(string $message, list<(\danog\MadelineProto\EventHandler\Message\Entities\MessageEntity|array{_: string, offset: int, length: int})> $entities, bool $allowTelegramTags = false): stringtoCamelCase(string $input): stringtoSnakeCase(string $input): stringhtmlEscape(string $what): stringmarkdownEscape(string $what): stringmarkdownCodeblockEscape(string $what): stringmarkdownCodeEscape(string $what): stringmarkdownUrlEscape(string $what): stringgetMimeFromExtension(string $extension, string $default): stringgetExtensionFromMime(string $mime): stringgetExtensionFromLocation(mixed $location, string $default): stringgetMimeFromFile(string $file): stringgetMimeFromBuffer(string $buffer): string
Methods:
rethrow(\Throwable $e): void
Rethrow exception into event loop.
Parameters:
$e:\Throwable
See also:
\Throwable
callFork(\Generator|\Amp\Future|callable $callable, mixed ...$args): \Amp\Future<T>
Fork a new green thread and execute the passed function in the background.
Parameters:
$callable:\Generator|\Amp\Future|callable...$args:mixedArguments forwarded to the function when forking the thread.
See also:
\Generator\Amp\Future
flock(string $file, integer $operation, float $polling = 0.1, ?\Amp\Cancellation $token = NULL, ?\Closure $failureCb = NULL): ($token is null ? Closure(): void : (Closure(): void | null))
Asynchronously lock a file Resolves with a callbable that MUST eventually be called in order to release the lock.
Parameters:
$file:stringFile to lock$operation:integerLocking mode$polling:floatPolling interval$token:?\Amp\CancellationCancellation token$failureCb:?\ClosureFailure callback, called only once if the first locking attempt fails.
See also:
\Amp\Cancellation\Closure
sleep(float $time): void
Asynchronously sleep.
Parameters:
$time:floatNumber of seconds to sleep for
readLine(string $prompt = '', ?\Amp\Cancellation $cancel = NULL): string
Asynchronously read line.
Parameters:
$prompt:stringPrompt$cancel:?\Amp\Cancellation
See also:
\Amp\Cancellation
echo(string $string): void
Asynchronously write to stdout/browser.
Parameters:
$string:stringMessage to echo
mbStrlen(string $text): int
Get Telegram UTF-8 length of string.
Parameters:
$text:stringText
mbSubstr(string $text, integer $offset, (null|int) $length = NULL): string
Telegram UTF-8 multibyte substring.
Parameters:
$text:stringText to substring$offset:integerOffset$length:(null|int)Length
mbStrSplit(string $text, integer $length): array<string>
Telegram UTF-8 multibyte split.
Parameters:
$text:stringText$length:integerLength
htmlToMessageEntities(string $html): \danog\MadelineProto\TextEntities
Manually convert HTML to a message and a set of entities.
NOTE: You don’t have to use this method to send HTML messages.
This method is already called automatically by using parse_mode: “HTML” in messages.sendMessage, messages.sendMedia, et cetera…
Parameters:
$html:string
Return value: Object containing message and entities
See also:
- https://docs.madelineproto.xyz/API_docs/methods/messages.sendMessage.html#usage-of-parse_mode
\danog\MadelineProto\TextEntities: Class that converts HTML or markdown to a message + set of entities.
markdownToMessageEntities(string $markdown): \danog\MadelineProto\TextEntities
Manually convert markdown to a message and a set of entities.
NOTE: You don’t have to use this method to send Markdown messages.
This method is already called automatically by using parse_mode: “Markdown” in messages.sendMessage, messages.sendMedia, et cetera…
Parameters:
$markdown:string
Return value: Object containing message and entities
See also:
- https://docs.madelineproto.xyz/API_docs/methods/messages.sendMessage.html#usage-of-parse_mode
\danog\MadelineProto\TextEntities: Class that converts HTML or markdown to a message + set of entities.
entitiesToHtml(string $message, list<(\danog\MadelineProto\EventHandler\Message\Entities\MessageEntity|array{_: string, offset: int, length: int})> $entities, bool $allowTelegramTags = false): string
Convert a message and a set of entities to HTML.
Parameters:
$message:string$entities:list<(\danog\MadelineProto\EventHandler\Message\Entities\MessageEntity|array{_: string, offset: int, length: int})>$allowTelegramTags:boolWhether to allow telegram-specific tags like tg-spoiler, tg-emoji, mention links and so on…
See also:
\danog\MadelineProto\EventHandler\Message\Entities\MessageEntity: Master class for message entities.
toCamelCase(string $input): string
Convert to camelCase.
Parameters:
$input:stringString
toSnakeCase(string $input): string
Convert to snake_case.
Parameters:
$input:stringString
htmlEscape(string $what): string
Escape string for MadelineProto’s HTML entity converter.
Parameters:
$what:stringString to escape
markdownEscape(string $what): string
Escape string for markdown.
Parameters:
$what:stringString to escape
markdownCodeblockEscape(string $what): string
Escape string for markdown codeblock.
Parameters:
$what:stringString to escape
markdownCodeEscape(string $what): string
Escape string for markdown code section.
Parameters:
$what:stringString to escape
markdownUrlEscape(string $what): string
Escape string for URL.
Parameters:
$what:stringString to escape
getMimeFromExtension(string $extension, string $default): string
Get mime type from file extension.
Parameters:
$extension:stringFile extension$default:stringDefault mime type
getExtensionFromMime(string $mime): string
Get extension from mime type.
Parameters:
$mime:stringMIME type
getExtensionFromLocation(mixed $location, string $default): string
Get extension from file location.
Parameters:
$location:mixedFile location$default:stringDefault extension
getMimeFromFile(string $file): string
Get mime type of file.
Parameters:
$file:stringFile
getMimeFromBuffer(string $buffer): string
Get mime type from buffer.
Parameters:
$buffer:stringBuffer
Generated by danog/phpdoc