Svoboda | Graniru | BBC Russia | Golosameriki | Facebook
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get similar channels implementation for raw usage #1441

Closed
2 tasks done
kewldan opened this issue Jul 18, 2024 · 1 comment
Closed
2 tasks done

Get similar channels implementation for raw usage #1441

kewldan opened this issue Jul 18, 2024 · 1 comment

Comments

@kewldan
Copy link

kewldan commented Jul 18, 2024

Checklist

  • I believe the idea is awesome and would benefit the framework
  • I have searched in the issue tracker for similar requests, including closed ones

Description

I have tried to write method for myself, but when pyrogram receive response it crash. (ValueError: The server sent an unknown constructor: 0x8e87ccd8)

API link: https://core.telegram.org/api/recommend

My code for get_channel_recommendations.py:

from io import BytesIO
from typing import List, Any

from pyrogram import raw
from pyrogram.raw.core import TLObject
from pyrogram.raw.core.primitives import Int


class GetChannelRecommendations(TLObject):  # type: ignore
    """Telegram API function.

    Details:
        - Layer: ``170``
        - ID: ``83b70d97``

    Parameters:
        channel (:obj:`InputChannel <pyrogram.raw.base.InputChannel>`):
            N/A

    Returns:
        :obj:`messages.Chats <pyrogram.raw.base.messages.Chats>`
    """

    __slots__: List[str] = ["channel"]

    ID = 0x83b70d97
    QUALNAME = "functions.channels.GetChannelRecommendations"

    def __init__(self, *, channel: "raw.base.InputChannel") -> None:
        self.channel = channel  # InputChannel

    @staticmethod
    def read(b: BytesIO, *args: Any) -> "GetChannelRecommendations":
        channel = TLObject.read(b)
        return GetChannelRecommendations(channel=channel)

    def write(self, *args) -> bytes:
        b = BytesIO()
        b.write(Int(self.ID, False))

        b.write(self.channel.write())

        return b.getvalue()
@kewldan
Copy link
Author

kewldan commented Jul 26, 2024

just use pyrofork.

@kewldan kewldan closed this as completed Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant