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

Fix update_folders method #131

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

Danipulok
Copy link

What this PR does?

Updates update_folders method to make it work (currently, it fails).

MRE:

import asyncio

from pyrogram import Client, raw


async def main() -> None:
    client = Client(
        name="account",
        api_id=8,
        api_hash="7245de8e747a0d6fbe11f7cc14fcc0bb",
    )

    await client.start()

    await client.update_folder(
        folder_id=13,
        title="NEW_NAME",
        included_chats=["me"],
    )

    await client.stop()


if __name__ == "__main__":
    loop = asyncio.new_event_loop()
    loop.run_until_complete(main())

Current traceback:

Traceback (most recent call last):
  File "D:\Code\Personal\pyrogram\mre.py", line 35, in <module>
    loop.run_until_complete(main())
  File "C:\Program Files\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "D:\Code\Personal\pyrogram\mre.py", line 25, in main
    await client.update_folder(
  File "D:\Code\Personal\pyrogram\.venv\Lib\site-packages\pyrogram\methods\chats\update_folder.py", line 116, in update_folder
    r = await self.invoke(
        ^^^^^^^^^^^^^^^^^^
  File "D:\Code\Personal\pyrogram\.venv\Lib\site-packages\pyrogram\methods\advanced\invoke.py", line 94, in invoke
    r = await session.invoke(
        ^^^^^^^^^^^^^^^^^^^^^
  File "D:\Code\Personal\pyrogram\.venv\Lib\site-packages\pyrogram\session\session.py", line 406, in invoke
    return await self.send(query, timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Code\Personal\pyrogram\.venv\Lib\site-packages\pyrogram\session\session.py", line 335, in send
    message = self.msg_factory(data)
              ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Code\Personal\pyrogram\.venv\Lib\site-packages\pyrogram\session\internals\msg_factory.py", line 37, in __call__
    len(body)
  File "D:\Code\Personal\pyrogram\.venv\Lib\site-packages\pyrogram\raw\core\tl_object.py", line 79, in __len__
    return len(self.write())
               ^^^^^^^^^^^^
  File "D:\Code\Personal\pyrogram\.venv\Lib\site-packages\pyrogram\raw\functions\messages\update_dialog_filter.py", line 82, in write
    b.write(self.filter.write())
            ^^^^^^^^^^^^^^^^^^^
  File "D:\Code\Personal\pyrogram\.venv\Lib\site-packages\pyrogram\raw\types\dialog_filter.py", line 164, in write
    b.write(self.title.write())
            ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'write'

New behavior:

Process finished with exit code 0

@KurimuzonAkuma KurimuzonAkuma merged commit 35abba3 into KurimuzonAkuma:dev Jan 27, 2025
12 checks passed
@Danipulok Danipulok deleted the fix/update-folders branch January 28, 2025 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants