Source code for pyrogram.raw.functions.bots.create_bot
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram 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.
#
# Pyrogram 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 Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from io import BytesIO
from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
from pyrogram.raw.core import TLObject
from pyrogram import raw
from typing import List, Optional, Any
# # # # # # # # # # # # # # # # # # # # # # # #
# !!! WARNING !!! #
# This is a generated file! #
# All changes made in this file will be lost! #
# # # # # # # # # # # # # # # # # # # # # # # #
[docs]
class CreateBot(TLObject): # type: ignore
"""Create a `managed bot » <https://core.telegram.org/api/bots/managed-bots#creating-a-managed-bot>`_ owned by the current user and controlled by the specified manager bot.
.. include:: /_includes/usable-by/users.rst
Details:
- Layer: ``229``
- ID: ``E5B17F2B``
Parameters:
name (``str``):
Display name of the bot, 1–64 characters
username (``str``):
Username for the bot, as validated by `bots.checkUsername <https://core.telegram.org/method/bots.checkUsername>`_
manager_id (:obj:`InputUser <pyrogram.raw.base.InputUser>`):
The manager bot that will control the created bot; must have the `user <https://core.telegram.org/constructor/user>`_. ``bot_can_manage_bots`` flag set
via_deeplink (``bool``, *optional*):
Set only if the creation prompt was opened from a `managed bot creation request deep link » <https://core.telegram.org/api/links#managed-bot-creation-request-links>`_
Returns:
:obj:`User <pyrogram.raw.base.User>`
"""
__slots__: List[str] = ["name", "username", "manager_id", "via_deeplink"]
ID = 0xe5b17f2b
QUALNAME = "functions.bots.CreateBot"
def __init__(self, *, name: str, username: str, manager_id: "raw.base.InputUser", via_deeplink: Optional[bool] = None) -> None:
self.name = name # string
self.username = username # string
self.manager_id = manager_id # InputUser
self.via_deeplink = via_deeplink # flags.0?true
@staticmethod
def read(b: BytesIO, *args: Any) -> "CreateBot":
flags = Int.read(b)
via_deeplink = True if flags & (1 << 0) else False
name = String.read(b)
username = String.read(b)
manager_id = TLObject.read(b)
return CreateBot(name=name, username=username, manager_id=manager_id, via_deeplink=via_deeplink)
def write(self, *args) -> bytes:
b = BytesIO()
b.write(Int(self.ID, False))
flags = 0
flags |= (1 << 0) if self.via_deeplink else 0
b.write(Int(flags))
b.write(String(self.name))
b.write(String(self.username))
b.write(self.manager_id.write())
return b.getvalue()