Add GetFile method to fetch file details from Telegram API
This commit is contained in:
parent
44260ccaee
commit
3cac471f1e
2 changed files with 41 additions and 0 deletions
|
@ -11,6 +11,7 @@
|
||||||
use TgBotLib\Methods\DeleteWebhook;
|
use TgBotLib\Methods\DeleteWebhook;
|
||||||
use TgBotLib\Methods\ForwardMessage;
|
use TgBotLib\Methods\ForwardMessage;
|
||||||
use TgBotLib\Methods\ForwardMessages;
|
use TgBotLib\Methods\ForwardMessages;
|
||||||
|
use TgBotLib\Methods\GetFile;
|
||||||
use TgBotLib\Methods\GetMe;
|
use TgBotLib\Methods\GetMe;
|
||||||
use TgBotLib\Methods\GetUpdates;
|
use TgBotLib\Methods\GetUpdates;
|
||||||
use TgBotLib\Methods\GetUserProfilePhotos;
|
use TgBotLib\Methods\GetUserProfilePhotos;
|
||||||
|
@ -66,6 +67,7 @@
|
||||||
case SEND_CHAT_ACTION = 'sendChatAction';
|
case SEND_CHAT_ACTION = 'sendChatAction';
|
||||||
case SET_MESSAGE_REACTION = 'setMessageReaction';
|
case SET_MESSAGE_REACTION = 'setMessageReaction';
|
||||||
case GET_USER_PROFILE_PHOTOS = 'getUserProfilePhotos';
|
case GET_USER_PROFILE_PHOTOS = 'getUserProfilePhotos';
|
||||||
|
case GET_FILE = 'getFile';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a command on the provided bot with the given parameters.
|
* Executes a command on the provided bot with the given parameters.
|
||||||
|
@ -108,6 +110,7 @@
|
||||||
self::SEND_CHAT_ACTION => SendChatAction::execute($bot, $parameters),
|
self::SEND_CHAT_ACTION => SendChatAction::execute($bot, $parameters),
|
||||||
self::SET_MESSAGE_REACTION => SetMessageReaction::execute($bot, $parameters),
|
self::SET_MESSAGE_REACTION => SetMessageReaction::execute($bot, $parameters),
|
||||||
self::GET_USER_PROFILE_PHOTOS => GetUserProfilePhotos::execute($bot, $parameters),
|
self::GET_USER_PROFILE_PHOTOS => GetUserProfilePhotos::execute($bot, $parameters),
|
||||||
|
self::GET_FILE => GetFile::execute($bot, $parameters),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
38
src/TgBotLib/Methods/GetFile.php
Normal file
38
src/TgBotLib/Methods/GetFile.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TgBotLib\Methods;
|
||||||
|
|
||||||
|
use TgBotLib\Abstracts\Method;
|
||||||
|
use TgBotLib\Bot;
|
||||||
|
use TgBotLib\Enums\Methods;
|
||||||
|
use TgBotLib\Objects\File;
|
||||||
|
|
||||||
|
class GetFile extends Method
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function execute(Bot $bot, array $parameters = []): File
|
||||||
|
{
|
||||||
|
return File::fromArray($bot->sendRequest(Methods::GET_FILE->value, $parameters));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getRequiredParameters(): ?array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'file_id'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public static function getOptionalParameters(): ?array
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue