Skip to content

Commit e5f0216

Browse files
fix: make to_language_code optional in translation methods
1 parent e7f1d90 commit e5f0216

4 files changed

Lines changed: 11 additions & 12 deletions

File tree

pyrogram/enums/message_origin_type.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ class MessageOriginType(AutoName):
3636
IMPORT = auto()
3737
"The message was imported from a foreign chat service"
3838

39-
4039
USER = auto()
4140
"The message was originally sent by a known user"

pyrogram/methods/messages/compose_text_with_ai.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ async def compose_text_with_ai(
5555
Returns:
5656
:obj:`~pyrogram.types.FormattedText`: On success, information about the composed text is returned.
5757
58-
Example:
59-
.. code-block:: python
60-
61-
await app.compose_text_with_ai(
58+
Example:
59+
.. code-block:: python
60+
61+
await app.compose_text_with_ai(
6262
"hello, how are you?",
6363
translate_to_language_code="ru",
6464
style_name="formal",
65-
add_emojis=True
65+
add_emojis=True
6666
)
6767
"""
6868
if isinstance(text, str):

pyrogram/methods/messages/translate_message_text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async def translate_message_text(
2727
self: "pyrogram.Client",
2828
chat_id: str,
2929
message_id: int,
30-
to_language_code: str,
30+
to_language_code: Optional[str] = None,
3131
tone: Optional[str] = None
3232
) -> "types.FormattedText":
3333
"""Extract text or caption of the given message and translates it to the given language.
@@ -45,7 +45,7 @@ async def translate_message_text(
4545
message_id (``int``):
4646
Identifier of the message.
4747
48-
to_language_code (``str``):
48+
to_language_code (``str``, *optional*):
4949
Language code of the language to which the message is translated.
5050
Must be one of "af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et",
5151
"fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko",

pyrogram/methods/messages/translate_text.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from typing import List, Optional, Union
19+
from typing import Optional, Union
2020

2121
import pyrogram
22-
from pyrogram import enums, raw, types, utils
22+
from pyrogram import raw, types
2323

2424

2525
class TranslateText:
2626
async def translate_text(
2727
self: "pyrogram.Client",
2828
text: Union[str, "types.FormattedText"],
29-
to_language_code: str,
29+
to_language_code: Optional[str] = None,
3030
tone: Optional[str] = None,
3131
) -> "types.FormattedText":
3232
"""Translate a text to the given language.
@@ -39,7 +39,7 @@ async def translate_text(
3939
text (``str`` | :obj:`~pyrogram.types.FormattedText`):
4040
Text to translate.
4141
42-
to_language_code (``str``):
42+
to_language_code (``str``, *optional*):
4343
Language code of the language to which the message is translated.
4444
Must be one of "af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et",
4545
"fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko",

0 commit comments

Comments
 (0)