Source code for pyrogram.raw.functions.aicompose.create_tone
# 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 CreateTone(TLObject): # type: ignore
"""Create a new custom `AI composer tone » <https://core.telegram.org/api/ai#ai-compose-tones>`_.
.. include:: /_includes/usable-by/users.rst
Details:
- Layer: ``229``
- ID: ``4AA83913``
Parameters:
emoji_id (``int`` ``64-bit``):
`Custom emoji ID <https://core.telegram.org/api/custom-emoji>`_ of the tone's icon
title (``str``):
Human-readable tone name, up to `aicompose_tone_title_length_max » <https://core.telegram.org/api/config#aicompose-tone-title-length-max>`_ UTF-8 characters long
prompt (``str``):
The prompt that describes how the AI should rephrase messages using this tone, up to `aicompose_tone_prompt_length_max » <https://core.telegram.org/api/config#aicompose-tone-prompt-length-max>`_ UTF-8 characters long
display_author (``bool``, *optional*):
If set, the current user will be publicly credited as the author of the tone
Returns:
:obj:`AiComposeTone <pyrogram.raw.base.AiComposeTone>`
"""
__slots__: List[str] = ["emoji_id", "title", "prompt", "display_author"]
ID = 0x4aa83913
QUALNAME = "functions.aicompose.CreateTone"
def __init__(self, *, emoji_id: int, title: str, prompt: str, display_author: Optional[bool] = None) -> None:
self.emoji_id = emoji_id # long
self.title = title # string
self.prompt = prompt # string
self.display_author = display_author # flags.0?true
@staticmethod
def read(b: BytesIO, *args: Any) -> "CreateTone":
flags = Int.read(b)
display_author = True if flags & (1 << 0) else False
emoji_id = Long.read(b)
title = String.read(b)
prompt = String.read(b)
return CreateTone(emoji_id=emoji_id, title=title, prompt=prompt, display_author=display_author)
def write(self, *args) -> bytes:
b = BytesIO()
b.write(Int(self.ID, False))
flags = 0
flags |= (1 << 0) if self.display_author else 0
b.write(Int(flags))
b.write(Long(self.emoji_id))
b.write(String(self.title))
b.write(String(self.prompt))
return b.getvalue()