GithubHelp home page GithubHelp logo

mayuri-chan / pyrofork Goto Github PK

View Code? Open in Web Editor NEW
126.0 5.0 67.0 9.24 MB

Pyrogram fork with Adjustable web page preview, Quote Reply, Story & Topics Support, Mongodb session storage, and much more. go to https://pyrofork.mayuri.my.id/ for documentation.

Home Page: https://pyrofork.mayuri.my.id

License: GNU Lesser General Public License v3.0

Makefile 0.04% Python 99.91% Shell 0.05%
mtproto pyrogram python python3 telegram telegram-api telegram-bot pyrofork

pyrofork's Introduction

Pyrofork
Telegram MTProto API Framework for Python
Homepage Documentation Issues Support Chat News/Releases

Pyrofork

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots

from pyrogram import Client, filters

app = Client("my_account")


@app.on_message(filters.private)
async def hello(client, message):
    await message.reply("Hello from Pyrofork!")


app.run()

Pyrofork is a modern, elegant and asynchronous MTProto API framework. It enables you to easily interact with the main Telegram API through a user account (custom client) or a bot identity (bot API alternative) using Python.

Support

If you'd like to support Pyrofork, you can consider:

Key Features

  • Ready: Install Pyrofork with pip and start building your applications right away.
  • Easy: Makes the Telegram API simple and intuitive, while still allowing advanced usages.
  • Elegant: Low-level details are abstracted and re-presented in a more convenient way.
  • Fast: Boosted up by TgCrypto, a high-performance cryptography library written in C.
  • Type-hinted: Types and methods are all type-hinted, enabling excellent editor support.
  • Async: Fully asynchronous (also usable synchronously if wanted, for convenience).
  • Powerful: Full access to Telegram's API to execute any official client action and more.

Installing

pip3 install pyrofork

Resources

  • Check out the docs at https://pyrofork.mayuri.my.id to learn more about Pyrofork, get started right away and discover more in-depth material for building your client applications.
  • Join the official group at https://t.me/MayuriChan_Chat and stay tuned for news, updates and announcements.

pyrofork's People

Contributors

1pyxa1 avatar alissonlauffer avatar bakatrouble avatar colinshark avatar customicon avatar cyanbook avatar delivrance avatar dependabot[bot] avatar furoin avatar hitalom avatar jonatan1609 avatar josxa avatar kalmengr avatar kurimuzonakuma avatar mahesh0253 avatar mendelmaleh avatar mrmissx avatar mrnaif2018 avatar null-nick avatar octonezd avatar princic-1837592 avatar ripeey avatar shivangkakkar avatar spechide avatar teriks avatar trenoduro avatar wulan17 avatar x1a0ca1 avatar yasirarism avatar yoilyl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pyrofork's Issues

[Request]: send spoiler media using file id.

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

await client.send_video("me", fileid, has_spoiler=True)

:(
it's a missing feature.

[400 AUTH_BYTES_INVALID]

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/Mayuri-Chan/pyrofork/archive/master.zip and reproduced the issue using the latest development version

Description

kemaren2 gak error begini tapi skrng sering muncul,
pyrofork latest 2.3.11post2

Steps to reproduce

  1. userbot
  2. entah

Code example

from pyrogram import Client, utils, raw
from pyrogram.types import Message
from pyrogram.session import Session, Auth
from pyrogram.errors import AuthBytesInvalid,FloodWait

async def generate_media_session(self, client: Client, msg: Message):
        data = await self.generate_file_properties(msg)

        media_session = client.media_sessions.get(data.dc_id, None)

        if media_session is None:
            if data.dc_id != await client.storage.dc_id():
                media_session = Session(client, data.dc_id, await Auth(client, data.dc_id, await client.storage.test_mode()).create(), await client.storage.test_mode(), is_media=True)
                await media_session.start()

                for _ in range(5):
                    exported_auth = await client.invoke(raw.functions.auth.ExportAuthorization(dc_id=data.dc_id))

                    try:
                        await media_session.invoke(
                            raw.functions.auth.ImportAuthorization(
                                id=exported_auth.id,
                                bytes=exported_auth.bytes,
                            )
                        )
                    except AuthBytesInvalid:
                        continue
                    except FloodWait as e:
                        LOGGER.info(f"FloodWait when generate_media_session, value: {f.value}")
                        await asyncio.sleep(e.value)
                        await media_session.invoke(
                            raw.functions.auth.ImportAuthorization(
                                id=exported_auth.id,
                                bytes=exported_auth.bytes,
                            )
                        )
                    else:
                        break
                else:
                    await media_session.stop()
                    raise AuthBytesInvalid
            else:
                media_session = Session(client, data.dc_id, await client.storage.auth_key(), await client.storage.test_mode(), is_media=True)
                await media_session.start()

            client.media_sessions[data.dc_id] = media_session

        return media_session

Logs

Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/pyrogram/client.py", line 1048, in get_file
    await session.invoke(
  File "/venv/lib/python3.10/site-packages/pyrogram/session/session.py", line 402, in invoke
    return await self.send(query, timeout=timeout)
  File "/venv/lib/python3.10/site-packages/pyrogram/session/session.py", line 359, in send
    RPCError.raise_it(result, type(data))
  File "/venv/lib/python3.10/site-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it
    raise getattr(
pyrogram.errors.exceptions.bad_request_400.AuthBytesInvalid: Telegram says: [400 AUTH_BYTES_INVALID] - The authorization bytes are invalid (caused by "auth.ImportAuthorization")

Feature request

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

If possible, add description and thumb in InlineResultAudio, in telethon we can add description for audio result in inline

message.photo not working

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/Mayuri-Chan/pyrofork/archive/master.zip and reproduced the issue using the latest development version

Description

message.photo not working

Steps to reproduce

message.photo not working

Code example

message.photo  not working

Logs

No response

can't print story

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

see code example

Steps to reproduce

see code example

Code example

import pyrogram.client
import pyrogram.types
import asyncio


async def main():
    client = pyrogram.client.Client(
        name='tg_bot',
    )
    await client.start()
    msg = await client.get_messages(
        chat_id='@autotests_source',
        message_ids=121,
    )
    assert isinstance(msg, pyrogram.types.Message)
    print(msg.story.__dict__) # works
    print(msg.story) # throws error


asyncio.run(main())

Logs

.venv/bin/python test.py
Traceback (most recent call last):
  File "/var/home/hmk/proj/test/test.py", line 20, in <module>
    asyncio.run(main())
  File "/usr/lib64/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/var/home/hmk/proj/test/test.py", line 17, in main
    print(msg.story)
  File "/var/home/hmk/proj/test/.venv/lib64/python3.12/site-packages/pyrogram/types/object.py", line 83, in __str__
    return dumps(self, indent=4, default=Object.default, ensure_ascii=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/encoder.py", line 202, in encode
    chunks = list(chunks)
             ^^^^^^^^^^^^
  File "/usr/lib64/python3.12/json/encoder.py", line 440, in _iterencode
    yield from _iterencode(o, _current_indent_level)
  File "/usr/lib64/python3.12/json/encoder.py", line 432, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib64/python3.12/json/encoder.py", line 406, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.12/json/encoder.py", line 439, in _iterencode
    o = _default(o)
        ^^^^^^^^^^^
  File "/var/home/hmk/proj/test/.venv/lib64/python3.12/site-packages/pyrogram/types/object.py", line 72, in default
    obj.__dict__,
    ^^^^^^^^^^^^
AttributeError: 'Chats' object has no attribute '__dict__'. Did you mean: '__dir__'?

[feature request] Add Error handler

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

As a user of PyroFork, I would like to see improved error handling.

Parallel download

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/Mayuri-Chan/pyrofork/archive/master.zip and reproduced the issue using the latest development version

Description

In previous version like, 2.2.10 or less, it was download multiple file in parallel, but now, it's download one after one. I hope you will revert download function

Steps to reproduce

.

Code example

.

Logs

No response

Multiple target chats

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

Add way to forward message to multiple chats at time, as in telegram app

synchronous usage broken

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

there is a synchronous useage guide in docs - https://pyrofork.mayuri.my.id/main/topics/synchronous.html

when i run the code it runs, throws no errors, but there are no any sent messages

Steps to reproduce

  1. copy code from synchronous usage guide
  2. run the code
  3. see that message was not sent

Code example

from pyrogram import Client

app = Client("my_account")

with app:
    app.send_message("me", "Hi!")
    print('sent')

Logs

.venv/bin/python test.py
sent

Premium FLOOD WAIT ERROR ✓✓

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

[ERROR/2024-06-10 00:48:32,509] pyrogram.client: Telegram says: [420 FLOOD_PREMIUM_WAIT_X] - A wait of 15 seconds is required (caused by "upload.GetFile")2024-06-10T00:48:32.510368+00:00 app[.1]: Traceback (most recent call last):2024-06-10T00:48:32.510368+00:00 app[.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pyrogram/client.py", line 1007, in get_file2024-06-10T00:48:32.510369+00:00 app[.1]: r = await session.invoke(2024-06-10T00:48:32.510369+00:00 app[.1]: ^^^^^^^^^^^^^^^^^^^^^2024-06-10T00:48:32.510369+00:00 app[.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pyrogram/session/session.py", line 407, in invoke2024-06-10T00:48:32.510370+00:00 ]: return await self.send(query, timeout=timeout)2024-06-10T00:48:32.510370+00:00 app[.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^2024-06-10T00:48:32.510370+00:00 app[ File "/app/.heroku/python/lib/python3.12/site-packages/pyrogram/session/session.py", line 364, in send2024-06-10T00:48:32.510371+00:00 RPCError.raise_it(result, type(data))2024-06- File "/app/.heroku/python/lib/python3.12/site-packages/pyrogram/errors/rpc_error.py", line 92, in raise_it raise getattr pyrogram.errors.exceptions.flood_420.FloodPremiumWait: Telegram says: [420 FLOOD_PREMIUM_WAIT_X] - A wait of 15 seconds is required (caused by "upload.GetFile")

Steps to reproduce

1

Code example

from Pyrogram import Client
import time

bot = Client(api_id=API, api_hash=HASH, bot_token=TOKEN)

userbot = Client(api_id=API, api_hash=HASH, string_session=SESSION)

userbot.run()
bot.run()

#sending media
@bot.on_message(filters.text)
async def media_dl_trst(client, message):
    # total_size = 300MB
    await userbot.download_media(message=message, progress=progress_for_pyrogram,progress_args=("Dᴏᴡɴʟᴏᴀᴅing...", ms, time.time()))

# path download size 30MB Why 
# Path Downloaded but error come & size downloaded 30MB BUT TOTAL Size 300MB
# Premium Flood Wait ✓

Logs

[ERROR/2024-06-10 00:48:32,509] pyrogram.client: Telegram says: [420 FLOOD_PREMIUM_WAIT_X] - A wait of 15 seconds is required (caused by "upload.GetFile")2024-06-10T00:48:32.510368+00:00 app[.1]: Traceback (most recent call last):2024-06-10T00:48:32.510368+00:00 app[.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pyrogram/client.py", line 1007, in get_file2024-06-10T00:48:32.510369+00:00 app[.1]: r = await session.invoke(2024-06-10T00:48:32.510369+00:00 app[.1]: ^^^^^^^^^^^^^^^^^^^^^2024-06-10T00:48:32.510369+00:00 app[.1]: File "/app/.heroku/python/lib/python3.12/site-packages/pyrogram/session/session.py", line 407, in invoke2024-06-10T00:48:32.510370+00:00 ]: return await self.send(query, timeout=timeout)2024-06-10T00:48:32.510370+00:00 app[.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^2024-06-10T00:48:32.510370+00:00 app[ File "/app/.heroku/python/lib/python3.12/site-packages/pyrogram/session/session.py", line 364, in send2024-06-10T00:48:32.510371+00:00  RPCError.raise_it(result, type(data))2024-06- File "/app/.heroku/python/lib/python3.12/site-packages/pyrogram/errors/rpc_error.py", line 92, in raise_it raise getattr pyrogram.errors.exceptions.flood_420.FloodPremiumWait: Telegram says: [420 FLOOD_PREMIUM_WAIT_X] - A wait of 15 seconds is required (caused by "upload.GetFile")

Fork and update TgCrypto to support Python 3.12

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

Pyrofork requires TgCrypto for better performance. The last version of TgCrypto is 1.2.5, and was released 2 years ago (11 November 2022).

The 1.2.5 version doesn't support current Python 3.12 (and future versions).
Suggestion is to fork and update the TgCrypto.

pymongo should be optional

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/Mayuri-Chan/pyrofork/archive/master.zip and reproduced the issue using the latest development version

Description

pymongo should be optional since many people won't use it

Steps to reproduce

  1. Install pyrofork
  2. Check installed dependencies

Code example

No response

Logs

No response

message.copy()

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

Bang tambahin support spoiler media pas di msg.copy() dong

can't handle messages with await client.start(), but can with client.run()

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

if i use await client.start() to start client, code can't hadle messages, but if i use client.run(), it works fine

Steps to reproduce

see code example

Code example

this code works just fine, and prints all messages

from pyrogram import Client


client = Client('tg_bot')


@client.on_message()
async def on_msg(_, msg):
    print(f'new msg {msg.id}')


client.run()

this code expected to work same, but it doesn't handle messages and doesn't print anything

from pyrogram import Client, idle
import asyncio


client = Client('tg_bot')


@client.on_message()
async def on_msg(_, msg):
    print(f'new msg {msg.id}')


async def main():
    await client.start()
    await idle()


asyncio.run(main())

Logs

No response

PERR ID .

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version

Description

me just sift pyrogram to pyrofork .

now me get peer id

Steps to reproduce

me try to approve user using cb but it's show as peer id
But me sure it's not peer .

Code example

My data 
...
 f"approve_{m.from_user.id}"

@cb...
async def approve_chat(c, q):
    _, user = q.data.split("_")
    try:
        await q.message.edit("ᴅᴏɴᴇ !.")
        await c.approve_chat_join_request(q.message.chat.id, user)
    except Exception as err:
        await q.message.edit(err)

Logs

Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it

CopyMessage.copy_message() got an unexpected keyword argument 'has_spoiler'

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/Mayuri-Chan/pyrofork/archive/master.zip and reproduced the issue using the latest development version

Description

mau copy_message media dari ch ke ch lain tapi

CopyMessage.copy_message() got an unexpected keyword argument 'has_spoiler'

Steps to reproduce

pas copy()

Code example

self.__mspoil = bool()
cok = app.copy_message(
chat_id=self.__chat_id,
from_chat_id=config_dict["LOG_LEECH"],
message_id=self.__bacok.id,
reply_to_message_id=self.__dcok,
reply_markup=reply_markup,
has_spoiler=self.__mspoil,
)

Logs

No response

[request] numbers only in versions

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

hello

current pyrofork version is 2.3.21.post3

can you please use numbers only in versions, and do not use letters

[feature request] store session as text file

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

hello

sessoin file not really stores a lot of data, so can you please add an option to store session file as a regular text file

consider use json, or yml

UnicodeDecodeError in Str implementation

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

There's a crash in message.text (which, btw, is not str - this is not stated in the documentation, which says message.text is a plain str)...

Steps to reproduce

Add the following message handler to the bot and then write this message anywhere the bot is:

🏳️‍🌈🏳️‍🌈

Code example

@app.on_message(group=-199)
async def test(client: pyrogram.client.Client, message: pyrogram.types.Message) -> None:
    print(message.text[:5])

Logs

[   dispatcher.py:342    handler_worker()] 'utf-16-le' codec can't decode bytes in position 10-11: unexpected end of data
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/pyrogram/dispatcher.py", line 329, in handler_worker
    await handler.callback(self.client, *args)
  File "/home/user/.local/lib/python3.10/site-packages/pyrogram/handlers/message_handler.py", line 151, in resolve_future_or_callback
    await self.original_callback(client, message, *args)
  File "/mnt/c/bot/handlers/test.py", line 38, in test
    print(message.text[:5])
  File "/home/user/.local/lib/python3.10/site-packages/pyrogram/types/messages_and_media/message.py", line 57, in __getitem__
    return parser_utils.remove_surrogates(parser_utils.add_surrogates(self)[item])
  File "/home/user/.local/lib/python3.10/site-packages/pyrogram/parser/utils.py", line 38, in remove_surrogates
    return text.encode("utf-16", "surrogatepass").decode("utf-16")
UnicodeDecodeError: 'utf-16-le' codec can't decode bytes in position 10-11: unexpected end of data

Recovering after receiving types.UpdatesTooLong

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

It seems like pyrogram devs are dead or something. But here is the deal

2023-11-12 19:51:52,029 INFO Connecting...
2023-11-12 19:51:52,071 INFO Connected! Production DC2 (media) - IPv4
2023-11-12 19:51:52,072 INFO NetworkTask started
2023-11-12 19:51:52,223 INFO Session initialized: Layer 158
2023-11-12 19:51:52,223 INFO Device: CPython 3.10.11 - Pyrogram 2.0.106
2023-11-12 19:51:52,223 INFO System: Linux 5.15.0-69-generic (en)
2023-11-12 19:51:52,223 INFO Session started
2023-11-12 19:51:52,225 INFO PingTask started
2023-11-12 19:51:53,511 INFO PingTask stopped
2023-11-12 19:51:53,512 INFO Disconnected
2023-11-12 19:51:53,512 INFO NetworkTask stopped
2023-11-12 19:51:53,512 INFO Session stopped
2023-11-12 19:52:00,284 INFO {
    "_": "types.UpdatesTooLong"
}

Receiving this update leads to loosing some updates. So here is a question. How to handle such cases?

Connection Lost

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/Mayuri-Chan/pyrofork/archive/master.zip and reproduced the issue using the latest development version

Description

.

Steps to reproduce

I don't know how it happened, I get this error when I run my bot and it doesn't reply to my messages

Code example

No response

Logs

[31-Dec-23 20:40:50 - INFO] - pyrogram.session.session - [6] Retrying "channels.GetMessages" due to: Connection lost
[31-Dec-23 20:40:50 - WARNING] - asyncio - socket.send() raised exception.
[31-Dec-23 20:40:50 - INFO] - pyrogram.connection.transport.tcp.tcp - Send exception: ConnectionResetError Connection lost
[31-Dec-23 20:40:50 - ERROR] - pyrogram.dispatcher - Connection lost
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/dispatcher.py", line 226, in handler_worker
    await parser(update, users, chats)
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/dispatcher.py", line 73, in message_parser
    await pyrogram.types.Message._parse(self.client, update.message, users, chats,
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/types/messages_and_media/message.py", line 1103, in _parse
    reply_to_message = await client.get_messages(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/methods/messages/get_messages.py", line 115, in get_messages
    r = await self.invoke(rpc, sleep_threshold=-1)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/methods/advanced/invoke.py", line 79, in invoke
    r = await self.session.invoke(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/session/session.py", line 425, in invoke
    return await self.invoke(query, retries - 1, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/session/session.py", line 425, in invoke
    return await self.invoke(query, retries - 1, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/session/session.py", line 425, in invoke
    return await self.invoke(query, retries - 1, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 7 more times]
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/session/session.py", line 415, in invoke
    raise e from None
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/session/session.py", line 402, in invoke
    return await self.send(query, timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/session/session.py", line 342, in send
    raise e
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/session/session.py", line 339, in send
    await self.connection.send(payload)
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/connection/connection.py", line 71, in send
    await self.protocol.send(data)
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/connection/transport/tcp/tcp_abridged.py", line 38, in send
    await super().send(
  File "/usr/local/lib/python3.11/dist-packages/pyrogram/connection/transport/tcp/tcp.py", line 104, in send
    raise OSError(e)
OSError: Connection lost
[31-Dec-23 20:40:50 - WARNING] - asyncio - socket.send() raised exception.

KeyError in get_peer_by_username function

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

When attempting to resolve a peer by username, the function get_peer_by_username in the storage.py module is raising a KeyError due to the absence of the key "last_update_on" in the returned result. This issue likely stems from incomplete data or an unexpected format in the database.

Steps to reproduce

  1. Attempt to resolve a peer by username.
  2. Encounter a KeyError due to the absence of "last_update_on" key in the returned result.

Code example

from pyrogram import Client
from typing import Union

async def get_chat() -> None:
    async with Client("my_account") as app:
        try:
            chat: Union[None, dict] = await app.get_chat("pir11")
            if chat:
                print(chat)
            else:
                print("Chat not found.")
        except Exception as e:
            print("An error occurred:", e)

def main() -> None:
    get_chat()

if __name__ == "__main__":
    main()

Logs

Traceback (most recent call last):
  File "<string>", line 1, in tmp
  File "/home/kai/.cache/pypoetry/virtualenvs/caligo-gKLP72oz-py3.9/lib/python3.9/site-packages/pyrogram/methods/users/get_users.py", line 60, in get_users
    user_ids = await asyncio.gather(*[self.resolve_peer(i) for i in user_ids])
  File "/home/kai/.cache/pypoetry/virtualenvs/caligo-gKLP72oz-py3.9/lib/python3.9/site-packages/pyrogram/methods/advanced/resolve_peer.py", line 84, in resolve_peer
    return await self.storage.get_peer_by_username(peer_id)
  File "caligo/core/database/storage.py", line 142, in get_peer_by_username
    if abs(time.time() - res["last_update_on"]) > self.USERNAME_TTL:
KeyError: 'last_update_on'

Full webapp support with documentation

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

Full telegram webapp support with documentation

Health Check

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

Hey team,

I have some bots using Pyrogram, however I am facing some issues on AWS, my bots get offline for no reason, then I need to redeploy it again on Github workflows to have them online again.

And I am not able to find any clues about the reason that it's crashing.

I think it would be possible to implement some kind of health check direct on the Pyrogram library.

I am available to work on this health check, but I would like to know what the devs suggest before working on this PR.

Waiting for news...

tgcrypto-pyrofork unable to install on arm processor

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

i have problem with installing tgcrypto-pyrofork

on x86 machines it installs without any issues

error on arm machines when try to install from pypi:

pip install tgcrypto-pyrofork
ERROR: Could not find a version that satisfies the requirement tgcrypto-pyrofork (from versions: none)
ERROR: No matching distribution found for tgcrypto-pyrofork

but it can be installed from git without any issues

pip install git+https://github.com/Mayuri-Chan/tgcrypto-pyrofork
Successfully installed TgCrypto-pyrofork-1.2.6

i tried to use fedora and ubuntu linux

Steps to reproduce

run pip install tgcrypto-pyrofork

Code example

No response

Logs

No response

Fix ValueError: Invalid peer type in mongodb session storage

Checklist

  • I am sure the error is coming from Pyrogram's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U https://github.com/pyrogram/pyrogram/archive/master.zip and reproduced the issue using the latest development version

Description

Please merge 2 important commit from mongodb session from animexd
animeshxd/pyromongo@d2c921f
animeshxd/pyromongo@f4ebae0

Steps to reproduce

I'm trying to use resolve peer with user id and username but always got peer id invalid even session saved in DB

Code example

app.resolve_peer(user id)

Logs

[16-May-23 07:11:27 - ERROR] - pyrogram.dispatcher.handler_worker - Invalid peer type: 1684221087
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/methods/advanced/resolve_peer.py", line 62, in resolve_peer
    return await self.storage.get_peer_by_id(peer_id)
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/storage/mongo_storage.py", line 104, in get_peer_by_id
    raise KeyError(f"ID not found: {peer_id}")
KeyError: 'ID not found: IAmCuteCodes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/methods/advanced/resolve_peer.py", line 71, in resolve_peer
    int(peer_id)
ValueError: invalid literal for int() with base 10: 'iamcutecodes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/dispatcher.py", line 240, in handler_worker
    await handler.callback(self.client, *args)
  File "/root/MissKatyPyro/misskaty/core/misskaty_patch/listen/listen.py", line 239, in resolve_future
    await self.registered_handler(client, message, *args)
  File "/root/MissKatyPyro/misskaty/core/decorator/ratelimiter.py", line 44, in decorator
    return await func(client, update)
  File "/root/MissKatyPyro/misskaty/helper/localization.py", line 120, in wrapper
    return await func(client, message, lfunc)
  File "/root/MissKatyPyro/misskaty/plugins/stickers.py", line 112, in kang_sticker
    user = await self.resolve_peer(ctx.from_user.username or ctx.from_user.id)
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/methods/advanced/resolve_peer.py", line 74, in resolve_peer
    return await self.storage.get_peer_by_username(peer_id)
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/storage/mongo_storage.py", line 118, in get_peer_by_username
    return get_input_peer(*list(r.values())[:3])
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/storage/sqlite_storage.py", line 90, in get_input_peer
    raise ValueError(f"Invalid peer type: {peer_type}")
ValueError: Invalid peer type: 1684221087

The bot does not call message handlers

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

Nothing happens when sending a message to the bot in the example below.

Steps to reproduce

  1. Try to write an echo bot;
  2. ..enjoy.

Code example

from pyrogram.filters import text
from pyrogram.client  import Client
from tomllib          import load


with open('auth.toml', 'rb') as file: auth_data = load(file)


app = Client(
    name      = auth_data['api']['name'],
    api_id    = auth_data['api']['id'],
    api_hash  = auth_data['api']['hash'],
    bot_token = auth_data['api']['token']
)


@app.on_message()
async def on_text(_, msg):
    print(msg.text)
    await app.send_message(
        chat_id = msg.chat.id,
        text = 'Ping!'
    )


print('Starting..')
app.run()

Logs

Starting..

Add new markdown.

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

Add new markdown for quote, telegram new feature.

The connection times out, the request times out, and the client is automatically restarted.

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

When a connection timeout or request timeout occurs after the client has been running for a period of time, the client cannot respond to the request. The client must be restarted to respond normally. I hope pyrofork can automatically restart the client.

image

search_messages in a chat topic

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

Whether to support searching content in a topic instead of searching the entire group

get_chat_history_count returns wrong

Checklist

  • I am sure the error is coming from Pyrofork's code and not elsewhere
  • I have searched in the issue tracker for similar bug reports, including closed ones
  • I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

In many chats it gives the result 2147483647 even though it has nothing to do with it

>> await app.get_chat_history_count(1454618510)
2147483647
>> await app.get_chat_history_count("me")
2147483647

Steps to reproduce

.

Code example

No response

Logs

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.