pyrogram / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
4.33k stars 1.39k forks source link

Can't send sticker #316

Closed nsychev closed 4 years ago

nsychev commented 4 years ago

Checklist

Description

I'm developing tool to get stats of usage for each sticker in sticker pack.

In stable version from pip it doesn't work with one of my stickers. In development version (branch develop) it says that user @BotFather (ID = 429000) does not exist.

Steps to Reproduce

app.send_sticker(429000, "CAADAgADjwIAAsG90QX4Cp_GGTOzmRYE")

Sticker I'm trying to send is 31st in this pack.

Traceback

For stable version

TgCrypto is missing! Pyrogram will work the same, but at a much slower speed. More info: https://docs.pyrogram.org/topics/tgcrypto
Old session file detected: "stickers.session.OLD". You can remove this file now
Pyrogram v0.15.1, Copyright (C) 2017-2019 Dan <https://github.com/delivrance>
Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\pyrogram\client\ext\utils.py", line 97, in get_input_media_from_file_id
    decoded = decode(file_id_str)
  File "C:\Python37\lib\site-packages\pyrogram\client\ext\utils.py", line 33, in decode
    assert s[-1] == 2
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "app.py", line 111, in <module>
    main()
  File "app.py", line 102, in main
    app.send_sticker(429000, sticker)
  File "C:\Python37\lib\site-packages\pyrogram\client\methods\messages\send_sticker.py", line 115, in send_sticker
    media = utils.get_input_media_from_file_id(sticker, 8)
  File "C:\Python37\lib\site-packages\pyrogram\client\ext\utils.py", line 99, in get_input_media_from_file_id
    raise ValueError("Failed to decode file_id: {}".format(file_id_str))
ValueError: Failed to decode file_id: CAADAgADjwIAAsG90QX4Cp_GGTOzmRYE

Development version

TgCrypto is missing! Pyrogram will work the same, but at a much slower speed. More info: https://docs.pyrogram.org/topics/tgcrypto
Old session file detected: "stickers.session.OLD". You can remove this file now
Pyrogram v0.16.0.dev, Copyright (C) 2017-2019 Dan <https://github.com/delivrance>
Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\pyrogram\client\client.py", line 1659, in resolve_peer
    return self.storage.get_peer_by_id(peer_id)
  File "C:\Python37\lib\site-packages\pyrogram\client\storage\sqlite_storage.py", line 108, in get_peer_by_id
    raise KeyError("ID not found: {}".format(peer_id))
KeyError: 'ID not found: 429000'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\pyrogram\client\client.py", line 1720, in resolve_peer
    return self.storage.get_peer_by_id(peer_id)
  File "C:\Python37\lib\site-packages\pyrogram\client\storage\sqlite_storage.py", line 108, in get_peer_by_id
    raise KeyError("ID not found: {}".format(peer_id))
KeyError: 'ID not found: 429000'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "app.py", line 111, in <module>
    main()
  File "app.py", line 98, in main
    app.send_message(429000, "/stats")
  File "C:\Python37\lib\site-packages\pyrogram\client\methods\messages\send_message.py", line 123, in send_message
    peer=self.resolve_peer(chat_id),
  File "C:\Python37\lib\site-packages\pyrogram\client\client.py", line 1722, in resolve_peer
    raise PeerIdInvalid
pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: [400 PEER_ID_INVALID]: The id/access_hash combination is invalid
delivrance commented 4 years ago

@nsychev Hi, Botfather's id is 93372553, not 429000. You can use usernames directly without worrying about flood waits (unless you are fetching too many new usernames); Pyrogram will cache them all. The other error is due to you using the new file id format, which v0.15.1 doesn't understand.

nsychev commented 4 years ago

@delivrance OK, I'll try to use username, but 0.15.1 could send messages to 429000 and this ID is present in update object when I forward BotFather's message to any bot.

delivrance commented 4 years ago

I don't deny 429000 could exist (even though I don't know who is that, probably some Telegram support account), but BotFather 1) is a bot and 2) has a different id you can check yourself with print(app.get_users("@BotFather").id)