mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-04 14:24:51 +00:00
Pyrofork: Add get_bot_info and set_bot_info method
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
654076edd4
commit
34fcefe534
6 changed files with 171 additions and 0 deletions
|
|
@ -334,6 +334,8 @@ def pyrogram_api():
|
||||||
set_chat_menu_button
|
set_chat_menu_button
|
||||||
get_chat_menu_button
|
get_chat_menu_button
|
||||||
answer_web_app_query
|
answer_web_app_query
|
||||||
|
get_bot_info
|
||||||
|
set_bot_info
|
||||||
""",
|
""",
|
||||||
authorization="""
|
authorization="""
|
||||||
Authorization
|
Authorization
|
||||||
|
|
@ -420,6 +422,7 @@ def pyrogram_api():
|
||||||
ForumTopic
|
ForumTopic
|
||||||
PeerUser
|
PeerUser
|
||||||
PeerChannel
|
PeerChannel
|
||||||
|
BotInfo
|
||||||
""",
|
""",
|
||||||
messages_media="""
|
messages_media="""
|
||||||
Messages & Media
|
Messages & Media
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ from .answer_web_app_query import AnswerWebAppQuery
|
||||||
from .delete_bot_commands import DeleteBotCommands
|
from .delete_bot_commands import DeleteBotCommands
|
||||||
from .get_bot_commands import GetBotCommands
|
from .get_bot_commands import GetBotCommands
|
||||||
from .get_bot_default_privileges import GetBotDefaultPrivileges
|
from .get_bot_default_privileges import GetBotDefaultPrivileges
|
||||||
|
from .get_bot_info import GetBotInfo
|
||||||
from .get_chat_menu_button import GetChatMenuButton
|
from .get_chat_menu_button import GetChatMenuButton
|
||||||
from .get_game_high_scores import GetGameHighScores
|
from .get_game_high_scores import GetGameHighScores
|
||||||
from .get_inline_bot_results import GetInlineBotResults
|
from .get_inline_bot_results import GetInlineBotResults
|
||||||
|
|
@ -30,6 +31,7 @@ from .send_game import SendGame
|
||||||
from .send_inline_bot_result import SendInlineBotResult
|
from .send_inline_bot_result import SendInlineBotResult
|
||||||
from .set_bot_commands import SetBotCommands
|
from .set_bot_commands import SetBotCommands
|
||||||
from .set_bot_default_privileges import SetBotDefaultPrivileges
|
from .set_bot_default_privileges import SetBotDefaultPrivileges
|
||||||
|
from .set_bot_info import SetBotInfo
|
||||||
from .set_chat_menu_button import SetChatMenuButton
|
from .set_chat_menu_button import SetChatMenuButton
|
||||||
from .set_game_score import SetGameScore
|
from .set_game_score import SetGameScore
|
||||||
|
|
||||||
|
|
@ -48,6 +50,8 @@ class Bots(
|
||||||
DeleteBotCommands,
|
DeleteBotCommands,
|
||||||
SetBotDefaultPrivileges,
|
SetBotDefaultPrivileges,
|
||||||
GetBotDefaultPrivileges,
|
GetBotDefaultPrivileges,
|
||||||
|
SetBotInfo,
|
||||||
|
GetBotInfo,
|
||||||
SetChatMenuButton,
|
SetChatMenuButton,
|
||||||
GetChatMenuButton,
|
GetChatMenuButton,
|
||||||
AnswerWebAppQuery
|
AnswerWebAppQuery
|
||||||
|
|
|
||||||
49
pyrogram/methods/bots/get_bot_info.py
Normal file
49
pyrogram/methods/bots/get_bot_info.py
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrofork.
|
||||||
|
#
|
||||||
|
# Pyrofork is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrofork is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
|
||||||
|
|
||||||
|
class GetBotInfo:
|
||||||
|
async def get_bot_info(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
lang_code: str,
|
||||||
|
bot: Union[int, str] = None
|
||||||
|
) -> pyrogram.types.BotInfo:
|
||||||
|
"""Get the bot info in given language.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users-bots.rst
|
||||||
|
|
||||||
|
Note:
|
||||||
|
For normal bot you can only use this method to self.
|
||||||
|
For userbot you can only use this method if you are the owner of target bot.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
lang_code ``str``:
|
||||||
|
A two-letter ISO 639-1 language code.
|
||||||
|
bot (``int`` | ``str``, *optional*):
|
||||||
|
Unique identifier (int) or username (str) of the target bot.
|
||||||
|
"""
|
||||||
|
peer = None
|
||||||
|
if bot:
|
||||||
|
peer = await self.resolve_peer(bot)
|
||||||
|
r = await self.invoke(raw.functions.bots.GetBotInfo(lang_code=lang_code, bot=peer))
|
||||||
|
return pyrogram.types.BotInfo._parse(r)
|
||||||
61
pyrogram/methods/bots/set_bot_info.py
Normal file
61
pyrogram/methods/bots/set_bot_info.py
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrofork.
|
||||||
|
#
|
||||||
|
# Pyrofork is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrofork is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
|
from pyrogram import raw
|
||||||
|
|
||||||
|
|
||||||
|
class SetBotInfo:
|
||||||
|
async def set_bot_info(
|
||||||
|
self: "pyrogram.Client",
|
||||||
|
lang_code: str,
|
||||||
|
bot: Union[int, str] = None,
|
||||||
|
name: str = None,
|
||||||
|
about: str = None,
|
||||||
|
description: str = None
|
||||||
|
) -> bool:
|
||||||
|
"""Get the bot info in given language.
|
||||||
|
|
||||||
|
.. include:: /_includes/usable-by/users-bots.rst
|
||||||
|
|
||||||
|
Note:
|
||||||
|
For normal bot you can only use this method to self.
|
||||||
|
For userbot you can only use this method if you are the owner of target bot.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
lang_code ``str``:
|
||||||
|
A two-letter ISO 639-1 language code.
|
||||||
|
bot (``int`` | ``str``, *optional*) :
|
||||||
|
Unique identifier (int) or username (str) of the target bot.
|
||||||
|
|
||||||
|
name (``str``, *optional*):
|
||||||
|
The bot name.
|
||||||
|
|
||||||
|
about (``str``, *optional*):
|
||||||
|
The bot bio.
|
||||||
|
|
||||||
|
description (``str``, *optional*):
|
||||||
|
Description of the bot;
|
||||||
|
"""
|
||||||
|
peer = None
|
||||||
|
if bot:
|
||||||
|
peer = await self.resolve_peer(bot)
|
||||||
|
r = await self.invoke(raw.functions.bots.SetBotInfo(lang_code=lang_code, bot=peer, name=name, about=about, description=description))
|
||||||
|
return bool(r)
|
||||||
|
|
@ -25,6 +25,7 @@ from .bot_command_scope_chat import BotCommandScopeChat
|
||||||
from .bot_command_scope_chat_administrators import BotCommandScopeChatAdministrators
|
from .bot_command_scope_chat_administrators import BotCommandScopeChatAdministrators
|
||||||
from .bot_command_scope_chat_member import BotCommandScopeChatMember
|
from .bot_command_scope_chat_member import BotCommandScopeChatMember
|
||||||
from .bot_command_scope_default import BotCommandScopeDefault
|
from .bot_command_scope_default import BotCommandScopeDefault
|
||||||
|
from .bot_info import BotInfo
|
||||||
from .callback_game import CallbackGame
|
from .callback_game import CallbackGame
|
||||||
from .callback_query import CallbackQuery
|
from .callback_query import CallbackQuery
|
||||||
from .force_reply import ForceReply
|
from .force_reply import ForceReply
|
||||||
|
|
@ -68,6 +69,7 @@ __all__ = [
|
||||||
"BotCommandScopeChatAdministrators",
|
"BotCommandScopeChatAdministrators",
|
||||||
"BotCommandScopeChatMember",
|
"BotCommandScopeChatMember",
|
||||||
"BotCommandScopeDefault",
|
"BotCommandScopeDefault",
|
||||||
|
"BotInfo",
|
||||||
"WebAppInfo",
|
"WebAppInfo",
|
||||||
"MenuButton",
|
"MenuButton",
|
||||||
"MenuButtonCommands",
|
"MenuButtonCommands",
|
||||||
|
|
|
||||||
52
pyrogram/types/bots_and_keyboards/bot_info.py
Normal file
52
pyrogram/types/bots_and_keyboards/bot_info.py
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
# Pyrofork - Telegram MTProto API Client Library for Python
|
||||||
|
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
|
||||||
|
#
|
||||||
|
# This file is part of Pyrofork.
|
||||||
|
#
|
||||||
|
# Pyrofork is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published
|
||||||
|
# by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Pyrofork is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Lesser General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from pyrogram import raw
|
||||||
|
|
||||||
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
|
class BotInfo(Object):
|
||||||
|
"""A bot Information.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
name (``str``):
|
||||||
|
The bot name.
|
||||||
|
|
||||||
|
about (``str``):
|
||||||
|
The bot bio.
|
||||||
|
|
||||||
|
description (``str``):
|
||||||
|
Description of the bot;
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, name: str, about: str, description: str):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.name = name
|
||||||
|
self.about = about
|
||||||
|
self.description = description
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _parse(bot_info: "raw.types.bots.BotInfo") -> "BotInfo":
|
||||||
|
return BotInfo(
|
||||||
|
name=getattr(bot_info,"name", None),
|
||||||
|
about=getattr(bot_info,"about", None),
|
||||||
|
description=getattr(bot_info,"description", None)
|
||||||
|
)
|
||||||
Loading…
Reference in a new issue