forked from danog/MadelineProto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInternalDoc.php
2350 lines (2346 loc) · 110 KB
/
InternalDoc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php declare(strict_types=1);
/**
* This file is automatically generated by the build_docs.php file
* and is used only for autocompletion in multiple IDEs
* don't modify it manually.
*/
namespace danog\MadelineProto;
use __PHP_Incomplete_Class;
use Amp\ByteStream\Pipe;
use Amp\ByteStream\ReadableStream;
use Amp\ByteStream\WritableStream;
use Amp\Cancellation;
use Amp\Future;
use Amp\Http\Server\Request as ServerRequest;
use Closure;
use danog\MadelineProto\Broadcast\Action;
use danog\MadelineProto\Broadcast\Progress;
use danog\MadelineProto\Broadcast\Status;
use danog\MadelineProto\EventHandler\Action\Cancel;
use danog\MadelineProto\EventHandler\Attributes\Handler;
use danog\MadelineProto\EventHandler\Keyboard;
use danog\MadelineProto\EventHandler\Media;
use danog\MadelineProto\EventHandler\Media\Audio;
use danog\MadelineProto\EventHandler\Media\Document;
use danog\MadelineProto\EventHandler\Media\Gif;
use danog\MadelineProto\EventHandler\Media\Photo;
use danog\MadelineProto\EventHandler\Media\Sticker;
use danog\MadelineProto\EventHandler\Media\Video;
use danog\MadelineProto\EventHandler\Media\Voice;
use danog\MadelineProto\EventHandler\Message;
use danog\MadelineProto\EventHandler\Message\Entities\Code;
use danog\MadelineProto\EventHandler\Message\Entities\Email;
use danog\MadelineProto\EventHandler\Message\Entities\Mention;
use danog\MadelineProto\EventHandler\Message\Entities\MessageEntity;
use danog\MadelineProto\EventHandler\Message\Entities\Phone;
use danog\MadelineProto\EventHandler\Message\Entities\Pre;
use danog\MadelineProto\EventHandler\Message\Entities\Spoiler;
use danog\MadelineProto\EventHandler\Message\Entities\Url;
use danog\MadelineProto\EventHandler\Participant\Admin;
use danog\MadelineProto\EventHandler\Participant\Member;
use danog\MadelineProto\EventHandler\Pinned;
use danog\MadelineProto\EventHandler\Update;
use danog\MadelineProto\EventHandler\User\Status\Emoji;
use danog\MadelineProto\EventHandler\User\Username;
use danog\MadelineProto\Ipc\Client;
use danog\MadelineProto\Ipc\EventHandlerProxy;
use danog\MadelineProto\Ipc\Server;
/** @psalm-suppress PossiblyNullReference, PropertyNotSetInConstructor */
abstract class InternalDoc
{
protected APIWrapper $wrapper;
/** @var \danog\MadelineProto\Namespace\Auth $auth */
public $auth;
/** @var \danog\MadelineProto\Namespace\Account $account */
public $account;
/** @var \danog\MadelineProto\Namespace\Users $users */
public $users;
/** @var \danog\MadelineProto\Namespace\Contacts $contacts */
public $contacts;
/** @var \danog\MadelineProto\Namespace\Messages $messages */
public $messages;
/** @var \danog\MadelineProto\Namespace\Updates $updates */
public $updates;
/** @var \danog\MadelineProto\Namespace\Photos $photos */
public $photos;
/** @var \danog\MadelineProto\Namespace\Upload $upload */
public $upload;
/** @var \danog\MadelineProto\Namespace\Help $help */
public $help;
/** @var \danog\MadelineProto\Namespace\Channels $channels */
public $channels;
/** @var \danog\MadelineProto\Namespace\Bots $bots */
public $bots;
/** @var \danog\MadelineProto\Namespace\Payments $payments */
public $payments;
/** @var \danog\MadelineProto\Namespace\Stickers $stickers */
public $stickers;
/** @var \danog\MadelineProto\Namespace\Phone $phone */
public $phone;
/** @var \danog\MadelineProto\Namespace\Langpack $langpack */
public $langpack;
/** @var \danog\MadelineProto\Namespace\Folders $folders */
public $folders;
/** @var \danog\MadelineProto\Namespace\Stats $stats */
public $stats;
/** @var \danog\MadelineProto\Namespace\Chatlists $chatlists */
public $chatlists;
/** @var \danog\MadelineProto\Namespace\Stories $stories */
public $stories;
/** @var \danog\MadelineProto\Namespace\Premium $premium */
public $premium;
/** @var \danog\MadelineProto\Namespace\Smsjobs $smsjobs */
public $smsjobs;
/** @var \danog\MadelineProto\Namespace\Fragment $fragment */
public $fragment;
/**
* Export APIFactory instance with the specified namespace.
* @psalm-suppress InaccessibleProperty
*/
protected function exportNamespaces(): void
{
$this->auth ??= new \danog\MadelineProto\Namespace\AbstractAPI('auth');
$this->auth->setWrapper($this->wrapper);
$this->account ??= new \danog\MadelineProto\Namespace\AbstractAPI('account');
$this->account->setWrapper($this->wrapper);
$this->users ??= new \danog\MadelineProto\Namespace\AbstractAPI('users');
$this->users->setWrapper($this->wrapper);
$this->contacts ??= new \danog\MadelineProto\Namespace\AbstractAPI('contacts');
$this->contacts->setWrapper($this->wrapper);
$this->messages ??= new \danog\MadelineProto\Namespace\AbstractAPI('messages');
$this->messages->setWrapper($this->wrapper);
$this->updates ??= new \danog\MadelineProto\Namespace\AbstractAPI('updates');
$this->updates->setWrapper($this->wrapper);
$this->photos ??= new \danog\MadelineProto\Namespace\AbstractAPI('photos');
$this->photos->setWrapper($this->wrapper);
$this->upload ??= new \danog\MadelineProto\Namespace\AbstractAPI('upload');
$this->upload->setWrapper($this->wrapper);
$this->help ??= new \danog\MadelineProto\Namespace\AbstractAPI('help');
$this->help->setWrapper($this->wrapper);
$this->channels ??= new \danog\MadelineProto\Namespace\AbstractAPI('channels');
$this->channels->setWrapper($this->wrapper);
$this->bots ??= new \danog\MadelineProto\Namespace\AbstractAPI('bots');
$this->bots->setWrapper($this->wrapper);
$this->payments ??= new \danog\MadelineProto\Namespace\AbstractAPI('payments');
$this->payments->setWrapper($this->wrapper);
$this->stickers ??= new \danog\MadelineProto\Namespace\AbstractAPI('stickers');
$this->stickers->setWrapper($this->wrapper);
$this->phone ??= new \danog\MadelineProto\Namespace\AbstractAPI('phone');
$this->phone->setWrapper($this->wrapper);
$this->langpack ??= new \danog\MadelineProto\Namespace\AbstractAPI('langpack');
$this->langpack->setWrapper($this->wrapper);
$this->folders ??= new \danog\MadelineProto\Namespace\AbstractAPI('folders');
$this->folders->setWrapper($this->wrapper);
$this->stats ??= new \danog\MadelineProto\Namespace\AbstractAPI('stats');
$this->stats->setWrapper($this->wrapper);
$this->chatlists ??= new \danog\MadelineProto\Namespace\AbstractAPI('chatlists');
$this->chatlists->setWrapper($this->wrapper);
$this->stories ??= new \danog\MadelineProto\Namespace\AbstractAPI('stories');
$this->stories->setWrapper($this->wrapper);
$this->premium ??= new \danog\MadelineProto\Namespace\AbstractAPI('premium');
$this->premium->setWrapper($this->wrapper);
$this->smsjobs ??= new \danog\MadelineProto\Namespace\AbstractAPI('smsjobs');
$this->smsjobs->setWrapper($this->wrapper);
$this->fragment ??= new \danog\MadelineProto\Namespace\AbstractAPI('fragment');
$this->fragment->setWrapper($this->wrapper);
}
/**
* Convert MTProto parameters to bot API parameters.
*
* @param array $data Data
*/
final public function MTProtoToBotAPI(array $data): array
{
return $this->wrapper->getAPI()->MTProtoToBotAPI($data);
}
/**
* MTProto to TD params.
*
* @param mixed $params Params
*/
final public function MTProtoToTd(mixed &$params): array
{
return $this->wrapper->getAPI()->MTProtoToTd($params);
}
/**
* MTProto to TDCLI params.
*
* @param mixed $params Params
*/
final public function MTProtoToTdcli(mixed $params): array
{
return $this->wrapper->getAPI()->MTProtoToTdcli($params);
}
/**
* Accept call.
*/
final public function acceptCall(int $id, ?\Amp\Cancellation $cancellation = null): void
{
$this->wrapper->getAPI()->acceptCall($id, $cancellation);
}
/**
* Accept secret chat.
*
* @param array $params Secret chat ID
*/
final public function acceptSecretChat(array $params): void
{
$this->wrapper->getAPI()->acceptSecretChat($params);
}
/**
* Create array.
*
* @param mixed ...$params Params
*/
final public static function arr(mixed ...$params): array
{
return \danog\MadelineProto\Tools::arr(...$params);
}
/**
* base64URL decode.
*
* @param string $data Data to decode
*/
final public static function base64urlDecode(string $data): string
{
return \danog\MadelineProto\Tools::base64urlDecode($data);
}
/**
* Base64URL encode.
*
* @param string $data Data to encode
*/
final public static function base64urlEncode(string $data): string
{
return \danog\MadelineProto\Tools::base64urlEncode($data);
}
/**
* Convert bot API parameters to MTProto parameters.
*
* @param array $arguments Arguments
*/
final public function botAPIToMTProto(array $arguments): array
{
return $this->wrapper->getAPI()->botAPIToMTProto($arguments);
}
/**
* Login as bot.
*
* @param string $token Bot token
*/
final public function botLogin(string $token): ?array
{
return $this->wrapper->getAPI()->botLogin($token);
}
/**
* Executes a custom broadcast action with all peers (users, chats, channels) of the bot.
*
* Will return an integer ID that can be used to:
*
* - Get the current broadcast progress with getBroadcastProgress
* - Cancel the broadcast using cancelBroadcast
*
* Note that to avoid manually polling the progress,
* MadelineProto will also periodically emit updateBroadcastProgress updates,
* containing a Progress object for all broadcasts currently in-progress.
*
* @param Action $action A custom, serializable Action class that will be called once for every peer.
* @param float|null $delay Number of seconds to wait between each peer.
*/
final public function broadcastCustom(\danog\MadelineProto\Broadcast\Action $action, ?\danog\MadelineProto\Broadcast\Filter $filter = null, ?float $delay = null): int
{
return $this->wrapper->getAPI()->broadcastCustom($action, $filter, $delay);
}
/**
* Forwards a list of messages to all peers (users, chats, channels) of the bot.
*
* Will return an integer ID that can be used to:
*
* - Get the current broadcast progress with getBroadcastProgress
* - Cancel the broadcast using cancelBroadcast
*
* Note that to avoid manually polling the progress,
* MadelineProto will also periodically emit updateBroadcastProgress updates,
* containing a Progress object for all broadcasts currently in-progress.
*
* @param mixed $from_peer Bot API ID or Update, from where to forward the messages.
* @param list<int> $message_ids IDs of the messages to forward.
* @param bool $drop_author If true, will forward messages without quoting the original author.
* @param bool $pin Whether to also pin the last sent message.
* @param float|null $delay Number of seconds to wait between each peer.
*/
final public function broadcastForwardMessages(mixed $from_peer, array $message_ids, bool $drop_author = false, ?\danog\MadelineProto\Broadcast\Filter $filter = null, bool $pin = false, ?float $delay = null): int
{
return $this->wrapper->getAPI()->broadcastForwardMessages($from_peer, $message_ids, $drop_author, $filter, $pin, $delay);
}
/**
* Sends a list of messages to all peers (users, chats, channels) of the bot.
*
* A simplified version of this method is also available: broadcastForwardMessages can work with pre-prepared messages.
*
* Will return an integer ID that can be used to:
*
* - Get the current broadcast progress with getBroadcastProgress
* - Cancel the broadcast using cancelBroadcast
*
* Note that to avoid manually polling the progress,
* MadelineProto will also periodically emit updateBroadcastProgress updates,
* containing a Progress object for all broadcasts currently in-progress.
*
* @param array $messages The messages to send: an array of arrays, containing parameters to pass to messages.sendMessage.
* @param bool $pin Whether to also pin the last sent message.
* @param float|null $delay Number of seconds to wait between each peer.
*/
final public function broadcastMessages(array $messages, ?\danog\MadelineProto\Broadcast\Filter $filter = null, bool $pin = false, ?float $delay = null): int
{
return $this->wrapper->getAPI()->broadcastMessages($messages, $filter, $pin, $delay);
}
/**
* Fork a new green thread and execute the passed function in the background.
*
* @template T
*
* @param \Closure(...):T $callable Function to execute
* @param mixed ...$args Arguments forwarded to the function when forking the thread.
*
* @return Future<T>
*
* @psalm-suppress InvalidScope
*/
final public static function callFork(\Generator|\Amp\Future|callable $callable, ...$args): \Amp\Future
{
return \danog\MadelineProto\AsyncTools::callFork($callable, ...$args);
}
/**
* Get the file that is currently being played.
*
* Will return a string with the object ID of the stream if we're currently playing a stream, otherwise returns the related LocalFile or RemoteUrl.
*/
final public function callGetCurrent(int $id): \danog\MadelineProto\RemoteUrl|\danog\MadelineProto\LocalFile|string|null
{
return $this->wrapper->getAPI()->callGetCurrent($id);
}
/**
* Play file in call.
*/
final public function callPlay(int $id, \danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\Amp\ByteStream\ReadableStream $file): void
{
$this->wrapper->getAPI()->callPlay($id, $file);
}
/**
* Play files on hold in call.
*/
final public function callPlayOnHold(int $id, \danog\MadelineProto\LocalFile|\danog\MadelineProto\RemoteUrl|\Amp\ByteStream\ReadableStream ...$files): void
{
$this->wrapper->getAPI()->callPlayOnHold($id, ...$files);
}
/**
* Set output file or stream for incoming OPUS audio packets in a call.
*
* Will write an OGG OPUS stream to the specified file or stream.
*/
final public function callSetOutput(int $id, \danog\MadelineProto\LocalFile|\Amp\ByteStream\WritableStream $file): void
{
$this->wrapper->getAPI()->callSetOutput($id, $file);
}
/**
* Whether we can convert any audio/video file to a VoIP OGG OPUS file, or the files must be preconverted using @libtgvoipbot.
*/
final public static function canConvertOgg(): bool
{
return \danog\MadelineProto\Tools::canConvertOgg();
}
/**
* Whether we can convert any audio/video file using ffmpeg.
*/
final public static function canUseFFmpeg(?\Amp\Cancellation $cancellation = null): bool
{
return \danog\MadelineProto\Tools::canUseFFmpeg($cancellation);
}
/**
* Cancel a running broadcast.
*
* @param integer $id Broadcast ID
*
*/
final public function cancelBroadcast(int $id): void
{
$this->wrapper->getAPI()->cancelBroadcast($id);
}
/**
* Close connection with client, connected via web.
*
* @param string $message Message
*/
final public static function closeConnection(string $message): void
{
\danog\MadelineProto\Tools::closeConnection($message);
}
/**
* Complete 2FA login.
*
* @param string $password Password
*/
final public function complete2faLogin(string $password): array
{
return $this->wrapper->getAPI()->complete2faLogin($password);
}
/**
* Complet user login using login code.
*
* @param string $code Login code
*/
final public function completePhoneLogin(string $code): array
{
return $this->wrapper->getAPI()->completePhoneLogin($code);
}
/**
* Complete signup to Telegram.
*
* @param string $first_name First name
* @param string $last_name Last name
*/
final public function completeSignup(string $first_name, string $last_name = ''): array
{
return $this->wrapper->getAPI()->completeSignup($first_name, $last_name);
}
/**
* Discard call.
*
* @param int<1, 5> $rating Call rating in stars
* @param string $comment Additional comment on call quality.
*/
final public function discardCall(int $id, \danog\MadelineProto\VoIP\DiscardReason $reason = \danog\MadelineProto\VoIP\DiscardReason::HANGUP, ?int $rating = null, ?string $comment = null): void
{
$this->wrapper->getAPI()->discardCall($id, $reason, $rating, $comment);
}
/**
* Discard secret chat.
*
* @param int $chat Secret chat ID
* @param bool $deleteHistory If true, deletes the entire chat history for the other user as well.
*/
final public function discardSecretChat(int $chat, bool $deleteHistory = false): void
{
$this->wrapper->getAPI()->discardSecretChat($chat, $deleteHistory);
}
/**
* Downloads a file to the browser using the specified session file.
*/
final public static function downloadServer(string $session): void
{
\danog\MadelineProto\MTProto::downloadServer($session);
}
/**
* Download file to browser.
*
* Supports HEAD requests and content-ranges for parallel and resumed downloads.
*
* @param array|string|FileCallbackInterface|\danog\MadelineProto\EventHandler\Message $messageMedia File to download
* @param null|callable $cb Status callback (can also use FileCallback)
* @param null|int $size Size of file to download, required for bot API file IDs.
* @param null|string $mime MIME type of file to download, required for bot API file IDs.
* @param null|string $name Name of file to download, required for bot API file IDs.
*/
final public function downloadToBrowser(\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\EventHandler\Message|array|string $messageMedia, ?callable $cb = null, ?int $size = null, ?string $name = null, ?string $mime = null, ?\Amp\Cancellation $cancellation = null): void
{
$this->wrapper->getAPI()->downloadToBrowser($messageMedia, $cb, $size, $name, $mime, $cancellation);
}
/**
* Download file to callable.
* The callable must accept two parameters: string $payload, int $offset
* The callable will be called (possibly out of order, depending on the value of $seekable).
*
* @param mixed $messageMedia File to download
* @param callable|FileCallbackInterface $callable Chunk callback
* @param callable $cb Status callback
* @param bool $seekable Whether the callable can be called out of order
* @param int $offset Offset where to start downloading
* @param int $end Offset where to stop downloading (inclusive)
* @param int $part_size Size of each chunk
*/
final public function downloadToCallable(mixed $messageMedia, callable $callable, ?callable $cb = null, bool $seekable = true, int $offset = 0, int $end = -1, ?int $part_size = null, ?\Amp\Cancellation $cancellation = null): void
{
$this->wrapper->getAPI()->downloadToCallable($messageMedia, $callable, $cb, $seekable, $offset, $end, $part_size, $cancellation);
}
/**
* Download file to directory.
*
* @param mixed $messageMedia File to download
* @param string|FileCallbackInterface $dir Directory where to download the file
* @param callable $cb Callback
*
* @return non-empty-string Downloaded file name
*/
final public function downloadToDir(mixed $messageMedia, \danog\MadelineProto\FileCallbackInterface|string $dir, ?callable $cb = null, ?\Amp\Cancellation $cancellation = null): string
{
return $this->wrapper->getAPI()->downloadToDir($messageMedia, $dir, $cb, $cancellation);
}
/**
* Download file.
*
* @param mixed $messageMedia File to download
* @param string|FileCallbackInterface $file Downloaded file path
* @param callable $cb Callback
*
* @return non-empty-string Downloaded file name
*/
final public function downloadToFile(mixed $messageMedia, \danog\MadelineProto\FileCallbackInterface|string $file, ?callable $cb = null, ?\Amp\Cancellation $cancellation = null): string
{
return $this->wrapper->getAPI()->downloadToFile($messageMedia, $file, $cb, $cancellation);
}
/**
* Download file to amphp/http-server response.
*
* Supports HEAD requests and content-ranges for parallel and resumed downloads.
*
* @param array|string|FileCallbackInterface|\danog\MadelineProto\EventHandler\Message $messageMedia File to download
* @param ServerRequest $request Request
* @param callable $cb Status callback (can also use FileCallback)
* @param null|int $size Size of file to download, required for bot API file IDs.
* @param null|string $name Name of file to download, required for bot API file IDs.
* @param null|string $mime MIME type of file to download, required for bot API file IDs.
*/
final public function downloadToResponse(\danog\MadelineProto\FileCallbackInterface|\danog\MadelineProto\EventHandler\Message|array|string $messageMedia, \Amp\Http\Server\Request $request, ?callable $cb = null, ?int $size = null, ?string $mime = null, ?string $name = null, ?\Amp\Cancellation $cancellation = null): \Amp\Http\Server\Response
{
return $this->wrapper->getAPI()->downloadToResponse($messageMedia, $request, $cb, $size, $mime, $name, $cancellation);
}
/**
* Download file to an amphp stream, returning it.
*
* @param mixed $messageMedia File to download
* @param callable $cb Callback
* @param int $offset Offset where to start downloading
* @param int $end Offset where to end download
*/
final public function downloadToReturnedStream(mixed $messageMedia, ?callable $cb = null, int $offset = 0, int $end = -1, ?\Amp\Cancellation $cancellation = null): \Amp\ByteStream\ReadableStream
{
return $this->wrapper->getAPI()->downloadToReturnedStream($messageMedia, $cb, $offset, $end, $cancellation);
}
/**
* Download file to stream.
*
* @param mixed $messageMedia File to download
* @param mixed|FileCallbackInterface|resource|WritableStream $stream Stream where to download file
* @param callable $cb Callback
* @param int $offset Offset where to start downloading
* @param int $end Offset where to end download
*/
final public function downloadToStream(mixed $messageMedia, mixed $stream, ?callable $cb = null, int $offset = 0, int $end = -1, ?\Amp\Cancellation $cancellation = null): void
{
$this->wrapper->getAPI()->downloadToStream($messageMedia, $stream, $cb, $offset, $end, $cancellation);
}
/**
* Asynchronously write to stdout/browser.
*
* @param string $string Message to echo
*/
final public static function echo(string $string): void
{
\danog\MadelineProto\AsyncTools::echo($string);
}
/**
* Get final element of array.
*
* @template T
* @param array<T> $what Array
* @return T
*/
final public static function end(array $what): mixed
{
return \danog\MadelineProto\Tools::end($what);
}
/**
* Convert a message and a set of entities to HTML.
*
* @param list<MessageEntity|array{_: string, offset: int, length: int}> $entities
* @param bool $allowTelegramTags Whether to allow telegram-specific tags like tg-spoiler, tg-emoji, mention links and so on...
*/
final public static function entitiesToHtml(string $message, array $entities, bool $allowTelegramTags = false): string
{
return \danog\MadelineProto\StrTools::entitiesToHtml($message, $entities, $allowTelegramTags);
}
/**
* Export authorization.
*
* @return array{0: (int|string), 1: string}
*/
final public function exportAuthorization(): array
{
return $this->wrapper->getAPI()->exportAuthorization();
}
/**
* Extract file info from bot API message.
*
* @param array $info Bot API message object
*/
final public static function extractBotAPIFile(array $info): ?array
{
return \danog\MadelineProto\MTProto::extractBotAPIFile($info);
}
/**
* Extract a message constructor from an Updates constructor.
*/
final public function extractMessage(array $updates): array
{
return $this->wrapper->getAPI()->extractMessage($updates);
}
/**
* Extract a message ID from an Updates constructor.
*/
final public function extractMessageId(array $updates): int
{
return $this->wrapper->getAPI()->extractMessageId($updates);
}
/**
* Extract an update message constructor from an Updates constructor.
*/
final public function extractMessageUpdate(array $updates): array
{
return $this->wrapper->getAPI()->extractMessageUpdate($updates);
}
/**
* Extract Update constructors from an Updates constructor.
*
* @return array<array>
*/
final public function extractUpdates(array $updates): array
{
return $this->wrapper->getAPI()->extractUpdates($updates);
}
/**
* Get contents of remote file asynchronously.
*
* @param string $url URL
*/
final public function fileGetContents(string $url, ?\Amp\Cancellation $cancellation = null): string
{
return $this->wrapper->getAPI()->fileGetContents($url, $cancellation);
}
/**
* Asynchronously lock a file
* Resolves with a callbable that MUST eventually be called in order to release the lock.
*
* @param string $file File to lock
* @param integer $operation Locking mode
* @param float $polling Polling interval
* @param ?Cancellation $token Cancellation token
* @param ?Closure $failureCb Failure callback, called only once if the first locking attempt fails.
* @return ($token is null ? (Closure(): void) : ((Closure(): void)|null))
*/
final public static function flock(string $file, int $operation, float $polling = 0.1, ?\Amp\Cancellation $token = null, ?\Closure $failureCb = null): ?\Closure
{
return \danog\MadelineProto\AsyncTools::flock($file, $operation, $polling, $token, $failureCb);
}
/**
* When was full info for this chat last cached.
*
* @param mixed $id Chat ID
*/
final public function fullChatLastUpdated(mixed $id): int
{
return $this->wrapper->getAPI()->fullChatLastUpdated($id);
}
/**
* Get info about the logged-in user, not cached.
*/
final public function fullGetSelf(): array|false
{
return $this->wrapper->getAPI()->fullGetSelf();
}
/**
* Generate MTProto vector hash.
*
* Returns a vector hash.
*
* @param array<string|int> $longs IDs
*/
final public static function genVectorHash(array $longs): string
{
return \danog\MadelineProto\Tools::genVectorHash($longs);
}
/**
* Get admin IDs (equal to all user report peers).
*/
final public function getAdminIds(): array
{
return $this->wrapper->getAPI()->getAdminIds();
}
/**
* Get all pending and running calls, indexed by user ID.
*
* @return array<int, VoIP>
*/
final public function getAllCalls(): array
{
return $this->wrapper->getAPI()->getAllCalls();
}
/**
* Get full list of MTProto and API methods.
*/
final public function getAllMethods(): array
{
return $this->wrapper->getAPI()->getAllMethods();
}
/**
* Get authorization info.
*
* @return \danog\MadelineProto\API::NOT_LOGGED_IN|\danog\MadelineProto\API::WAITING_CODE|\danog\MadelineProto\API::WAITING_SIGNUP|\danog\MadelineProto\API::WAITING_PASSWORD|\danog\MadelineProto\API::LOGGED_IN|API::LOGGED_OUT
*/
final public function getAuthorization(): int
{
return $this->wrapper->getAPI()->getAuthorization();
}
/**
* Get the progress of a currently running broadcast.
*
* Will return null if the broadcast doesn't exist, has already completed or was cancelled.
*
* Use updateBroadcastProgress updates to get real-time progress status without polling.
*
* @param integer $id Broadcast ID
*/
final public function getBroadcastProgress(int $id): ?\danog\MadelineProto\Broadcast\Progress
{
return $this->wrapper->getAPI()->getBroadcastProgress($id);
}
/**
* Get cached server-side config.
*/
final public function getCachedConfig(): array
{
return $this->wrapper->getAPI()->getCachedConfig();
}
/**
* Get phone call information.
*/
final public function getCall(int $id): ?\danog\MadelineProto\VoIP
{
return $this->wrapper->getAPI()->getCall($id);
}
/**
* Get the phone call with the specified user ID.
*/
final public function getCallByPeer(int $userId): ?\danog\MadelineProto\VoIP
{
return $this->wrapper->getAPI()->getCallByPeer($userId);
}
/**
* Get call state.
*/
final public function getCallState(int $id): ?\danog\MadelineProto\VoIP\CallState
{
return $this->wrapper->getAPI()->getCallState($id);
}
/**
* Store RSA keys for CDN datacenters.
*/
final public function getCdnConfig(): void
{
$this->wrapper->getAPI()->getCdnConfig();
}
/**
* Get cached (or eventually re-fetch) server-side config.
*
* @param array $config Current config
*/
final public function getConfig(array $config = [
]): array
{
return $this->wrapper->getAPI()->getConfig($config);
}
/**
* Get async DNS client.
*/
final public function getDNSClient(): \Amp\Dns\DnsResolver
{
return $this->wrapper->getAPI()->getDNSClient();
}
/**
* Get diffie-hellman configuration.
*/
final public function getDhConfig(?\Amp\Cancellation $cancellation = null): array
{
return $this->wrapper->getAPI()->getDhConfig($cancellation);
}
/**
* Get dialog IDs.
*
* @return list<int>
*/
final public function getDialogIds(): array
{
return $this->wrapper->getAPI()->getDialogIds();
}
/**
* Get download info of file
* Returns an array with the following structure:.
*
* `$info['ext']` - The file extension
* `$info['name']` - The file name, without the extension
* `$info['mime']` - The file mime type
* `$info['size']` - The file size
*
* @param mixed $messageMedia File ID
*
* @return array{
* ext: string,
* name: string,
* mime: string,
* size: int,
* InputFileLocation: array,
* key_fingerprint?: string,
* key?: string,
* iv?: string,
* thumb_size?: string
* }
*/
final public function getDownloadInfo(mixed $messageMedia): array
{
return $this->wrapper->getAPI()->getDownloadInfo($messageMedia);
}
/**
* Get download link of media file.
*/
final public function getDownloadLink(\danog\MadelineProto\EventHandler\Message|\danog\MadelineProto\EventHandler\Media|array|string $media, ?string $scriptUrl = null, ?int $size = null, ?string $name = null, ?string $mime = null): string
{
return $this->wrapper->getAPI()->getDownloadLink($media, $scriptUrl, $size, $name, $mime);
}
/**
* Get event handler (or plugin instance).
*
* @template T as EventHandler
*
* @param class-string<T>|null $class
*
* @return T|EventHandlerProxy|__PHP_Incomplete_Class|null
*/
final public function getEventHandler(?string $class = null): \danog\MadelineProto\EventHandler|\danog\MadelineProto\Ipc\EventHandlerProxy|\__PHP_Incomplete_Class|null
{
return $this->wrapper->getAPI()->getEventHandler($class);
}
/**
* Get extension from file location.
*
* @param mixed $location File location
* @param string $default Default extension
*/
final public static function getExtensionFromLocation(mixed $location, string $default): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getExtensionFromLocation($location, $default);
}
/**
* Get extension from mime type.
*
* @param string $mime MIME type
*/
final public static function getExtensionFromMime(string $mime): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getExtensionFromMime($mime);
}
/**
* Get info about file.
*
* @param mixed $constructor File ID
*/
final public function getFileInfo(mixed $constructor): array
{
return $this->wrapper->getAPI()->getFileInfo($constructor);
}
/**
* Get full info of all dialogs.
*
* Bots should use getDialogIds, instead.
*
* @return array<int, array>
*/
final public function getFullDialogs(): array
{
return $this->wrapper->getAPI()->getFullDialogs();
}
/**
* Get full info about peer, returns an FullInfo object.
*
* @param mixed $id Peer
* @see https://docs.madelineproto.xyz/FullInfo.html
*/
final public function getFullInfo(mixed $id): array
{
return $this->wrapper->getAPI()->getFullInfo($id);
}
/**
* Get async HTTP client.
*/
final public function getHTTPClient(): \Amp\Http\Client\HttpClient
{
return $this->wrapper->getAPI()->getHTTPClient();
}
/**
* Get current password hint.
*/
final public function getHint(): string
{
return $this->wrapper->getAPI()->getHint();
}
/**
* Get the bot API ID of a peer.
*
* @param mixed $id Peer
*/
final public function getId(mixed $id): int
{
return $this->wrapper->getAPI()->getId($id);
}
/**
* Get info about peer, returns an Info object.
*
* If passed a secret chat ID, returns information about the user, not about the secret chat.
* Use getSecretChat to return information about the secret chat.
*
* @param mixed $id Peer
* @param \danog\MadelineProto\API::INFO_TYPE_* $type Whether to generate an Input*, an InputPeer or the full set of constructors
* @see https://docs.madelineproto.xyz/Info.html
* @return ($type is \danog\MadelineProto\API::INFO_TYPE_ALL ? array{
* User?: array,
* Chat?: array,
* bot_api_id: int,
* user_id?: int,
* chat_id?: int,
* channel_id?: int,
* type: string
* } : ($type is API::INFO_TYPE_TYPE ? string : ($type is \danog\MadelineProto\API::INFO_TYPE_ID ? int : array{_: string, user_id?: int, access_hash?: int, min?: bool, chat_id?: int, channel_id?: int}|array{_: string, user_id?: int, access_hash?: int, min?: bool}|array{_: string, channel_id: int, access_hash: int, min: bool})))
*/
final public function getInfo(mixed $id, int $type = \danog\MadelineProto\API::INFO_TYPE_ALL): array|string|int
{
return $this->wrapper->getAPI()->getInfo($id, $type);
}
/**
* Get logger.
*/
final public function getLogger(): \danog\MadelineProto\Logger
{
return $this->wrapper->getAPI()->getLogger();
}
/**
* Get current number of memory-mapped regions, UNIX only.
*/
final public static function getMaps(): ?int
{
return \danog\MadelineProto\Tools::getMaps();
}
/**
* Get maximum number of memory-mapped regions, UNIX only.
* Use testFibers to get the maximum number of fibers on any platform.
*/
final public static function getMaxMaps(): ?int
{
return \danog\MadelineProto\Tools::getMaxMaps();
}
/**
* Get memory profile with memprof.
*/
final public function getMemoryProfile(): string
{
return $this->wrapper->getAPI()->getMemoryProfile();
}
/**
* Get TL namespaces.
*/
final public function getMethodNamespaces(): array
{
return $this->wrapper->getAPI()->getMethodNamespaces();
}
/**
* Get namespaced methods (method => namespace).
*/
final public function getMethodsNamespaced(): array
{
return $this->wrapper->getAPI()->getMethodsNamespaced();
}
/**
* Get mime type from buffer.
*
* @param string $buffer Buffer
*/
final public static function getMimeFromBuffer(string $buffer): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getMimeFromBuffer($buffer);
}
/**
* Get mime type from file extension.
*
* @param string $extension File extension
* @param string $default Default mime type
*/
final public static function getMimeFromExtension(string $extension, string $default): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getMimeFromExtension($extension, $default);
}
/**
* Get mime type of file.
*
* @param string $file File
*/
final public static function getMimeFromFile(string $file): string
{
return \danog\MadelineProto\TL\Conversion\Extension::getMimeFromFile($file);
}
/**
* Obtain a certain event handler plugin instance.
*
* @template T as EventHandler
*
* @param class-string<T> $class
*
* return T|null
*/