├── .ver ├── LICENSE ├── README.md ├── assets ├── dashboard.php └── styles.css ├── bootstrap.php ├── bot.php ├── composer.json ├── config ├── .keep └── cli-config.php ├── languages ├── en.json └── it.json ├── logo.png └── src ├── Addons ├── AddonHandler.php ├── AddonInterface.php ├── AntifloodAddon.php └── DefaultAddon.php ├── DBEntity ├── BasicData.php ├── Chat.php └── User.php ├── Event ├── CallbackQueryEvent.php ├── ChannelPostCaptionEvent.php ├── ChannelPostTextEvent.php ├── DefaultEvent.php ├── EditedChannelPostCaptionEvent.php ├── EditedChannelPostTextEvent.php ├── EditedMessageCaptionEvent.php ├── EditedMessageTextEvent.php ├── EventHandler.php ├── EventInterface.php ├── InlineQueryEvent.php ├── MessageCaptionEvent.php ├── MessageTextEvent.php └── Trigger.php ├── Exception ├── EventException.php ├── LocalizationProviderException.php ├── SettingsProviderException.php ├── TelegramBotException.php └── UtilException.php ├── ExceptionHandler.php ├── Localization ├── Dictionary.php └── LocalizationProvider.php ├── Logger.php ├── Settings ├── Handlers │ └── AdminHandler.php ├── Sections │ ├── AntifloodSection.php │ ├── GeneralSection.php │ ├── MaintenanceSection.php │ ├── SectionInterface.php │ └── TelegramSection.php └── Settings.php ├── SettingsProvider.php ├── Telegram ├── Methods │ ├── AddStickerToSet.php │ ├── AnswerCallbackQuery.php │ ├── AnswerInlineQuery.php │ ├── AnswerPreCheckoutQuery.php │ ├── AnswerShippingQuery.php │ ├── CreateNewStickerSet.php │ ├── DeleteChatPhoto.php │ ├── DeleteChatStickerSet.php │ ├── DeleteMessage.php │ ├── DeleteStickerFromSet.php │ ├── DeleteWebhook.php │ ├── EditMessageCaption.php │ ├── EditMessageLiveLocation.php │ ├── EditMessageMedia.php │ ├── EditMessageReplyMarkup.php │ ├── EditMessageText.php │ ├── ExportChatInviteLink.php │ ├── ForwardMessage.php │ ├── GetChat.php │ ├── GetChatAdministrators.php │ ├── GetChatMember.php │ ├── GetChatMembersCount.php │ ├── GetFile.php │ ├── GetGameHighScores.php │ ├── GetMe.php │ ├── GetStickerSet.php │ ├── GetUpdates.php │ ├── GetUserProfilePhotos.php │ ├── GetWebhookInfo.php │ ├── KickChatMember.php │ ├── LeaveChat.php │ ├── MethodInterface.php │ ├── PinChatMessage.php │ ├── PromoteChatMember.php │ ├── RestrictChatMember.php │ ├── SendAnimation.php │ ├── SendAudio.php │ ├── SendChatAction.php │ ├── SendContact.php │ ├── SendDocument.php │ ├── SendGame.php │ ├── SendInvoice.php │ ├── SendLocation.php │ ├── SendMediaGroup.php │ ├── SendMessage.php │ ├── SendPhoto.php │ ├── SendSticker.php │ ├── SendVenue.php │ ├── SendVideo.php │ ├── SendVideoNote.php │ ├── SendVoice.php │ ├── SetChatDescription.php │ ├── SetChatPhoto.php │ ├── SetChatStickerSet.php │ ├── SetChatTitle.php │ ├── SetGameScore.php │ ├── SetPassportDataErrors.php │ ├── SetStickerPositionInSet.php │ ├── SetWebhook.php │ ├── StopMessageLiveLocation.php │ ├── UnbanChatMember.php │ ├── UnpinChatMessage.php │ └── UploadStickerFile.php └── Types │ ├── Animation.php │ ├── Audio.php │ ├── CallbackGame.php │ ├── CallbackQuery.php │ ├── Chat.php │ ├── ChatMember.php │ ├── ChatPhoto.php │ ├── ChosenInlineResult.php │ ├── Contact.php │ ├── Document.php │ ├── EncryptedCredentials.php │ ├── EncryptedPassportElement.php │ ├── File.php │ ├── ForceReply.php │ ├── Game.php │ ├── GameHighScore.php │ ├── InlineKeyboardButton.php │ ├── InlineKeyboardMarkup.php │ ├── InlineQuery.php │ ├── InlineQueryResult.php │ ├── InlineQueryResultArticle.php │ ├── InlineQueryResultAudio.php │ ├── InlineQueryResultCachedAudio.php │ ├── InlineQueryResultCachedDocument.php │ ├── InlineQueryResultCachedGif.php │ ├── InlineQueryResultCachedMpeg4Gif.php │ ├── InlineQueryResultCachedPhoto.php │ ├── InlineQueryResultCachedSticker.php │ ├── InlineQueryResultCachedVideo.php │ ├── InlineQueryResultCachedVoice.php │ ├── InlineQueryResultContact.php │ ├── InlineQueryResultDocument.php │ ├── InlineQueryResultGame.php │ ├── InlineQueryResultGif.php │ ├── InlineQueryResultInterface.php │ ├── InlineQueryResultLocation.php │ ├── InlineQueryResultMpeg4Gif.php │ ├── InlineQueryResultPhoto.php │ ├── InlineQueryResultVenue.php │ ├── InlineQueryResultVideo.php │ ├── InlineQueryResultVoice.php │ ├── InputContactMessageContent.php │ ├── InputFile.php │ ├── InputLocationMessageContent.php │ ├── InputMedia.php │ ├── InputMediaAnimation.php │ ├── InputMediaAudio.php │ ├── InputMediaDocument.php │ ├── InputMediaInterface.php │ ├── InputMediaPhoto.php │ ├── InputMediaVideo.php │ ├── InputMessageContent.php │ ├── InputMessageContentInterface.php │ ├── InputTextMessageContent.php │ ├── InputVenueMessageContent.php │ ├── Invoice.php │ ├── KeyboardButton.php │ ├── LabeledPrice.php │ ├── Location.php │ ├── MaskPosition.php │ ├── Message.php │ ├── MessageEntity.php │ ├── OrderInfo.php │ ├── PassportData.php │ ├── PassportElementError.php │ ├── PassportElementErrorDataField.php │ ├── PassportElementErrorFile.php │ ├── PassportElementErrorFiles.php │ ├── PassportElementErrorFrontSide.php │ ├── PassportElementErrorInterface.php │ ├── PassportElementErrorReverseSide.php │ ├── PassportElementErrorSelfie.php │ ├── PassportElementErrorTranslationFile.php │ ├── PassportElementErrorTranslationFiles.php │ ├── PassportElementErrorUnspecified.php │ ├── PassportFile.php │ ├── PhotoSize.php │ ├── PreCheckoutQuery.php │ ├── ReplyKeyboardMarkup.php │ ├── ReplyKeyboardRemove.php │ ├── ReplyMarkupInterface.php │ ├── Response.php │ ├── ResponseParameters.php │ ├── ShippingAddress.php │ ├── ShippingOption.php │ ├── ShippingQuery.php │ ├── Sticker.php │ ├── StickerSet.php │ ├── SuccessfulPayment.php │ ├── Update.php │ ├── User.php │ ├── UserProfilePhotos.php │ ├── Venue.php │ ├── Video.php │ ├── VideoNote.php │ ├── Voice.php │ └── WebhookInfo.php ├── TelegramBot.php └── Util ├── HashUtil.php └── KeyboardUtil.php /.ver: -------------------------------------------------------------------------------- 1 | 1.0.5 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sysbot 2 | 3 |

4 | 5 |

6 | 7 | I'm still working on this project, but a huge refactoring is required before the release. Until then, the built-in IP validator won't work. 8 | 9 | *You're still looking for a working version of Sysbot? Try the new [ultra-light version](https://github.com/sys-001/Sysbot/tree/minimal).* 10 | -------------------------------------------------------------------------------- /bootstrap.php: -------------------------------------------------------------------------------- 1 | 'pdo_mysql', 11 | 'dbname' => 'Sysbot', 12 | 'user' => 'user', 13 | 'password' => 'password', 14 | 'host' => 'localhost' 15 | ]; 16 | 17 | /* //use this if you don't want to install MySQL (please, install it) 18 | $conn = [ 19 | 'driver' => 'pdo_sqlite', 20 | 'path' => __DIR__ . '/db.sqlite' 21 | ]; 22 | */ 23 | 24 | /* //use this if you plan to use Redis as caching system (improves speed) 25 | $redis = new Redis(); 26 | $redis->connect('localhost'); 27 | $redis->auth('foobared'); 28 | $cache_driver = new Doctrine\Common\Cache\RedisCache(); 29 | $cache_driver->setRedis($redis); 30 | $config->setQueryCacheImpl($cache_driver); 31 | $config->setResultCacheImpl($cache_driver); 32 | $config->setMetadataCacheImpl($cache_driver); 33 | */ 34 | 35 | $entity_manager = EntityManager::create($conn, $config); 36 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sys-001/sysbot", 3 | "description": "A simple Telegram Bot Framework, written in PHP.", 4 | "type": "project", 5 | "require": { 6 | "doctrine/orm": "^2.6.2", 7 | "ext-json": "*", 8 | "guzzlehttp/guzzle": "~6.0", 9 | "php": "^7.2", 10 | "ext-shmop": "*" 11 | }, 12 | "suggest": { 13 | "ext-redis": "Required if you plan to use Doctrine Caching." 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "TelegramBot\\": "src/" 18 | } 19 | }, 20 | "authors": [ 21 | { 22 | "name": "sys-001", 23 | "email": "honfu7891@etlgr.com" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /config/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sys-001/Sysbot/ed4aca413c3f0f17a22f11100c5293ea3225d945/config/.keep -------------------------------------------------------------------------------- /config/cli-config.php: -------------------------------------------------------------------------------- 1 | addons[] = new AntifloodAddon(); 25 | } 26 | } 27 | 28 | /** 29 | * @return array 30 | */ 31 | public function getAddons(): array 32 | { 33 | return $this->addons; 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /src/Addons/AddonInterface.php: -------------------------------------------------------------------------------- 1 | callback; 29 | } 30 | 31 | /** 32 | * @return array 33 | */ 34 | public function getUpdatePaths(): array 35 | { 36 | return $this->update_paths; 37 | } 38 | } -------------------------------------------------------------------------------- /src/DBEntity/BasicData.php: -------------------------------------------------------------------------------- 1 | id; 24 | } 25 | 26 | /** 27 | * @return string 28 | */ 29 | public function getName() 30 | { 31 | return $this->name; 32 | } 33 | 34 | /** 35 | * @param string $name 36 | */ 37 | public function setName($name) 38 | { 39 | $this->name = $name; 40 | } 41 | 42 | /** 43 | * @return array 44 | */ 45 | public function getValue() 46 | { 47 | return $this->value; 48 | } 49 | 50 | /** 51 | * @param array $value 52 | */ 53 | public function setValue($value) 54 | { 55 | $this->value = $value; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/DBEntity/Chat.php: -------------------------------------------------------------------------------- 1 | admins; 24 | } 25 | 26 | /** 27 | * @param array $admins 28 | */ 29 | public function setAdmins($admins) 30 | { 31 | $this->admins = $admins; 32 | } 33 | 34 | /** 35 | * @return double 36 | */ 37 | public function getId() 38 | { 39 | return $this->id; 40 | } 41 | 42 | /** 43 | * @param double $id 44 | */ 45 | public function setId($id) 46 | { 47 | $this->id = $id; 48 | } 49 | 50 | /** 51 | * @return string 52 | */ 53 | public function getType() 54 | { 55 | return $this->type; 56 | } 57 | 58 | /** 59 | * @param string $type 60 | */ 61 | public function setType($type) 62 | { 63 | $this->type = $type; 64 | } 65 | 66 | 67 | } -------------------------------------------------------------------------------- /src/DBEntity/User.php: -------------------------------------------------------------------------------- 1 | id; 24 | } 25 | 26 | /** 27 | * @param int $id 28 | */ 29 | public function setId($id) 30 | { 31 | $this->id = $id; 32 | } 33 | 34 | /** 35 | * @return bool 36 | */ 37 | public function getBlocked() 38 | { 39 | return $this->blocked; 40 | } 41 | 42 | /** 43 | * @param bool $blocked 44 | */ 45 | public function setBlocked($blocked) 46 | { 47 | $this->blocked = $blocked; 48 | } 49 | 50 | /** 51 | * @return string 52 | */ 53 | public function getLanguageCode() 54 | { 55 | return $this->language_code; 56 | } 57 | 58 | /** 59 | * @param string $language_code 60 | */ 61 | public function setLanguageCode($language_code) 62 | { 63 | $this->language_code = $language_code; 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /src/Event/CallbackQueryEvent.php: -------------------------------------------------------------------------------- 1 | uuid = uniqid(); 48 | $this->trigger = $trigger; 49 | $this->callback = $callback; 50 | $this->admins_only = $admins_only; 51 | } 52 | 53 | /** 54 | * @return \Closure 55 | */ 56 | public function getCallback(): \Closure 57 | { 58 | return $this->callback; 59 | } 60 | 61 | /** 62 | * @return Trigger 63 | */ 64 | public function getTrigger(): Trigger 65 | { 66 | return $this->trigger; 67 | } 68 | 69 | /** 70 | * @return string 71 | */ 72 | public function getUuid(): string 73 | { 74 | return $this->uuid; 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /src/Event/EditedChannelPostCaptionEvent.php: -------------------------------------------------------------------------------- 1 | regex = $regex; 41 | } 42 | 43 | /** 44 | * @param string $regex 45 | * @return Trigger 46 | * @throws EventException 47 | */ 48 | public static function createByRegex(string $regex): self 49 | { 50 | return (new self('')) 51 | ->setRegex($regex); 52 | } 53 | 54 | /** 55 | * @return string 56 | */ 57 | public function getRegex(): string 58 | { 59 | return $this->regex; 60 | } 61 | 62 | /** 63 | * @param string $regex 64 | * @return Trigger 65 | * @throws EventException 66 | */ 67 | public function setRegex(string $regex): self 68 | { 69 | if (false === @preg_match($regex, null)) { 70 | throw new EventException('Invalid regex provided'); 71 | } 72 | $this->regex = $regex; 73 | return $this; 74 | } 75 | } -------------------------------------------------------------------------------- /src/Exception/EventException.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 24 | set_error_handler([$this, 'errorToException'], E_ERROR | E_PARSE); 25 | if ($logger->getVerbosity() == 1) { 26 | set_error_handler([$this, 'warningLogger'], E_WARNING | E_NOTICE); 27 | } 28 | set_exception_handler([$this, 'realHandler']); 29 | } 30 | 31 | /** 32 | * @param $severity 33 | * @param $message 34 | * @param $file 35 | * @param $line 36 | */ 37 | function warningLogger($severity, $message, $file, $line): void 38 | { 39 | if (!(error_reporting() & $severity)) { 40 | return; 41 | } 42 | $log_message = sprintf("WarningHandler: '%s' in '%s' (line %d)", 43 | $message, $file ?? '', $line ?? ''); 44 | $this->logger->log($log_message); 45 | return; 46 | } 47 | 48 | /** 49 | * @param $severity 50 | * @param $message 51 | * @param $file 52 | * @param $line 53 | * @throws \ErrorException 54 | */ 55 | function errorToException($severity, $message, $file, $line): void 56 | { 57 | if (!(error_reporting() & $severity)) { 58 | return; 59 | } 60 | throw new \ErrorException($message, 0, $severity, $file, $line); 61 | } 62 | 63 | /** 64 | * @param \Throwable $throwable 65 | * @return bool 66 | */ 67 | function realHandler(\Throwable $throwable): bool 68 | { 69 | $type = get_class($throwable); 70 | $trace = $throwable->getTrace(); 71 | $trace_call = ''; 72 | if (!empty($trace[0]['class'])) { 73 | $trace_call = $trace[0]['class'] . '->'; 74 | } 75 | $trace_call .= $trace[0]['function']; 76 | $trace_params = json_encode($trace[0]['args'] ?? [], JSON_UNESCAPED_SLASHES); 77 | $log_message = sprintf("ExceptionHandler: '%s' with message '%s' occurred in '%s' (line %d) @ %s (args: '%s')", 78 | $type, $throwable->getMessage(), $trace[0]['file'] ?? '', $trace[0]['line'] ?? '', $trace_call, 79 | $trace_params); 80 | $this->logger->log($log_message); 81 | return true; 82 | } 83 | } -------------------------------------------------------------------------------- /src/Localization/Dictionary.php: -------------------------------------------------------------------------------- 1 | fields = $fields; 34 | } 35 | 36 | /** 37 | * @return \stdClass|null 38 | */ 39 | public function getFields(): ?\stdClass 40 | { 41 | return $this->fields; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /src/Logger.php: -------------------------------------------------------------------------------- 1 | verbosity_levels)) { 44 | $verbosity = 0; 45 | } 46 | $this->force_log_output = $force_log_output; 47 | $this->verbosity = $verbosity; 48 | $start = sprintf("[%s] Logger: Logger started.%s", date("d/m/y - H:i:s e"), PHP_EOL); 49 | if (empty($file_path) and php_sapi_name() === "cli") { 50 | $this->is_cli = true; 51 | echo $start; 52 | printf("[%s] Logger: Logger mode set to 'echo'.%s", date("d/m/y - H:i:s e"), PHP_EOL); 53 | } else { 54 | if (empty($file_path)) { 55 | $file_path = "Sysbot.log"; 56 | } 57 | $log_file = fopen($file_path, "w"); 58 | if (false === $log_file) { 59 | throw new \Exception("Could not create log file"); 60 | } 61 | fwrite($log_file, $start); 62 | $start = sprintf("[%s] Logger: Logger mode set to 'file'.%s", date("d/m/y - H:i:s e"), PHP_EOL); 63 | fwrite($log_file, $start); 64 | fflush($log_file); 65 | $this->log_file = $log_file; 66 | } 67 | } 68 | 69 | /** 70 | * @param string $message 71 | */ 72 | function log(string $message): void 73 | { 74 | $message = sprintf("[%s] %s%s", date("d/m/y - H:i:s e"), $message, PHP_EOL); 75 | if ($this->is_cli or $this->force_log_output) { 76 | echo $message; 77 | return; 78 | } 79 | fwrite($this->log_file, $message); 80 | fflush($this->log_file); 81 | return; 82 | } 83 | 84 | /** 85 | * @return int 86 | */ 87 | public function getVerbosity(): int 88 | { 89 | return $this->verbosity; 90 | } 91 | } -------------------------------------------------------------------------------- /src/Settings/Handlers/AdminHandler.php: -------------------------------------------------------------------------------- 1 | admins = $admins; 24 | } 25 | 26 | /** 27 | * @return array 28 | */ 29 | public function getAdmins(): array 30 | { 31 | return $this->admins; 32 | } 33 | 34 | /** 35 | * @param int $admin 36 | * @return array 37 | */ 38 | public function addAdmin(int $admin): array 39 | { 40 | if (!in_array($admin, $this->admins)) { 41 | $this->admins[] = $admin; 42 | } 43 | return $this->admins; 44 | } 45 | 46 | /** 47 | * @param array $admins 48 | * @return array 49 | */ 50 | public function addAdmins(array $admins): array 51 | { 52 | array_map([$this, 'addAdmin'], $admins); 53 | return $this->admins; 54 | } 55 | 56 | /** 57 | * @param int $admin 58 | * @return array 59 | */ 60 | public function remAdmin(int $admin): array 61 | { 62 | $this->admins = array_diff($this->admins, [$admin]); 63 | return $this->admins; 64 | } 65 | 66 | /** 67 | * @param array $admins 68 | * @return array 69 | */ 70 | public function remAdmins(array $admins): array 71 | { 72 | array_map([$this, 'remAdmin'], $admins); 73 | return $this->admins; 74 | } 75 | 76 | /** 77 | * @return AdminHandler 78 | */ 79 | public function resetAdmins(): self 80 | { 81 | $this->admins = []; 82 | return $this; 83 | } 84 | 85 | /** 86 | * @param int $admin 87 | * @return bool 88 | */ 89 | public function isAdmin(int $admin): bool 90 | { 91 | return in_array($admin, $this->admins); 92 | } 93 | } -------------------------------------------------------------------------------- /src/Settings/Sections/GeneralSection.php: -------------------------------------------------------------------------------- 1 | admin_handler = $admin_handler; 45 | $this->check_ip = $check_ip; 46 | $this->default_locale = $default_locale; 47 | $this->default_locale_path = $default_locale_path; 48 | } 49 | 50 | /** 51 | * @return string 52 | */ 53 | public function getDefaultLocale(): string 54 | { 55 | return $this->default_locale; 56 | } 57 | 58 | /** 59 | * @return string 60 | */ 61 | public function getDefaultLocalePath(): string 62 | { 63 | return $this->default_locale_path; 64 | } 65 | 66 | /** 67 | * @return bool 68 | */ 69 | public function getCheckIp(): bool 70 | { 71 | return $this->check_ip; 72 | } 73 | 74 | /** 75 | * @param bool $check_ip 76 | * @return GeneralSection 77 | */ 78 | public function setCheckIp(bool $check_ip): GeneralSection 79 | { 80 | $this->check_ip = $check_ip; 81 | return $this; 82 | } 83 | 84 | /** 85 | * @return AdminHandler 86 | */ 87 | public function getAdminHandler(): AdminHandler 88 | { 89 | return $this->admin_handler; 90 | } 91 | 92 | /** 93 | * @param AdminHandler $admin_handler 94 | * @return GeneralSection 95 | */ 96 | public function setAdmins(AdminHandler $admin_handler): self 97 | { 98 | $this->admin_handler = $admin_handler; 99 | return $this; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/Settings/Sections/MaintenanceSection.php: -------------------------------------------------------------------------------- 1 | enabled = $enabled; 28 | $this->message = $message; 29 | } 30 | 31 | /** 32 | * @return bool 33 | */ 34 | public function isEnabled(): bool 35 | { 36 | return $this->enabled; 37 | } 38 | 39 | /** 40 | * @param bool $enabled 41 | * @return MaintenanceSection 42 | */ 43 | public function setEnabled(bool $enabled): self 44 | { 45 | $this->enabled = $enabled; 46 | return $this; 47 | } 48 | 49 | /** 50 | * @return string 51 | */ 52 | public function getMessage(): string 53 | { 54 | return $this->message; 55 | } 56 | 57 | /** 58 | * @param string $message 59 | * @return MaintenanceSection 60 | */ 61 | public function setMessage(string $message): self 62 | { 63 | $this->message = $message; 64 | return $this; 65 | } 66 | 67 | 68 | } -------------------------------------------------------------------------------- /src/Settings/Sections/SectionInterface.php: -------------------------------------------------------------------------------- 1 | parse_mode = $parse_mode; 40 | $this->send_actions = $send_actions; 41 | $this->use_test_api = $use_test_api; 42 | } 43 | 44 | /** 45 | * @return string 46 | */ 47 | public function getParseMode(): string 48 | { 49 | return $this->parse_mode; 50 | } 51 | 52 | /** 53 | * @param string $parse_mode 54 | * @return TelegramSection 55 | */ 56 | public function setParseMode(string $parse_mode): TelegramSection 57 | { 58 | $this->parse_mode = $parse_mode; 59 | return $this; 60 | } 61 | 62 | /** 63 | * @return bool 64 | */ 65 | public function getSendActions(): bool 66 | { 67 | return $this->send_actions; 68 | } 69 | 70 | /** 71 | * @param bool $send_actions 72 | * @return TelegramSection 73 | */ 74 | public function setSendActions(bool $send_actions): TelegramSection 75 | { 76 | $this->send_actions = $send_actions; 77 | return $this; 78 | } 79 | 80 | /** 81 | * @return bool 82 | */ 83 | public function getUseTestApi(): bool 84 | { 85 | return $this->use_test_api; 86 | } 87 | 88 | /** 89 | * @param bool $use_test_api 90 | * @return TelegramSection 91 | */ 92 | public function setUseTestApi(bool $use_test_api): TelegramSection 93 | { 94 | $this->use_test_api = $use_test_api; 95 | return $this; 96 | } 97 | 98 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/AnswerCallbackQuery.php: -------------------------------------------------------------------------------- 1 | callback_query_id = $callback_query_id; 68 | $this->text = $text; 69 | $this->show_alert = $show_alert; 70 | $this->url = $url; 71 | $this->cache_time = $cache_time; 72 | } 73 | 74 | /** 75 | * @return array 76 | */ 77 | public function getParams(): array 78 | { 79 | return [ 80 | 'callback_query_id' => $this->callback_query_id, 81 | 'text' => $this->text, 82 | 'show_alert' => $this->show_alert, 83 | 'url' => $this->url, 84 | 'cache_time' => $this->cache_time 85 | ]; 86 | } 87 | 88 | /** 89 | * @return string 90 | */ 91 | public function getMethodName(): string 92 | { 93 | return self::METHOD_NAME; 94 | } 95 | 96 | /** 97 | * @return bool 98 | */ 99 | public function isMultipart(): bool 100 | { 101 | return $this->multipart; 102 | } 103 | 104 | /** 105 | * @return array 106 | */ 107 | public function getResultParams(): array 108 | { 109 | return [ 110 | 'type' => self::RESULT_TYPE, 111 | 'multiple' => self::MULTIPLE_RESULTS 112 | ]; 113 | } 114 | 115 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/AnswerPreCheckoutQuery.php: -------------------------------------------------------------------------------- 1 | pre_checkout_query_id = $pre_checkout_query_id; 59 | $this->ok = $ok; 60 | $this->error_message = $error_message; 61 | } 62 | 63 | /** 64 | * @return array 65 | */ 66 | public function getParams(): array 67 | { 68 | return [ 69 | 'pre_checkout_query_id' => $this->pre_checkout_query_id, 70 | 'ok' => $this->ok, 71 | 'error_message' => $this->error_message 72 | ]; 73 | } 74 | 75 | /** 76 | * @return string 77 | */ 78 | public function getMethodName(): string 79 | { 80 | return self::METHOD_NAME; 81 | } 82 | 83 | /** 84 | * @return bool 85 | */ 86 | public function isMultipart(): bool 87 | { 88 | return $this->multipart; 89 | } 90 | 91 | /** 92 | * @return array 93 | */ 94 | public function getResultParams(): array 95 | { 96 | return [ 97 | 'type' => self::RESULT_TYPE, 98 | 'multiple' => self::MULTIPLE_RESULTS 99 | ]; 100 | } 101 | 102 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/DeleteChatPhoto.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'chat_id' => $this->chat_id 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/DeleteChatStickerSet.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'chat_id' => $this->chat_id 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/DeleteMessage.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 48 | $this->message_id = $message_id; 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function getParams(): array 55 | { 56 | return [ 57 | 'chat_id' => $this->chat_id, 58 | 'message_id' => $this->message_id 59 | ]; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getMethodName(): string 66 | { 67 | return self::METHOD_NAME; 68 | } 69 | 70 | /** 71 | * @return bool 72 | */ 73 | public function isMultipart(): bool 74 | { 75 | return $this->multipart; 76 | } 77 | 78 | /** 79 | * @return array 80 | */ 81 | public function getResultParams(): array 82 | { 83 | return [ 84 | 'type' => self::RESULT_TYPE, 85 | 'multiple' => self::MULTIPLE_RESULTS 86 | ]; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/DeleteStickerFromSet.php: -------------------------------------------------------------------------------- 1 | sticker = $sticker->input_file; 45 | } 46 | 47 | /** 48 | * @return array 49 | */ 50 | public function getParams(): array 51 | { 52 | return [ 53 | 'sticker' => $this->sticker 54 | ]; 55 | } 56 | 57 | /** 58 | * @return string 59 | */ 60 | public function getMethodName(): string 61 | { 62 | return self::METHOD_NAME; 63 | } 64 | 65 | /** 66 | * @return bool 67 | */ 68 | public function isMultipart(): bool 69 | { 70 | return $this->multipart; 71 | } 72 | 73 | /** 74 | * @return array 75 | */ 76 | public function getResultParams(): array 77 | { 78 | return [ 79 | 'type' => self::RESULT_TYPE, 80 | 'multiple' => self::MULTIPLE_RESULTS 81 | ]; 82 | } 83 | 84 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/DeleteWebhook.php: -------------------------------------------------------------------------------- 1 | multipart; 53 | } 54 | 55 | /** 56 | * @return array 57 | */ 58 | public function getResultParams(): array 59 | { 60 | return [ 61 | 'type' => self::RESULT_TYPE, 62 | 'multiple' => self::MULTIPLE_RESULTS 63 | ]; 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/ExportChatInviteLink.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'chat_id' => $this->chat_id 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/ForwardMessage.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 58 | $this->from_chat_id = $from_chat_id; 59 | $this->disable_notification = $disable_notification; 60 | $this->message_id = $message_id; 61 | } 62 | 63 | /** 64 | * @return array 65 | */ 66 | public function getParams(): array 67 | { 68 | return [ 69 | 'chat_id' => $this->chat_id, 70 | 'from_chat_id' => $this->from_chat_id, 71 | 'disable_notification' => $this->disable_notification, 72 | 'message_id' => $this->message_id 73 | ]; 74 | } 75 | 76 | /** 77 | * @return string 78 | */ 79 | public function getMethodName(): string 80 | { 81 | return self::METHOD_NAME; 82 | } 83 | 84 | /** 85 | * @return bool 86 | */ 87 | public function isMultipart(): bool 88 | { 89 | return $this->multipart; 90 | } 91 | 92 | /** 93 | * @return array 94 | */ 95 | public function getResultParams(): array 96 | { 97 | return [ 98 | 'type' => self::RESULT_TYPE, 99 | 'multiple' => self::MULTIPLE_RESULTS 100 | ]; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetChat.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'chat_id' => $this->chat_id 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetChatAdministrators.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'chat_id' => $this->chat_id 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetChatMember.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 48 | $this->user_id = $user_id; 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function getParams(): array 55 | { 56 | return [ 57 | 'chat_id' => $this->chat_id, 58 | 'user_id' => $this->user_id 59 | ]; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getMethodName(): string 66 | { 67 | return self::METHOD_NAME; 68 | } 69 | 70 | /** 71 | * @return bool 72 | */ 73 | public function isMultipart(): bool 74 | { 75 | return $this->multipart; 76 | } 77 | 78 | /** 79 | * @return array 80 | */ 81 | public function getResultParams(): array 82 | { 83 | return [ 84 | 'type' => self::RESULT_TYPE, 85 | 'multiple' => self::MULTIPLE_RESULTS 86 | ]; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetChatMembersCount.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'chat_id' => $this->chat_id 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetFile.php: -------------------------------------------------------------------------------- 1 | file_id = $file_id; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'file_id' => $this->file_id 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetMe.php: -------------------------------------------------------------------------------- 1 | multipart; 53 | } 54 | 55 | /** 56 | * @return array 57 | */ 58 | public function getResultParams(): array 59 | { 60 | return [ 61 | 'type' => self::RESULT_TYPE, 62 | 'multiple' => self::MULTIPLE_RESULTS 63 | ]; 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetStickerSet.php: -------------------------------------------------------------------------------- 1 | name = $name; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'name' => $this->name 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetUpdates.php: -------------------------------------------------------------------------------- 1 | offset = $offset; 58 | $this->limit = $limit; 59 | $this->timeout = $timeout; 60 | $this->allowed_updates = $allowed_updates; 61 | } 62 | 63 | /** 64 | * @return array 65 | */ 66 | public function getParams(): array 67 | { 68 | return [ 69 | 'offset' => $this->offset, 70 | 'limit' => $this->limit, 71 | 'timeout' => $this->timeout, 72 | 'allowed_updates' => $this->allowed_updates 73 | ]; 74 | } 75 | 76 | /** 77 | * @return string 78 | */ 79 | public function getMethodName(): string 80 | { 81 | return self::METHOD_NAME; 82 | } 83 | 84 | /** 85 | * @return bool 86 | */ 87 | public function isMultipart(): bool 88 | { 89 | return $this->multipart; 90 | } 91 | 92 | /** 93 | * @return array 94 | */ 95 | public function getResultParams(): array 96 | { 97 | return [ 98 | 'type' => self::RESULT_TYPE, 99 | 'multiple' => self::MULTIPLE_RESULTS 100 | ]; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetUserProfilePhotos.php: -------------------------------------------------------------------------------- 1 | user_id = $user_id; 53 | $this->offset = $offset; 54 | $this->limit = $limit; 55 | } 56 | 57 | /** 58 | * @return array 59 | */ 60 | public function getParams(): array 61 | { 62 | return [ 63 | 'user_id' => $this->user_id, 64 | 'offset' => $this->offset, 65 | 'limit' => $this->limit 66 | ]; 67 | } 68 | 69 | /** 70 | * @return string 71 | */ 72 | public function getMethodName(): string 73 | { 74 | return self::METHOD_NAME; 75 | } 76 | 77 | /** 78 | * @return bool 79 | */ 80 | public function isMultipart(): bool 81 | { 82 | return $this->multipart; 83 | } 84 | 85 | /** 86 | * @return array 87 | */ 88 | public function getResultParams(): array 89 | { 90 | return [ 91 | 'type' => self::RESULT_TYPE, 92 | 'multiple' => self::MULTIPLE_RESULTS 93 | ]; 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/GetWebhookInfo.php: -------------------------------------------------------------------------------- 1 | multipart; 53 | } 54 | 55 | /** 56 | * @return array 57 | */ 58 | public function getResultParams(): array 59 | { 60 | return [ 61 | 'type' => self::RESULT_TYPE, 62 | 'multiple' => self::MULTIPLE_RESULTS 63 | ]; 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/KickChatMember.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 53 | $this->user_id = $user_id; 54 | $this->until_date = $until_date; 55 | } 56 | 57 | /** 58 | * @return array 59 | */ 60 | public function getParams(): array 61 | { 62 | return [ 63 | 'chat_id' => $this->chat_id, 64 | 'user_id' => $this->user_id, 65 | 'until_date' => $this->until_date 66 | ]; 67 | } 68 | 69 | /** 70 | * @return string 71 | */ 72 | public function getMethodName(): string 73 | { 74 | return self::METHOD_NAME; 75 | } 76 | 77 | /** 78 | * @return bool 79 | */ 80 | public function isMultipart(): bool 81 | { 82 | return $this->multipart; 83 | } 84 | 85 | /** 86 | * @return array 87 | */ 88 | public function getResultParams(): array 89 | { 90 | return [ 91 | 'type' => self::RESULT_TYPE, 92 | 'multiple' => self::MULTIPLE_RESULTS 93 | ]; 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/LeaveChat.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'chat_id' => $this->chat_id 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/MethodInterface.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 53 | $this->message_id = $message_id; 54 | $this->disable_notification = $disable_notification; 55 | } 56 | 57 | /** 58 | * @return array 59 | */ 60 | public function getParams(): array 61 | { 62 | return [ 63 | 'chat_id' => $this->chat_id, 64 | 'message_id' => $this->message_id, 65 | 'disable_notification' => $this->disable_notification 66 | ]; 67 | } 68 | 69 | /** 70 | * @return string 71 | */ 72 | public function getMethodName(): string 73 | { 74 | return self::METHOD_NAME; 75 | } 76 | 77 | /** 78 | * @return bool 79 | */ 80 | public function isMultipart(): bool 81 | { 82 | return $this->multipart; 83 | } 84 | 85 | /** 86 | * @return array 87 | */ 88 | public function getResultParams(): array 89 | { 90 | return [ 91 | 'type' => self::RESULT_TYPE, 92 | 'multiple' => self::MULTIPLE_RESULTS 93 | ]; 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/SendChatAction.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 48 | $this->action = $action; 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function getParams(): array 55 | { 56 | return [ 57 | 'chat_id' => $this->chat_id, 58 | 'action' => $this->action 59 | ]; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getMethodName(): string 66 | { 67 | return self::METHOD_NAME; 68 | } 69 | 70 | /** 71 | * @return bool 72 | */ 73 | public function isMultipart(): bool 74 | { 75 | return $this->multipart; 76 | } 77 | 78 | /** 79 | * @return array 80 | */ 81 | public function getResultParams(): array 82 | { 83 | return [ 84 | 'type' => self::RESULT_TYPE, 85 | 'multiple' => self::MULTIPLE_RESULTS 86 | ]; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/SendMediaGroup.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 62 | foreach ($media as $media_file) { 63 | if ($media_file->is_multipart) { 64 | $this->multipart = true; 65 | } 66 | } 67 | $this->media = $media; 68 | $this->disable_notification = $disable_notification; 69 | $this->reply_to_message_id = $reply_to_message_id; 70 | } 71 | 72 | /** 73 | * @return array 74 | */ 75 | public function getParams(): array 76 | { 77 | return [ 78 | 'chat_id' => $this->chat_id, 79 | 'media' => $this->media, 80 | 'disable_notification' => $this->disable_notification, 81 | 'reply_to_message_id' => $this->reply_to_message_id 82 | ]; 83 | } 84 | 85 | /** 86 | * @return string 87 | */ 88 | public function getMethodName(): string 89 | { 90 | return self::METHOD_NAME; 91 | } 92 | 93 | /** 94 | * @return bool 95 | */ 96 | public function isMultipart(): bool 97 | { 98 | return $this->multipart; 99 | } 100 | 101 | /** 102 | * @return array 103 | */ 104 | public function getResultParams(): array 105 | { 106 | return [ 107 | 'type' => self::RESULT_TYPE, 108 | 'multiple' => self::MULTIPLE_RESULTS 109 | ]; 110 | } 111 | 112 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/SetChatDescription.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 48 | $this->description = $description; 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function getParams(): array 55 | { 56 | return [ 57 | 'chat_id' => $this->chat_id, 58 | 'description' => $this->description 59 | ]; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getMethodName(): string 66 | { 67 | return self::METHOD_NAME; 68 | } 69 | 70 | /** 71 | * @return bool 72 | */ 73 | public function isMultipart(): bool 74 | { 75 | return $this->multipart; 76 | } 77 | 78 | /** 79 | * @return array 80 | */ 81 | public function getResultParams(): array 82 | { 83 | return [ 84 | 'type' => self::RESULT_TYPE, 85 | 'multiple' => self::MULTIPLE_RESULTS 86 | ]; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/SetChatPhoto.php: -------------------------------------------------------------------------------- 1 | is_local) { 50 | $this->multipart = true; 51 | } 52 | $this->chat_id = $chat_id; 53 | $this->photo = $photo->input_file; 54 | } 55 | 56 | /** 57 | * @return array 58 | */ 59 | public function getParams(): array 60 | { 61 | return [ 62 | 'chat_id' => $this->chat_id, 63 | 'photo' => $this->photo 64 | ]; 65 | } 66 | 67 | /** 68 | * @return string 69 | */ 70 | public function getMethodName(): string 71 | { 72 | return self::METHOD_NAME; 73 | } 74 | 75 | /** 76 | * @return bool 77 | */ 78 | public function isMultipart(): bool 79 | { 80 | return $this->multipart; 81 | } 82 | 83 | /** 84 | * @return array 85 | */ 86 | public function getResultParams(): array 87 | { 88 | return [ 89 | 'type' => self::RESULT_TYPE, 90 | 'multiple' => self::MULTIPLE_RESULTS 91 | ]; 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/SetChatStickerSet.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 48 | $this->sticker_set_name = $sticker_set_name; 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function getParams(): array 55 | { 56 | return [ 57 | 'chat_id' => $this->chat_id, 58 | 'sticker_set_name' => $this->sticker_set_name 59 | ]; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getMethodName(): string 66 | { 67 | return self::METHOD_NAME; 68 | } 69 | 70 | /** 71 | * @return bool 72 | */ 73 | public function isMultipart(): bool 74 | { 75 | return $this->multipart; 76 | } 77 | 78 | /** 79 | * @return array 80 | */ 81 | public function getResultParams(): array 82 | { 83 | return [ 84 | 'type' => self::RESULT_TYPE, 85 | 'multiple' => self::MULTIPLE_RESULTS 86 | ]; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/SetChatTitle.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 48 | $this->title = $title; 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function getParams(): array 55 | { 56 | return [ 57 | 'chat_id' => $this->chat_id, 58 | 'title' => $this->title 59 | ]; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getMethodName(): string 66 | { 67 | return self::METHOD_NAME; 68 | } 69 | 70 | /** 71 | * @return bool 72 | */ 73 | public function isMultipart(): bool 74 | { 75 | return $this->multipart; 76 | } 77 | 78 | /** 79 | * @return array 80 | */ 81 | public function getResultParams(): array 82 | { 83 | return [ 84 | 'type' => self::RESULT_TYPE, 85 | 'multiple' => self::MULTIPLE_RESULTS 86 | ]; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/SetPassportDataErrors.php: -------------------------------------------------------------------------------- 1 | user_id = $user_id; 48 | $this->errors = $errors; 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function getParams(): array 55 | { 56 | return [ 57 | 'user_id' => $this->user_id, 58 | 'errors' => $this->errors 59 | ]; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getMethodName(): string 66 | { 67 | return self::METHOD_NAME; 68 | } 69 | 70 | /** 71 | * @return bool 72 | */ 73 | public function isMultipart(): bool 74 | { 75 | return $this->multipart; 76 | } 77 | 78 | /** 79 | * @return array 80 | */ 81 | public function getResultParams(): array 82 | { 83 | return [ 84 | 'type' => self::RESULT_TYPE, 85 | 'multiple' => self::MULTIPLE_RESULTS 86 | ]; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/SetStickerPositionInSet.php: -------------------------------------------------------------------------------- 1 | sticker = $sticker->input_file; 50 | $this->position = $position; 51 | } 52 | 53 | /** 54 | * @return array 55 | */ 56 | public function getParams(): array 57 | { 58 | return [ 59 | 'sticker' => $this->sticker, 60 | 'position' => $this->position 61 | ]; 62 | } 63 | 64 | /** 65 | * @return string 66 | */ 67 | public function getMethodName(): string 68 | { 69 | return self::METHOD_NAME; 70 | } 71 | 72 | /** 73 | * @return bool 74 | */ 75 | public function isMultipart(): bool 76 | { 77 | return $this->multipart; 78 | } 79 | 80 | /** 81 | * @return array 82 | */ 83 | public function getResultParams(): array 84 | { 85 | return [ 86 | 'type' => self::RESULT_TYPE, 87 | 'multiple' => self::MULTIPLE_RESULTS 88 | ]; 89 | } 90 | 91 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/SetWebhook.php: -------------------------------------------------------------------------------- 1 | is_local) { 64 | $this->multipart = true; 65 | } 66 | $this->url = $url; 67 | $this->certificate = $certificate->input_file; 68 | $this->max_connections = $max_connections; 69 | $this->allowed_updates = $allowed_updates; 70 | } 71 | 72 | /** 73 | * @return array 74 | */ 75 | public function getParams(): array 76 | { 77 | return [ 78 | 'url' => $this->url, 79 | 'certificate' => $this->certificate, 80 | 'max_connections' => $this->max_connections, 81 | 'allowed_updates' => $this->allowed_updates 82 | ]; 83 | } 84 | 85 | /** 86 | * @return string 87 | */ 88 | public function getMethodName(): string 89 | { 90 | return self::METHOD_NAME; 91 | } 92 | 93 | /** 94 | * @return bool 95 | */ 96 | public function isMultipart(): bool 97 | { 98 | return $this->multipart; 99 | } 100 | 101 | /** 102 | * @return array 103 | */ 104 | public function getResultParams(): array 105 | { 106 | return [ 107 | 'type' => self::RESULT_TYPE, 108 | 'multiple' => self::MULTIPLE_RESULTS 109 | ]; 110 | } 111 | 112 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/UnbanChatMember.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 48 | $this->user_id = $user_id; 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function getParams(): array 55 | { 56 | return [ 57 | 'chat_id' => $this->chat_id, 58 | 'user_id' => $this->user_id 59 | ]; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getMethodName(): string 66 | { 67 | return self::METHOD_NAME; 68 | } 69 | 70 | /** 71 | * @return bool 72 | */ 73 | public function isMultipart(): bool 74 | { 75 | return $this->multipart; 76 | } 77 | 78 | /** 79 | * @return array 80 | */ 81 | public function getResultParams(): array 82 | { 83 | return [ 84 | 'type' => self::RESULT_TYPE, 85 | 'multiple' => self::MULTIPLE_RESULTS 86 | ]; 87 | } 88 | 89 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/UnpinChatMessage.php: -------------------------------------------------------------------------------- 1 | chat_id = $chat_id; 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | public function getParams(): array 49 | { 50 | return [ 51 | 'chat_id' => $this->chat_id 52 | ]; 53 | } 54 | 55 | /** 56 | * @return string 57 | */ 58 | public function getMethodName(): string 59 | { 60 | return self::METHOD_NAME; 61 | } 62 | 63 | /** 64 | * @return bool 65 | */ 66 | public function isMultipart(): bool 67 | { 68 | return $this->multipart; 69 | } 70 | 71 | /** 72 | * @return array 73 | */ 74 | public function getResultParams(): array 75 | { 76 | return [ 77 | 'type' => self::RESULT_TYPE, 78 | 'multiple' => self::MULTIPLE_RESULTS 79 | ]; 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /src/Telegram/Methods/UploadStickerFile.php: -------------------------------------------------------------------------------- 1 | is_local) { 50 | $this->multipart = true; 51 | } 52 | $this->user_id = $user_id; 53 | $this->png_sticker = $png_sticker->input_file; 54 | } 55 | 56 | /** 57 | * @return array 58 | */ 59 | public function getParams(): array 60 | { 61 | return [ 62 | 'user_id' => $this->user_id, 63 | 'png_sticker' => $this->png_sticker 64 | ]; 65 | } 66 | 67 | /** 68 | * @return string 69 | */ 70 | public function getMethodName(): string 71 | { 72 | return self::METHOD_NAME; 73 | } 74 | 75 | /** 76 | * @return bool 77 | */ 78 | public function isMultipart(): bool 79 | { 80 | return $this->multipart; 81 | } 82 | 83 | /** 84 | * @return array 85 | */ 86 | public function getResultParams(): array 87 | { 88 | return [ 89 | 'type' => self::RESULT_TYPE, 90 | 'multiple' => self::MULTIPLE_RESULTS 91 | ]; 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /src/Telegram/Types/CallbackGame.php: -------------------------------------------------------------------------------- 1 | setCallbackGame($callback_game ?? null); 29 | } 30 | 31 | /** 32 | * @param null|\stdClass $callback_game 33 | * @return CallbackGame 34 | */ 35 | public function setCallbackGame(?\stdClass $callback_game): self 36 | { 37 | $this->callback_game = $callback_game; 38 | return $this; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/Telegram/Types/ChatPhoto.php: -------------------------------------------------------------------------------- 1 | setSmallFileId($chat_photo->small_file_id ?? null) 35 | ->setBigFileId($chat_photo->big_file_id ?? null); 36 | } 37 | 38 | /** 39 | * @param null|string $big_file_id 40 | * @return ChatPhoto 41 | */ 42 | public function setBigFileId(?string $big_file_id): self 43 | { 44 | $this->big_file_id = $big_file_id; 45 | return $this; 46 | } 47 | 48 | /** 49 | * @param null|string $small_file_id 50 | * @return ChatPhoto 51 | */ 52 | public function setSmallFileId(?string $small_file_id): self 53 | { 54 | $this->small_file_id = $small_file_id; 55 | return $this; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/Telegram/Types/ChosenInlineResult.php: -------------------------------------------------------------------------------- 1 | setResultId($chosen_inline_result->result_id ?? null) 47 | ->setFrom(User::parseUser($chosen_inline_result->from ?? null)) 48 | ->setLocation(Location::parseLocation($chosen_inline_result->location ?? null)) 49 | ->setInlineMessageId($chosen_inline_result->inline_message_id ?? null) 50 | ->setQuery($chosen_inline_result->query ?? null); 51 | } 52 | 53 | /** 54 | * @param null|string $query 55 | * @return ChosenInlineResult 56 | */ 57 | public function setQuery(?string $query): self 58 | { 59 | $this->query = $query; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $inline_message_id 65 | * @return ChosenInlineResult 66 | */ 67 | public function setInlineMessageId(?string $inline_message_id): self 68 | { 69 | $this->inline_message_id = $inline_message_id; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param null|Location $location 75 | * @return ChosenInlineResult 76 | */ 77 | public function setLocation(?Location $location): self 78 | { 79 | $this->location = $location; 80 | return $this; 81 | } 82 | 83 | /** 84 | * @param null|User $from 85 | * @return ChosenInlineResult 86 | */ 87 | public function setFrom(?User $from): self 88 | { 89 | $this->from = $from; 90 | return $this; 91 | } 92 | 93 | /** 94 | * @param null|string $result_id 95 | * @return ChosenInlineResult 96 | */ 97 | public function setResultId(?string $result_id): self 98 | { 99 | $this->result_id = $result_id; 100 | return $this; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/Telegram/Types/Contact.php: -------------------------------------------------------------------------------- 1 | setPhoneNumber($contact->phone_number ?? null) 47 | ->setFirstName($contact->first_name ?? null) 48 | ->setLastName($contact->last_name ?? null) 49 | ->setUserId($contact->user_id ?? null) 50 | ->setVcard($contact->vcard ?? null); 51 | } 52 | 53 | /** 54 | * @param null|string $vcard 55 | * @return Contact 56 | */ 57 | public function setVcard(?string $vcard): self 58 | { 59 | $this->vcard = $vcard; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param int|null $user_id 65 | * @return Contact 66 | */ 67 | public function setUserId(?int $user_id): self 68 | { 69 | $this->user_id = $user_id; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param null|string $last_name 75 | * @return Contact 76 | */ 77 | public function setLastName(?string $last_name): self 78 | { 79 | $this->last_name = $last_name; 80 | return $this; 81 | } 82 | 83 | /** 84 | * @param null|string $first_name 85 | * @return Contact 86 | */ 87 | public function setFirstName(?string $first_name): self 88 | { 89 | $this->first_name = $first_name; 90 | return $this; 91 | } 92 | 93 | /** 94 | * @param null|string $phone_number 95 | * @return Contact 96 | */ 97 | public function setPhoneNumber(?string $phone_number): self 98 | { 99 | $this->phone_number = $phone_number; 100 | return $this; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/Telegram/Types/Document.php: -------------------------------------------------------------------------------- 1 | setFileId($document->file_id ?? null) 47 | ->setThumb(PhotoSize::parsePhotoSize($document->thumb ?? null)) 48 | ->setFileName($document->file_name ?? null) 49 | ->setMimeType($document->mime_type ?? null) 50 | ->setFileSize($document->file_size ?? null); 51 | } 52 | 53 | /** 54 | * @param int|null $file_size 55 | * @return Document 56 | */ 57 | public function setFileSize(?int $file_size): self 58 | { 59 | $this->file_size = $file_size; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $mime_type 65 | * @return Document 66 | */ 67 | public function setMimeType(?string $mime_type): self 68 | { 69 | $this->mime_type = $mime_type; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param null|string $file_name 75 | * @return Document 76 | */ 77 | public function setFileName(?string $file_name): self 78 | { 79 | $this->file_name = $file_name; 80 | return $this; 81 | } 82 | 83 | /** 84 | * @param null|PhotoSize $thumb 85 | * @return Document 86 | */ 87 | public function setThumb(?PhotoSize $thumb): self 88 | { 89 | $this->thumb = $thumb; 90 | return $this; 91 | } 92 | 93 | /** 94 | * @param null|string $file_id 95 | * @return Document 96 | */ 97 | public function setFileId(?string $file_id): self 98 | { 99 | $this->file_id = $file_id; 100 | return $this; 101 | } 102 | } -------------------------------------------------------------------------------- /src/Telegram/Types/EncryptedCredentials.php: -------------------------------------------------------------------------------- 1 | setData($encrypted_credentials->data ?? null) 39 | ->setHash($encrypted_credentials->hash ?? null) 40 | ->setSecret($encrypted_credentials->secret ?? null); 41 | } 42 | 43 | /** 44 | * @param null|string $secret 45 | * @return EncryptedCredentials 46 | */ 47 | public function setSecret(?string $secret): self 48 | { 49 | $this->secret = $secret; 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param null|string $hash 55 | * @return EncryptedCredentials 56 | */ 57 | public function setHash(?string $hash): self 58 | { 59 | $this->hash = $hash; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $data 65 | * @return EncryptedCredentials 66 | */ 67 | public function setData(?string $data): self 68 | { 69 | $this->data = $data; 70 | return $this; 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /src/Telegram/Types/File.php: -------------------------------------------------------------------------------- 1 | setFileId($file->file_id ?? null) 39 | ->setFileSize($file->file_size ?? null) 40 | ->setFilePath($file->file_path ?? null); 41 | } 42 | 43 | /** 44 | * @param null|string $file_path 45 | * @return File 46 | */ 47 | public function setFilePath(?string $file_path): self 48 | { 49 | $this->file_path = $file_path; 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param int|null $file_size 55 | * @return File 56 | */ 57 | public function setFileSize(?int $file_size): self 58 | { 59 | $this->file_size = $file_size; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $file_id 65 | * @return File 66 | */ 67 | public function setFileId(?string $file_id): self 68 | { 69 | $this->file_id = $file_id; 70 | return $this; 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /src/Telegram/Types/ForceReply.php: -------------------------------------------------------------------------------- 1 | setForceReply($force_reply->force_reply ?? null) 35 | ->setSelective($force_reply->selective ?? null); 36 | } 37 | 38 | /** 39 | * @param bool|null $selective 40 | * @return ForceReply 41 | */ 42 | public function setSelective(?bool $selective): self 43 | { 44 | $this->selective = $selective; 45 | return $this; 46 | } 47 | 48 | /** 49 | * @param bool|null $force_reply 50 | * @return ForceReply 51 | */ 52 | public function setForceReply(?bool $force_reply): self 53 | { 54 | $this->force_reply = $force_reply; 55 | return $this; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/Telegram/Types/GameHighScore.php: -------------------------------------------------------------------------------- 1 | setPosition($game_high_score->position ?? null) 39 | ->setUser(User::parseUser($game_high_score->user ?? null)) 40 | ->setScore($game_high_score->score ?? null); 41 | } 42 | 43 | /** 44 | * @param int|null $score 45 | * @return GameHighScore 46 | */ 47 | public function setScore(?int $score): self 48 | { 49 | $this->score = $score; 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param null|User $user 55 | * @return GameHighScore 56 | */ 57 | public function setUser(?User $user): self 58 | { 59 | $this->user = $user; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param int|null $position 65 | * @return GameHighScore 66 | */ 67 | public function setPosition(?int $position): self 68 | { 69 | $this->position = $position; 70 | return $this; 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InlineKeyboardMarkup.php: -------------------------------------------------------------------------------- 1 | setInlineKeyboard($inline_keyboard_markup->inline_keyboard ?? null); 31 | } 32 | 33 | /** 34 | * @param array|null $inline_keyboard 35 | * @return InlineKeyboardMarkup 36 | */ 37 | public function setInlineKeyboard(?array $inline_keyboard): self 38 | { 39 | $this->inline_keyboard = $inline_keyboard; 40 | return $this; 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InlineQuery.php: -------------------------------------------------------------------------------- 1 | setId($inline_query->id ?? null) 47 | ->setFrom(User::parseUser($inline_query->from ?? null)) 48 | ->setLocation(Location::parseLocation($inline_query->location ?? null)) 49 | ->setQuery($inline_query->query ?? null) 50 | ->setOffset($inline_query->offset ?? null); 51 | } 52 | 53 | /** 54 | * @param null|string $offset 55 | * @return InlineQuery 56 | */ 57 | public function setOffset(?string $offset): self 58 | { 59 | $this->offset = $offset; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $query 65 | * @return InlineQuery 66 | */ 67 | public function setQuery(?string $query): self 68 | { 69 | $this->query = $query; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param null|Location $location 75 | * @return InlineQuery 76 | */ 77 | public function setLocation(?Location $location): self 78 | { 79 | $this->location = $location; 80 | return $this; 81 | } 82 | 83 | /** 84 | * @param null|User $from 85 | * @return InlineQuery 86 | */ 87 | public function setFrom(?User $from): self 88 | { 89 | $this->from = $from; 90 | return $this; 91 | } 92 | 93 | /** 94 | * @param null|string $id 95 | * @return InlineQuery 96 | */ 97 | public function setId(?string $id): self 98 | { 99 | $this->id = $id; 100 | return $this; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InlineQueryResult.php: -------------------------------------------------------------------------------- 1 | type)) { 34 | return null; 35 | } 36 | $class_name = sprintf('InlineQueryResult%s', ucfirst($inline_query_result->type)); 37 | return call_user_func([$class_name, 'parseInlineQueryResult'], $inline_query_result); 38 | } 39 | 40 | 41 | /** 42 | * @param null|string $type 43 | * @return InlineQueryResult 44 | */ 45 | public function setType(?string $type): InlineQueryResultInterface 46 | { 47 | $this->type = $type; 48 | return $this; 49 | } 50 | 51 | 52 | /** 53 | * @param null|string $id 54 | * @return InlineQueryResult 55 | */ 56 | public function setId(?string $id): InlineQueryResultInterface 57 | { 58 | $this->id = $id; 59 | return $this; 60 | } 61 | 62 | 63 | /** 64 | * @param null|InlineKeyboardMarkup $reply_markup 65 | * @return InlineQueryResult 66 | */ 67 | public function setReplyMarkup(?InlineKeyboardMarkup $reply_markup): InlineQueryResultInterface 68 | { 69 | $this->reply_markup = $reply_markup; 70 | return $this; 71 | } 72 | 73 | 74 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InlineQueryResultCachedSticker.php: -------------------------------------------------------------------------------- 1 | setStickerFileId($inline_query_result_cached_sticker->sticker_file_id ?? null) 34 | ->setInputMessageContent(InputMessageContent::parseInputMessageContent($inline_query_result_cached_sticker->input_message_content ?? null)) 35 | ->setType($inline_query_result_cached_sticker->type ?? null) 36 | ->setId($inline_query_result_cached_sticker->id ?? null) 37 | ->setReplyMarkup(InlineKeyboardMarkup::parseInlineKeyboardMarkup($inline_query_result_cached_sticker->reply_markup ?? null)); 38 | } 39 | 40 | /** 41 | * @param null|InputMessageContent $input_message_content 42 | * @return InlineQueryResultCachedSticker 43 | */ 44 | public function setInputMessageContent(?InputMessageContent $input_message_content): InlineQueryResultInterface 45 | { 46 | $this->input_message_content = $input_message_content; 47 | return $this; 48 | } 49 | 50 | /** 51 | * @param null|string $sticker_file_id 52 | * @return InlineQueryResultCachedSticker 53 | */ 54 | public function setStickerFileId(?string $sticker_file_id): InlineQueryResultInterface 55 | { 56 | $this->sticker_file_id = $sticker_file_id; 57 | return $this; 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InlineQueryResultGame.php: -------------------------------------------------------------------------------- 1 | setGameShortName($inline_query_result_game->game_short_name ?? null) 31 | ->setType($inline_query_result_game->type ?? null) 32 | ->setId($inline_query_result_game->id ?? null) 33 | ->setReplyMarkup(InlineKeyboardMarkup::parseInlineKeyboardMarkup($inline_query_result_game->reply_markup ?? null)); 34 | } 35 | 36 | /** 37 | * @param null|string $game_short_name 38 | * @return InlineQueryResultGame 39 | */ 40 | public function setGameShortName(?string $game_short_name): InlineQueryResultInterface 41 | { 42 | $this->game_short_name = $game_short_name; 43 | return $this; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InlineQueryResultInterface.php: -------------------------------------------------------------------------------- 1 | setPhoneNumber($input_contact_message_content->phone_number ?? null) 43 | ->setFirstName($input_contact_message_content->first_name ?? null) 44 | ->setLastName($input_contact_message_content->last_name ?? null) 45 | ->setVcard($input_contact_message_content->vcard ?? null); 46 | } 47 | 48 | /** 49 | * @param null|string $vcard 50 | * @return InputContactMessageContent 51 | */ 52 | public function setVcard(?string $vcard): InputMessageContentInterface 53 | { 54 | $this->vcard = $vcard; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param null|string $last_name 60 | * @return InputContactMessageContent 61 | */ 62 | public function setLastName(?string $last_name): InputMessageContentInterface 63 | { 64 | $this->last_name = $last_name; 65 | return $this; 66 | } 67 | 68 | /** 69 | * @param null|string $first_name 70 | * @return InputContactMessageContent 71 | */ 72 | public function setFirstName(?string $first_name): InputMessageContentInterface 73 | { 74 | $this->first_name = $first_name; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param null|string $phone_number 80 | * @return InputContactMessageContent 81 | */ 82 | public function setPhoneNumber(?string $phone_number): InputMessageContentInterface 83 | { 84 | $this->phone_number = $phone_number; 85 | return $this; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InputFile.php: -------------------------------------------------------------------------------- 1 | input_file = $input_file ?? null; 33 | $this->is_local = $is_local ?? false; 34 | } 35 | 36 | 37 | /** 38 | * @param string|resource $input_file 39 | * @param bool $is_local 40 | * @return null|InputFile 41 | */ 42 | public static function parseInputFile(string $input_file, bool $is_local = false): self 43 | { 44 | return new self($input_file ?? null, $is_local ?? false); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InputLocationMessageContent.php: -------------------------------------------------------------------------------- 1 | setLatitude($input_location_message_content->latitude ?? null) 39 | ->setLongitude($input_location_message_content->longitude ?? null) 40 | ->setLivePeriod($input_location_message_content->live_period ?? null); 41 | } 42 | 43 | /** 44 | * @param int|null $live_period 45 | * @return InputLocationMessageContent 46 | */ 47 | public function setLivePeriod(?int $live_period): InputMessageContentInterface 48 | { 49 | $this->live_period = $live_period; 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param float|null $longitude 55 | * @return InputLocationMessageContent 56 | */ 57 | public function setLongitude(?float $longitude): InputMessageContentInterface 58 | { 59 | $this->longitude = $longitude; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param float|null $latitude 65 | * @return InputLocationMessageContent 66 | */ 67 | public function setLatitude(?float $latitude): InputMessageContentInterface 68 | { 69 | $this->latitude = $latitude; 70 | return $this; 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InputMedia.php: -------------------------------------------------------------------------------- 1 | type)) { 35 | return null; 36 | } 37 | $class_name = sprintf('InputMedia%s', ucfirst($input_media->type)); 38 | return call_user_func([$class_name, 'parseInputMedia'], $input_media); 39 | } 40 | 41 | /** 42 | * @param null|string $type 43 | * @return InputMedia 44 | */ 45 | public function setType(?string $type): InputMediaInterface 46 | { 47 | $this->type = $type; 48 | return $this; 49 | } 50 | 51 | /** 52 | * @param null|string $media 53 | * @return InputMedia 54 | */ 55 | public function setMedia(?string $media): InputMediaInterface 56 | { 57 | $this->media = $media; 58 | return $this; 59 | } 60 | 61 | /** 62 | * @param null|string $caption 63 | * @return InputMedia 64 | */ 65 | public function setCaption(?string $caption): InputMediaInterface 66 | { 67 | $this->caption = $caption; 68 | return $this; 69 | } 70 | 71 | /** 72 | * @param null|string $parse_mode 73 | * @return InputMedia 74 | */ 75 | public function setParseMode(?string $parse_mode): InputMediaInterface 76 | { 77 | $this->parse_mode = $parse_mode; 78 | return $this; 79 | } 80 | 81 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InputMediaAnimation.php: -------------------------------------------------------------------------------- 1 | setThumb($input_media_animation->thumb ?? null) 59 | ->setWidth($input_media_animation->width ?? null) 60 | ->setHeight($input_media_animation->height ?? null) 61 | ->setDuration($input_media_animation->duration ?? null) 62 | ->setType($input_media_animation->type ?? null) 63 | ->setMedia(InputFile::parseInputFile($input_media_animation->media ?? null)) 64 | ->setCaption($input_media_animation->caption ?? null) 65 | ->setParseMode($input_media_animation->parse_mode ?? null); 66 | } 67 | 68 | /** 69 | * @param int|null $duration 70 | * @return InputMediaAnimation 71 | */ 72 | public function setDuration(?int $duration): InputMediaInterface 73 | { 74 | $this->duration = $duration; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param int|null $height 80 | * @return InputMediaAnimation 81 | */ 82 | public function setHeight(?int $height): InputMediaInterface 83 | { 84 | $this->height = $height; 85 | return $this; 86 | } 87 | 88 | /** 89 | * @param int|null $width 90 | * @return InputMediaAnimation 91 | */ 92 | public function setWidth(?int $width): InputMediaInterface 93 | { 94 | $this->width = $width; 95 | return $this; 96 | } 97 | 98 | /** 99 | * @param null|PhotoSize $thumb 100 | * @return InputMediaAnimation 101 | */ 102 | public function setThumb(?PhotoSize $thumb): InputMediaInterface 103 | { 104 | $this->thumb = $thumb; 105 | return $this; 106 | } 107 | 108 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InputMediaAudio.php: -------------------------------------------------------------------------------- 1 | setThumb($input_media_audio->thumb ?? null) 59 | ->setDuration($input_media_audio->duration ?? null) 60 | ->setPerformer($input_media_audio->performer ?? null) 61 | ->setTitle($input_media_audio->title ?? null) 62 | ->setType($input_media_audio->type ?? null) 63 | ->setMedia(InputFile::parseInputFile($input_media_audio->media ?? null)) 64 | ->setCaption($input_media_audio->caption ?? null) 65 | ->setParseMode($input_media_audio->parse_mode ?? null); 66 | } 67 | 68 | /** 69 | * @param null|string $title 70 | * @return InputMediaAudio 71 | */ 72 | public function setTitle(?string $title): InputMediaInterface 73 | { 74 | $this->title = $title; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param null|string $performer 80 | * @return InputMediaAudio 81 | */ 82 | public function setPerformer(?string $performer): InputMediaInterface 83 | { 84 | $this->performer = $performer; 85 | return $this; 86 | } 87 | 88 | /** 89 | * @param int|null $duration 90 | * @return InputMediaAudio 91 | */ 92 | public function setDuration(?int $duration): InputMediaInterface 93 | { 94 | $this->duration = $duration; 95 | return $this; 96 | } 97 | 98 | /** 99 | * @param null|InputFile $thumb 100 | * @return InputMediaAudio 101 | */ 102 | public function setThumb(?InputFile $thumb): InputMediaInterface 103 | { 104 | $this->thumb = $thumb; 105 | return $this; 106 | } 107 | 108 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InputMediaDocument.php: -------------------------------------------------------------------------------- 1 | setThumb($input_media_document->thumb ?? null) 47 | ->setType($input_media_document->type ?? null) 48 | ->setMedia(InputFile::parseInputFile($input_media_document->media ?? null)) 49 | ->setCaption($input_media_document->caption ?? null) 50 | ->setParseMode($input_media_document->parse_mode ?? null); 51 | } 52 | 53 | /** 54 | * @param null|InputFile $thumb 55 | * @return InputMediaDocument 56 | */ 57 | public function setThumb(?InputFile $thumb): InputMediaInterface 58 | { 59 | $this->thumb = $thumb; 60 | return $this; 61 | } 62 | 63 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InputMediaInterface.php: -------------------------------------------------------------------------------- 1 | setType($input_media_photo->type ?? null) 43 | ->setMedia(InputFile::parseInputFile($input_media_photo->media ?? null)) 44 | ->setCaption($input_media_photo->caption ?? null) 45 | ->setParseMode($input_media_photo->parse_mode ?? null); 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InputMessageContent.php: -------------------------------------------------------------------------------- 1 | type)) { 21 | return null; 22 | } 23 | $class_name = sprintf('InputMessageContent%s', ucfirst($input_message_content->type)); 24 | return call_user_func([$class_name, 'parseInputMessageContent'], $input_message_content); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /src/Telegram/Types/InputMessageContentInterface.php: -------------------------------------------------------------------------------- 1 | setMessageText($input_text_message_content->message_text ?? null) 39 | ->setParseMode($input_text_message_content->parse_mode ?? null) 40 | ->setDisableWebPagePreview($input_text_message_content->disable_web_page_preview ?? null); 41 | } 42 | 43 | /** 44 | * @param bool|null $disable_web_page_preview 45 | * @return InputTextMessageContent 46 | */ 47 | public function setDisableWebPagePreview(?bool $disable_web_page_preview): InputMessageContentInterface 48 | { 49 | $this->disable_web_page_preview = $disable_web_page_preview; 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param null|string $parse_mode 55 | * @return InputTextMessageContent 56 | */ 57 | public function setParseMode(?string $parse_mode): InputMessageContentInterface 58 | { 59 | $this->parse_mode = $parse_mode; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $message_text 65 | * @return InputTextMessageContent 66 | */ 67 | public function setMessageText(?string $message_text): InputMessageContentInterface 68 | { 69 | $this->message_text = $message_text; 70 | return $this; 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /src/Telegram/Types/Invoice.php: -------------------------------------------------------------------------------- 1 | setTitle($invoice->title ?? null) 47 | ->setDescription($invoice->description ?? null) 48 | ->setStartParameter($invoice->start_parameter ?? null) 49 | ->setCurrency($invoice->currency ?? null) 50 | ->setTotalAmount($invoice->total_amount ?? null); 51 | } 52 | 53 | /** 54 | * @param int|null $total_amount 55 | * @return Invoice 56 | */ 57 | public function setTotalAmount(?int $total_amount): self 58 | { 59 | $this->total_amount = $total_amount; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $currency 65 | * @return Invoice 66 | */ 67 | public function setCurrency(?string $currency): self 68 | { 69 | $this->currency = $currency; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param null|string $start_parameter 75 | * @return Invoice 76 | */ 77 | public function setStartParameter(?string $start_parameter): self 78 | { 79 | $this->start_parameter = $start_parameter; 80 | return $this; 81 | } 82 | 83 | /** 84 | * @param null|string $description 85 | * @return Invoice 86 | */ 87 | public function setDescription(?string $description): self 88 | { 89 | $this->description = $description; 90 | return $this; 91 | } 92 | 93 | /** 94 | * @param null|string $title 95 | * @return Invoice 96 | */ 97 | public function setTitle(?string $title): self 98 | { 99 | $this->title = $title; 100 | return $this; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/Telegram/Types/KeyboardButton.php: -------------------------------------------------------------------------------- 1 | setText($keyboard_button->text ?? null) 39 | ->setRequestContact($keyboard_button->request_contact ?? false) 40 | ->setRequestLocation($keyboard_button->request_location ?? false); 41 | } 42 | 43 | /** 44 | * @param bool|null $request_location 45 | * @return KeyboardButton 46 | */ 47 | public function setRequestLocation(?bool $request_location): self 48 | { 49 | $this->request_location = $request_location; 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param bool|null $request_contact 55 | * @return KeyboardButton 56 | */ 57 | public function setRequestContact(?bool $request_contact): self 58 | { 59 | $this->request_contact = $request_contact; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $text 65 | * @return KeyboardButton 66 | */ 67 | public function setText(?string $text): self 68 | { 69 | $this->text = $text; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param array|null $keyboard_buttons 75 | * @return array|null 76 | */ 77 | public static function parseKeyboardButtons(?array $keyboard_buttons): ?array 78 | { 79 | if (is_null($keyboard_buttons)) { 80 | return null; 81 | } 82 | return array_map(['self', 'parseKeyboardButton'], $keyboard_buttons); 83 | } 84 | 85 | } -------------------------------------------------------------------------------- /src/Telegram/Types/LabeledPrice.php: -------------------------------------------------------------------------------- 1 | setLabel($labeled_price->label ?? null) 35 | ->setAmount($labeled_price->amount ?? null); 36 | } 37 | 38 | /** 39 | * @param int|null $amount 40 | * @return LabeledPrice 41 | */ 42 | public function setAmount(?int $amount): self 43 | { 44 | $this->amount = $amount; 45 | return $this; 46 | } 47 | 48 | /** 49 | * @param null|string $label 50 | * @return LabeledPrice 51 | */ 52 | public function setLabel(?string $label): self 53 | { 54 | $this->label = $label; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param array|null $labeled_prices 60 | * @return array|null 61 | */ 62 | public static function parseLabeledPrices(?array $labeled_prices): ?array 63 | { 64 | if (is_null($labeled_prices)) { 65 | return null; 66 | } 67 | return array_map(['self', 'parseLabeledPrice'], $labeled_prices); 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /src/Telegram/Types/Location.php: -------------------------------------------------------------------------------- 1 | setLongitude($location->longitude ?? null) 35 | ->setLatitude($location->latitude ?? null); 36 | } 37 | 38 | /** 39 | * @param float|null $latitude 40 | * @return Location 41 | */ 42 | public function setLatitude(?float $latitude): self 43 | { 44 | $this->latitude = $latitude; 45 | return $this; 46 | } 47 | 48 | /** 49 | * @param float|null $longitude 50 | * @return Location 51 | */ 52 | public function setLongitude(?float $longitude): self 53 | { 54 | $this->longitude = $longitude; 55 | return $this; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/Telegram/Types/MaskPosition.php: -------------------------------------------------------------------------------- 1 | setPoint($mask_position->point ?? null) 43 | ->setXShift($mask_position->x_shift ?? null) 44 | ->setYShift($mask_position->y_shift ?? null) 45 | ->setScale($mask_position->scale ?? null); 46 | } 47 | 48 | /** 49 | * @param float|null $scale 50 | * @return MaskPosition 51 | */ 52 | public function setScale(?float $scale): self 53 | { 54 | $this->scale = $scale; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param float|null $y_shift 60 | * @return MaskPosition 61 | */ 62 | public function setYShift(?float $y_shift): self 63 | { 64 | $this->y_shift = $y_shift; 65 | return $this; 66 | } 67 | 68 | /** 69 | * @param float|null $x_shift 70 | * @return MaskPosition 71 | */ 72 | public function setXShift(?float $x_shift): self 73 | { 74 | $this->x_shift = $x_shift; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param null|string $point 80 | * @return MaskPosition 81 | */ 82 | public function setPoint(?string $point): self 83 | { 84 | $this->point = $point; 85 | return $this; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/Telegram/Types/MessageEntity.php: -------------------------------------------------------------------------------- 1 | setType($message_entity->type ?? null) 47 | ->setOffset($message_entity->offset ?? null) 48 | ->setLength($message_entity->length ?? null) 49 | ->setUrl($message_entity->url ?? null) 50 | ->setUser(User::parseUser($message_entity->user ?? null)); 51 | } 52 | 53 | /** 54 | * @param mixed $user 55 | * @return MessageEntity 56 | */ 57 | public function setUser(?User $user): self 58 | { 59 | $this->user = $user; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param mixed $url 65 | * @return MessageEntity 66 | */ 67 | public function setUrl(?string $url): self 68 | { 69 | $this->url = $url; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param mixed $length 75 | * @return MessageEntity 76 | */ 77 | public function setLength(?int $length): self 78 | { 79 | $this->length = $length; 80 | return $this; 81 | } 82 | 83 | /** 84 | * @param mixed $offset 85 | * @return MessageEntity 86 | */ 87 | public function setOffset(?int $offset): self 88 | { 89 | $this->offset = $offset; 90 | return $this; 91 | } 92 | 93 | /** 94 | * @param mixed $type 95 | * @return MessageEntity 96 | */ 97 | public function setType(?string $type): self 98 | { 99 | $this->type = $type; 100 | return $this; 101 | } 102 | 103 | /** 104 | * @param array|null $message_entities 105 | * @return array|null 106 | */ 107 | public static function parseMessageEntities(?array $message_entities): ?array 108 | { 109 | if (is_null($message_entities)) { 110 | return null; 111 | } 112 | return array_map(['self', 'parseMessageEntity'], $message_entities); 113 | } 114 | } -------------------------------------------------------------------------------- /src/Telegram/Types/OrderInfo.php: -------------------------------------------------------------------------------- 1 | setName($order_info->name ?? null) 43 | ->setPhoneNumber($order_info->phone_number ?? null) 44 | ->setEmail($order_info->email ?? null) 45 | ->setShippingAddress(ShippingAddress::parseShippingAddress($order_info->shipping_address ?? null)); 46 | } 47 | 48 | /** 49 | * @param null|ShippingAddress $shipping_address 50 | * @return OrderInfo 51 | */ 52 | public function setShippingAddress(?ShippingAddress $shipping_address): self 53 | { 54 | $this->shipping_address = $shipping_address; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param null|string $email 60 | * @return OrderInfo 61 | */ 62 | public function setEmail(?string $email): self 63 | { 64 | $this->email = $email; 65 | return $this; 66 | } 67 | 68 | /** 69 | * @param null|string $phone_number 70 | * @return OrderInfo 71 | */ 72 | public function setPhoneNumber(?string $phone_number): self 73 | { 74 | $this->phone_number = $phone_number; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param null|string $name 80 | * @return OrderInfo 81 | */ 82 | public function setName(?string $name): self 83 | { 84 | $this->name = $name; 85 | return $this; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportData.php: -------------------------------------------------------------------------------- 1 | setData(EncryptedPassportElement::parseEncryptedPassportElements($passport_data->data ?? null)) 35 | ->setCredentials(EncryptedCredentials::parseEncryptedCredentials($passport_data->credentials ?? null)); 36 | } 37 | 38 | /** 39 | * @param null|EncryptedCredentials $credentials 40 | * @return PassportData 41 | */ 42 | public function setCredentials(?EncryptedCredentials $credentials): self 43 | { 44 | $this->credentials = $credentials; 45 | return $this; 46 | } 47 | 48 | /** 49 | * @param array|null $data 50 | * @return PassportData 51 | */ 52 | public function setData(?array $data): self 53 | { 54 | $this->data = $data; 55 | return $this; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementError.php: -------------------------------------------------------------------------------- 1 | type)) { 38 | return null; 39 | } 40 | $class_name = sprintf('PassportElementError%s', ucfirst($passport_element_error->type)); 41 | return call_user_func([$class_name, 'parsePassportElementError'], $passport_element_error); 42 | } 43 | 44 | 45 | /** 46 | * @param null|string $source 47 | * @return PassportElementError 48 | */ 49 | public function setSource(?string $source): PassportElementErrorInterface 50 | { 51 | $this->source = $source; 52 | return $this; 53 | } 54 | 55 | 56 | /** 57 | * @param null|string $type 58 | * @return PassportElementError 59 | */ 60 | public function setType(?string $type): PassportElementErrorInterface 61 | { 62 | $this->type = $type; 63 | return $this; 64 | } 65 | 66 | 67 | /** 68 | * @param null|string $message 69 | * @return PassportElementError 70 | */ 71 | public function setMessage(?string $message): PassportElementErrorInterface 72 | { 73 | $this->message = $message; 74 | return $this; 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementErrorDataField.php: -------------------------------------------------------------------------------- 1 | setFieldName($passport_element_error_data_field->field_name ?? null) 35 | ->setDataHash($passport_element_error_data_field->data_hash ?? null) 36 | ->setSource($passport_element_error_data_field->source ?? null) 37 | ->setType($passport_element_error_data_field->type ?? null) 38 | ->setMessage($passport_element_error_data_field->message ?? null); 39 | } 40 | 41 | /** 42 | * @param null|string $data_hash 43 | * @return PassportElementErrorDataField 44 | */ 45 | public function setDataHash(?string $data_hash): PassportElementErrorInterface 46 | { 47 | $this->data_hash = $data_hash; 48 | return $this; 49 | } 50 | 51 | /** 52 | * @param null|string $field_name 53 | * @return PassportElementErrorDataField 54 | */ 55 | public function setFieldName(?string $field_name): PassportElementErrorInterface 56 | { 57 | $this->field_name = $field_name; 58 | return $this; 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementErrorFile.php: -------------------------------------------------------------------------------- 1 | setFileHash($passport_element_error_file->file_hash ?? null) 31 | ->setSource($passport_element_error_file->source ?? null) 32 | ->setType($passport_element_error_file->type ?? null) 33 | ->setMessage($passport_element_error_file->message ?? null); 34 | } 35 | 36 | /** 37 | * @param null|string $file_hash 38 | * @return PassportElementErrorFile 39 | */ 40 | public function setFileHash(?string $file_hash): PassportElementErrorInterface 41 | { 42 | $this->file_hash = $file_hash; 43 | return $this; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementErrorFiles.php: -------------------------------------------------------------------------------- 1 | setFileHashes($passport_element_error_files->file_hashes ?? null) 30 | ->setSource($passport_element_error_files->source ?? null) 31 | ->setType($passport_element_error_files->type ?? null) 32 | ->setMessage($passport_element_error_files->message ?? null); 33 | } 34 | 35 | /** 36 | * @param array|null $file_hashes 37 | * @return PassportElementErrorFiles 38 | */ 39 | public function setFileHashes(?array $file_hashes): PassportElementErrorInterface 40 | { 41 | $this->file_hashes = $file_hashes; 42 | return $this; 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementErrorFrontSide.php: -------------------------------------------------------------------------------- 1 | setFileHash($passport_element_error_front_side->file_hash ?? null) 31 | ->setSource($passport_element_error_front_side->source ?? null) 32 | ->setType($passport_element_error_front_side->type ?? null) 33 | ->setMessage($passport_element_error_front_side->message ?? null); 34 | } 35 | 36 | /** 37 | * @param null|string $file_hash 38 | * @return PassportElementErrorFrontSide 39 | */ 40 | public function setFileHash(?string $file_hash): PassportElementErrorInterface 41 | { 42 | $this->file_hash = $file_hash; 43 | return $this; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementErrorInterface.php: -------------------------------------------------------------------------------- 1 | setFileHash($passport_element_error_reverse_side->file_hash ?? null) 31 | ->setSource($passport_element_error_reverse_side->source ?? null) 32 | ->setType($passport_element_error_reverse_side->type ?? null) 33 | ->setMessage($passport_element_error_reverse_side->message ?? null); 34 | } 35 | 36 | /** 37 | * @param null|string $file_hash 38 | * @return PassportElementErrorReverseSide 39 | */ 40 | public function setFileHash(?string $file_hash): PassportElementErrorInterface 41 | { 42 | $this->file_hash = $file_hash; 43 | return $this; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementErrorSelfie.php: -------------------------------------------------------------------------------- 1 | setFileHash($passport_element_error_selfie->file_hash ?? null) 31 | ->setSource($passport_element_error_selfie->source ?? null) 32 | ->setType($passport_element_error_selfie->type ?? null) 33 | ->setMessage($passport_element_error_selfie->message ?? null); 34 | } 35 | 36 | /** 37 | * @param null|string $file_hash 38 | * @return PassportElementErrorSelfie 39 | */ 40 | public function setFileHash(?string $file_hash): PassportElementErrorInterface 41 | { 42 | $this->file_hash = $file_hash; 43 | return $this; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementErrorTranslationFile.php: -------------------------------------------------------------------------------- 1 | setFileHash($passport_element_error_translation_file->file_hash ?? null) 31 | ->setSource($passport_element_error_translation_file->source ?? null) 32 | ->setType($passport_element_error_translation_file->type ?? null) 33 | ->setMessage($passport_element_error_translation_file->message ?? null); 34 | } 35 | 36 | /** 37 | * @param null|string $file_hash 38 | * @return PassportElementErrorTranslationFile 39 | */ 40 | public function setFileHash(?string $file_hash): PassportElementErrorInterface 41 | { 42 | $this->file_hash = $file_hash; 43 | return $this; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementErrorTranslationFiles.php: -------------------------------------------------------------------------------- 1 | setFileHashes($passport_element_error_translation_files->file_hashes ?? null) 31 | ->setSource($passport_element_error_translation_files->source ?? null) 32 | ->setType($passport_element_error_translation_files->type ?? null) 33 | ->setMessage($passport_element_error_translation_files->message ?? null); 34 | } 35 | 36 | /** 37 | * @param array|null $file_hashes 38 | * @return PassportElementErrorTranslationFiles 39 | */ 40 | public function setFileHashes(?array $file_hashes): PassportElementErrorInterface 41 | { 42 | $this->file_hashes = $file_hashes; 43 | return $this; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportElementErrorUnspecified.php: -------------------------------------------------------------------------------- 1 | setElementHash($passport_element_error_unspecified->element_hash ?? null) 31 | ->setSource($passport_element_error_unspecified->source ?? null) 32 | ->setType($passport_element_error_unspecified->type ?? null) 33 | ->setMessage($passport_element_error_unspecified->message ?? null); 34 | } 35 | 36 | /** 37 | * @param null|string $element_hash 38 | * @return PassportElementErrorUnspecified 39 | */ 40 | public function setElementHash(?string $element_hash): PassportElementErrorInterface 41 | { 42 | $this->element_hash = $element_hash; 43 | return $this; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PassportFile.php: -------------------------------------------------------------------------------- 1 | setFileId($passport_file->file_id ?? null) 39 | ->setFileSize($passport_file->file_size ?? null) 40 | ->setFileDate($passport_file->file_date ?? null); 41 | } 42 | 43 | /** 44 | * @param int|null $file_date 45 | * @return PassportFile 46 | */ 47 | public function setFileDate(?int $file_date): self 48 | { 49 | $this->file_date = $file_date; 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param int|null $file_size 55 | * @return PassportFile 56 | */ 57 | public function setFileSize(?int $file_size): self 58 | { 59 | $this->file_size = $file_size; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $file_id 65 | * @return PassportFile 66 | */ 67 | public function setFileId(?string $file_id): self 68 | { 69 | $this->file_id = $file_id; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param array|null $passport_files 75 | * @return array|null 76 | */ 77 | public static function parsePassportFiles(?array $passport_files): ?array 78 | { 79 | if (is_null($passport_files)) { 80 | return null; 81 | } 82 | return array_map(['self', 'parsePassportFile'], $passport_files); 83 | } 84 | } -------------------------------------------------------------------------------- /src/Telegram/Types/PhotoSize.php: -------------------------------------------------------------------------------- 1 | setFileId($photo_size->file_id ?? null) 43 | ->setWidth($photo_size->width ?? null) 44 | ->setHeight($photo_size->height ?? null) 45 | ->setFileSize($photo_size->file_size ?? null); 46 | } 47 | 48 | /** 49 | * @param int|null $file_size 50 | * @return PhotoSize 51 | */ 52 | public function setFileSize(?int $file_size): self 53 | { 54 | $this->file_size = $file_size; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param int|null $height 60 | * @return PhotoSize 61 | */ 62 | public function setHeight(?int $height): self 63 | { 64 | $this->height = $height; 65 | return $this; 66 | } 67 | 68 | /** 69 | * @param int|null $width 70 | * @return PhotoSize 71 | */ 72 | public function setWidth(?int $width): self 73 | { 74 | $this->width = $width; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param null|string $file_id 80 | * @return PhotoSize 81 | */ 82 | public function setFileId(?string $file_id): self 83 | { 84 | $this->file_id = $file_id; 85 | return $this; 86 | } 87 | 88 | /** 89 | * @param array|null $photo_sizes 90 | * @return array|null 91 | */ 92 | public static function parsePhotoSizes(?array $photo_sizes): ?array 93 | { 94 | if (is_null($photo_sizes)) { 95 | return null; 96 | } 97 | return array_map(['self', 'parsePhotoSize'], $photo_sizes); 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /src/Telegram/Types/ReplyKeyboardMarkup.php: -------------------------------------------------------------------------------- 1 | setKeyboard($reply_keyboard_markup->keyboard ?? null) 43 | ->setResizeKeyboard($reply_keyboard_markup->resize_keyboard ?? false) 44 | ->setOneTimeKeyboard($reply_keyboard_markup->one_time_keyboard ?? false) 45 | ->setSelective($reply_keyboard_markup->selective ?? false); 46 | } 47 | 48 | /** 49 | * @param bool|null $selective 50 | * @return ReplyKeyboardMarkup 51 | */ 52 | public function setSelective(?bool $selective): self 53 | { 54 | $this->selective = $selective; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param bool|null $one_time_keyboard 60 | * @return ReplyKeyboardMarkup 61 | */ 62 | public function setOneTimeKeyboard(?bool $one_time_keyboard): self 63 | { 64 | $this->one_time_keyboard = $one_time_keyboard; 65 | return $this; 66 | } 67 | 68 | /** 69 | * @param bool|null $resize_keyboard 70 | * @return ReplyKeyboardMarkup 71 | */ 72 | public function setResizeKeyboard(?bool $resize_keyboard): self 73 | { 74 | $this->resize_keyboard = $resize_keyboard; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param array|null $keyboard 80 | * @return ReplyKeyboardMarkup 81 | */ 82 | public function setKeyboard(?array $keyboard): self 83 | { 84 | $this->keyboard = $keyboard; 85 | return $this; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/Telegram/Types/ReplyKeyboardRemove.php: -------------------------------------------------------------------------------- 1 | setRemoveKeyboard($reply_keyboard_remove->remove_keyboard ?? true) 35 | ->setSelective($reply_keyboard_remove->selective ?? false); 36 | } 37 | 38 | /** 39 | * @param bool|null $selective 40 | * @return ReplyKeyboardRemove 41 | */ 42 | public function setSelective(?bool $selective): self 43 | { 44 | $this->selective = $selective; 45 | return $this; 46 | } 47 | 48 | /** 49 | * @param bool|null $remove_keyboard 50 | * @return ReplyKeyboardRemove 51 | */ 52 | public function setRemoveKeyboard(?bool $remove_keyboard): self 53 | { 54 | $this->remove_keyboard = $remove_keyboard; 55 | return $this; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/Telegram/Types/ReplyMarkupInterface.php: -------------------------------------------------------------------------------- 1 | setOk($response->ok ?? null) 40 | ->setErrorCode($response->error_code ?? null) 41 | ->setDescription($response->description ?? null); 42 | if (empty($response->result)) { 43 | $parsed_response->setResult(null); 44 | } elseif (!empty($response->result->migrate_to_chat_id) or !empty($response->result->retry_after)) { 45 | $parsed_response->setResult(ResponseParameters::parseResponseParameters($response->result ?? null)); 46 | } elseif (!empty($response->result_type)) { 47 | $result_class = sprintf('TelegramBot\Telegram\Types\%s', $response->result_type->class); 48 | $parsed_response->setResult(call_user_func([$result_class, $response->result_type->method], 49 | $response->result ?? null)); 50 | } else { 51 | $parsed_response->setResult($response->result ?? null); 52 | } 53 | return $parsed_response; 54 | } 55 | 56 | /** 57 | * @param string $description 58 | * @return Response 59 | */ 60 | public function setDescription(?string $description): self 61 | { 62 | $this->description = $description; 63 | return $this; 64 | } 65 | 66 | /** 67 | * @param int $error_code 68 | * @return Response 69 | */ 70 | public function setErrorCode(?int $error_code): self 71 | { 72 | $this->error_code = $error_code; 73 | return $this; 74 | } 75 | 76 | /** 77 | * @param bool $ok 78 | * @return Response 79 | */ 80 | public function setOk(?bool $ok): self 81 | { 82 | $this->ok = $ok; 83 | return $this; 84 | } 85 | 86 | /** 87 | * @param mixed $result 88 | * @return Response 89 | */ 90 | public function setResult($result): self 91 | { 92 | $this->result = $result; 93 | return $this; 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /src/Telegram/Types/ResponseParameters.php: -------------------------------------------------------------------------------- 1 | setMigrateToChatId($response_parameters->migrate_to_chat_id ?? null) 35 | ->setRetryAfter($response_parameters->retry_after ?? null); 36 | } 37 | 38 | /** 39 | * @param int|null $retry_after 40 | * @return ResponseParameters 41 | */ 42 | public function setRetryAfter(?int $retry_after): self 43 | { 44 | $this->retry_after = $retry_after; 45 | return $this; 46 | } 47 | 48 | /** 49 | * @param int|null $migrate_to_chat_id 50 | * @return ResponseParameters 51 | */ 52 | public function setMigrateToChatId(?int $migrate_to_chat_id): self 53 | { 54 | $this->migrate_to_chat_id = $migrate_to_chat_id; 55 | return $this; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/Telegram/Types/ShippingOption.php: -------------------------------------------------------------------------------- 1 | setId($shipping_option->id ?? null) 39 | ->setTitle($shipping_option->title ?? null) 40 | ->setPrices(LabeledPrice::parseLabeledPrices($shipping_option->prices ?? null)); 41 | } 42 | 43 | /** 44 | * @param array|null $prices 45 | * @return ShippingOption 46 | */ 47 | public function setPrices(?array $prices): self 48 | { 49 | $this->prices = $prices; 50 | return $this; 51 | } 52 | 53 | /** 54 | * @param null|string $title 55 | * @return ShippingOption 56 | */ 57 | public function setTitle(?string $title): self 58 | { 59 | $this->title = $title; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $id 65 | * @return ShippingOption 66 | */ 67 | public function setId(?string $id): self 68 | { 69 | $this->id = $id; 70 | return $this; 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /src/Telegram/Types/ShippingQuery.php: -------------------------------------------------------------------------------- 1 | setId($shipping_query->id ?? null) 43 | ->setFrom(User::parseUser($shipping_query->from ?? null)) 44 | ->setInvoicePayload($shipping_query->invoice_payload ?? null) 45 | ->setShippingAddress(ShippingAddress::parseShippingAddress($shipping_query->shipping_address ?? null)); 46 | } 47 | 48 | /** 49 | * @param null|ShippingAddress $shipping_address 50 | * @return ShippingQuery 51 | */ 52 | public function setShippingAddress(?ShippingAddress $shipping_address): self 53 | { 54 | $this->shipping_address = $shipping_address; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param null|string $invoice_payload 60 | * @return ShippingQuery 61 | */ 62 | public function setInvoicePayload(?string $invoice_payload): self 63 | { 64 | $this->invoice_payload = $invoice_payload; 65 | return $this; 66 | } 67 | 68 | /** 69 | * @param null|User $from 70 | * @return ShippingQuery 71 | */ 72 | public function setFrom(?User $from): self 73 | { 74 | $this->from = $from; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param null|string $id 80 | * @return ShippingQuery 81 | */ 82 | public function setId(?string $id): self 83 | { 84 | $this->id = $id; 85 | return $this; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/Telegram/Types/StickerSet.php: -------------------------------------------------------------------------------- 1 | setName($sticker_set->name ?? null) 43 | ->setTitle($sticker_set->title ?? null) 44 | ->setContainsMasks($sticker_set->contains_masks ?? null) 45 | ->setStickers(Sticker::parseStickers($sticker_set->stickers ?? null)); 46 | } 47 | 48 | /** 49 | * @param array|null $stickers 50 | * @return StickerSet 51 | */ 52 | public function setStickers(?array $stickers): self 53 | { 54 | $this->stickers = $stickers; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param bool|null $contains_masks 60 | * @return StickerSet 61 | */ 62 | public function setContainsMasks(?bool $contains_masks): self 63 | { 64 | $this->contains_masks = $contains_masks; 65 | return $this; 66 | } 67 | 68 | /** 69 | * @param null|string $title 70 | * @return StickerSet 71 | */ 72 | public function setTitle(?string $title): self 73 | { 74 | $this->title = $title; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param null|string $name 80 | * @return StickerSet 81 | */ 82 | public function setName(?string $name): self 83 | { 84 | $this->name = $name; 85 | return $this; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/Telegram/Types/UserProfilePhotos.php: -------------------------------------------------------------------------------- 1 | photos = (array)$user_profile_photos->photos; 31 | if (is_null($user_profile_photos)) { 32 | return null; 33 | } 34 | return (new self()) 35 | ->setTotalCount($user_profile_photos->total_count ?? null) 36 | ->setPhotos(array_map(['PhotoSize', 'parsePhotoSizes'], $user_profile_photos->photos ?? null)); 37 | } 38 | 39 | /** 40 | * @param array|null $photos 41 | * @return UserProfilePhotos 42 | */ 43 | public function setPhotos(?array $photos): self 44 | { 45 | $this->photos = $photos; 46 | return $this; 47 | } 48 | 49 | /** 50 | * @param int|null $total_count 51 | * @return UserProfilePhotos 52 | */ 53 | public function setTotalCount(?int $total_count): self 54 | { 55 | $this->total_count = $total_count; 56 | return $this; 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /src/Telegram/Types/Venue.php: -------------------------------------------------------------------------------- 1 | setLocation(Location::parseLocation($venue->location ?? null)) 47 | ->setTitle($venue->title ?? null) 48 | ->setAddress($venue->address ?? null) 49 | ->setFoursquareId($venue->foursquare_id ?? null) 50 | ->setFoursquareType($venue->foursquare_type ?? null); 51 | } 52 | 53 | /** 54 | * @param null|string $foursquare_type 55 | * @return Venue 56 | */ 57 | public function setFoursquareType(?string $foursquare_type): self 58 | { 59 | $this->foursquare_type = $foursquare_type; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|string $foursquare_id 65 | * @return Venue 66 | */ 67 | public function setFoursquareId(?string $foursquare_id): self 68 | { 69 | $this->foursquare_id = $foursquare_id; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param null|string $address 75 | * @return Venue 76 | */ 77 | public function setAddress(?string $address): self 78 | { 79 | $this->address = $address; 80 | return $this; 81 | } 82 | 83 | /** 84 | * @param null|string $title 85 | * @return Venue 86 | */ 87 | public function setTitle(?string $title): self 88 | { 89 | $this->title = $title; 90 | return $this; 91 | } 92 | 93 | /** 94 | * @param null|Location $location 95 | * @return Venue 96 | */ 97 | public function setLocation(?Location $location): self 98 | { 99 | $this->location = $location; 100 | return $this; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/Telegram/Types/VideoNote.php: -------------------------------------------------------------------------------- 1 | setFileId($video_note->file_id ?? null) 47 | ->setLength($video_note->length ?? null) 48 | ->setDuration($video_note->duration ?? null) 49 | ->setThumb(PhotoSize::parsePhotoSize($video_note->thumb ?? null)) 50 | ->setFileSize($video_note->file_size ?? null); 51 | } 52 | 53 | /** 54 | * @param int|null $file_size 55 | * @return VideoNote 56 | */ 57 | public function setFileSize(?int $file_size): self 58 | { 59 | $this->file_size = $file_size; 60 | return $this; 61 | } 62 | 63 | /** 64 | * @param null|PhotoSize $thumb 65 | * @return VideoNote 66 | */ 67 | public function setThumb(?PhotoSize $thumb): self 68 | { 69 | $this->thumb = $thumb; 70 | return $this; 71 | } 72 | 73 | /** 74 | * @param int|null $duration 75 | * @return VideoNote 76 | */ 77 | public function setDuration(?int $duration): self 78 | { 79 | $this->duration = $duration; 80 | return $this; 81 | } 82 | 83 | /** 84 | * @param int|null $length 85 | * @return VideoNote 86 | */ 87 | public function setLength(?int $length): self 88 | { 89 | $this->length = $length; 90 | return $this; 91 | } 92 | 93 | /** 94 | * @param null|string $file_id 95 | * @return VideoNote 96 | */ 97 | public function setFileId(?string $file_id): self 98 | { 99 | $this->file_id = $file_id; 100 | return $this; 101 | } 102 | 103 | } -------------------------------------------------------------------------------- /src/Telegram/Types/Voice.php: -------------------------------------------------------------------------------- 1 | setFileId($voice->file_id ?? null) 43 | ->setDuration($voice->duration ?? null) 44 | ->setMimeType($voice->mime_type ?? null) 45 | ->setFileSize($voice->file_size ?? null); 46 | } 47 | 48 | /** 49 | * @param int|null $file_size 50 | * @return Voice 51 | */ 52 | public function setFileSize(?int $file_size): self 53 | { 54 | $this->file_size = $file_size; 55 | return $this; 56 | } 57 | 58 | /** 59 | * @param null|string $mime_type 60 | * @return Voice 61 | */ 62 | public function setMimeType(?string $mime_type): self 63 | { 64 | $this->mime_type = $mime_type; 65 | return $this; 66 | } 67 | 68 | /** 69 | * @param int|null $duration 70 | * @return Voice 71 | */ 72 | public function setDuration(?int $duration): self 73 | { 74 | $this->duration = $duration; 75 | return $this; 76 | } 77 | 78 | /** 79 | * @param null|string $file_id 80 | * @return Voice 81 | */ 82 | public function setFileId(?string $file_id): self 83 | { 84 | $this->file_id = $file_id; 85 | return $this; 86 | } 87 | 88 | } --------------------------------------------------------------------------------