Add SetMyName method for configuring bot name

This commit is contained in:
netkas 2024-11-13 15:23:40 -05:00
parent c1d515de0c
commit d6f13f3177
2 changed files with 41 additions and 0 deletions

View file

@ -76,6 +76,7 @@
use TgBotLib\Methods\SetChatTitle;
use TgBotLib\Methods\SetMessageReaction;
use TgBotLib\Methods\SetMyCommands;
use TgBotLib\Methods\SetMyName;
use TgBotLib\Methods\SetWebhook;
use TgBotLib\Methods\UnbanChatMember;
use TgBotLib\Methods\UnbanChatSenderChat;
@ -166,6 +167,7 @@
case SET_MY_COMMANDS = 'setMyCommands';
case DELETE_MY_COMMANDS = 'deleteMyCommands';
case GET_MY_COMMANDS = 'getMyCommands';
case SET_MY_NAME = 'setMyName';
/**
* Executes a command on the provided bot with the given parameters.
@ -258,6 +260,7 @@
self::SET_MY_COMMANDS => SetMyCommands::execute($bot, $parameters),
self::DELETE_MY_COMMANDS => DeleteMyCommands::execute($bot, $parameters),
self::GET_MY_COMMANDS => GetMyCommands::execute($bot, $parameters),
self::SET_MY_NAME => SetMyName::execute($bot, $parameters),
};
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace TgBotLib\Methods;
use TgBotLib\Abstracts\Method;
use TgBotLib\Bot;
use TgBotLib\Enums\Methods;
class SetMyName extends Method
{
/**
* @inheritDoc
*/
public static function execute(Bot $bot, array $parameters = []): true
{
return (bool)self::executeCurl(self::buildPost($bot, Methods::SET_MY_NAME->value, $parameters));
}
/**
* @inheritDoc
*/
public static function getRequiredParameters(): ?array
{
return null;
}
/**
* @inheritDoc
*/
public static function getOptionalParameters(): ?array
{
return [
'name',
'language_code'
];
}
}