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

Error when working with the “message.html_text” property if the content type is “sticker” #2355

Closed
rustequal opened this issue Jul 28, 2024 · 4 comments

Comments

@rustequal
Copy link

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using?
    4.21.0
  2. What OS are you using?
    linux
  3. What version of python are you using?
    3.8.18

How to reproduce. Run this code:

import asyncio
from telebot.async_telebot import AsyncTeleBot

TOKEN = '<BOT_TOKEN>'
bot = AsyncTeleBot(TOKEN, parse_mode='HTML')

@bot.message_handler(content_types=['sticker'])
def handle_sticker(message):
  print(message.html_text)

asyncio.run(bot.infinity_polling(allowed_updates=['message']))

Send any sticker in private chat with the bot.

As of version 4.18.0, this commit has been added, which causes the error:
ERROR - TeleBot: ‘’NoneType‘ object has no attribute ’replace'”
if the property value is of type NoneType. Version 4.17.0 works without errors.

@Badiboy
Copy link
Collaborator

Badiboy commented Jul 28, 2024

Sticker has no text. Trying to assess text is nonsence.

@Badiboy Badiboy closed this as completed Jul 28, 2024
@Badiboy Badiboy reopened this Jul 28, 2024
@Badiboy
Copy link
Collaborator

Badiboy commented Jul 28, 2024

if the property value is of type NoneType. Version 4.17.0 works without errors.

Only this stopped me from closing the issue...

@rustequal
Copy link
Author

I'm well aware that the sticker doesn't have text in this property. But the library should not crash with an error when trying to access this property.

@Badiboy
Copy link
Collaborator

Badiboy commented Jul 28, 2024

#2356

@Badiboy Badiboy closed this as completed Jul 28, 2024
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

No branches or pull requests

2 participants