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

business_opening_hours is not shown in chat information. #1490

Closed
2 tasks done
proDreams opened this issue May 12, 2024 · 3 comments
Closed
2 tasks done

business_opening_hours is not shown in chat information. #1490

proDreams opened this issue May 12, 2024 · 3 comments
Labels
wontfix It is intended behavior

Comments

@proDreams
Copy link

Checklist

  • I am sure the error is coming from aiogram code
  • I have searched in the issue tracker for similar bug reports, including closed ones

Operating system

Debian 12

Python version

3.12

aiogram version

3.6.0

Expected behavior

I expect to receive information about opening hours in the information about the current chat.

Current behavior

business_opening_hours=None

Steps to reproduce

  1. Connect the bot to business mode
  2. Write a message
  3. Check the logs

Code example

async def handle_business_message(message: Message):
    print(await bot(GetChat(chat_id=message.chat.id)))
    # or
    print(message.chat)

Logs

No response

Additional information

If you make a request directly to Telegram https://api.telegram.org/BOT_TOKEN/getChat?chat_id=CHAT_ID, then the necessary information is in the answer.

@proDreams proDreams added the bug Something is wrong with the framework label May 12, 2024
@Olegt0rr
Copy link
Contributor

Olegt0rr commented Jun 6, 2024

Can't reproduce:

import logging

from aiogram import Bot, Dispatcher
from aiogram.types import Message

logger = logging.getLogger(__name__)

bot = Bot(token="...")
dp = Dispatcher()


@dp.message()
async def handler(message: Message):
    user = message.from_user

    chat = await bot.get_chat(user.id)
    hours = chat.business_opening_hours

    lines = [str(interval) for interval in hours.opening_hours]
    text = "\n".join(lines)
    await message.answer(text)


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    dp.run_polling(bot)
Screenshot 2024-06-06 at 19 37 46

@proDreams
Copy link
Author

Can't reproduce:

I tried to get in the middleware from the data argument, also through the GetChat class. I'll try your option, thanks.

@Olegt0rr
Copy link
Contributor

Olegt0rr commented Jun 6, 2024

The field in the original API is declared as Optional.
It shouldn't be in the Chat object sent with the message, so message.chat.business_opening_hours is guaranteed to return None

GetChat also works well

@dp.message()
async def handler(message: Message):
    chat = await bot(GetChat(chat_id=message.chat.id))
    hours = chat.business_opening_hours

    lines = [str(interval) for interval in hours.opening_hours]
    text = "\n".join(lines)
    await message.answer(text)

@Olegt0rr Olegt0rr added wontfix It is intended behavior and removed bug Something is wrong with the framework labels Jun 6, 2024
@Olegt0rr Olegt0rr closed this as not planned Won't fix, can't repro, duplicate, stale Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix It is intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants