diff --git a/compiler/docs/compiler.py b/compiler/docs/compiler.py
index e87eab49..61de1aa6 100644
--- a/compiler/docs/compiler.py
+++ b/compiler/docs/compiler.py
@@ -421,6 +421,12 @@ def pyrogram_api():
categories = dict(
users_chats="""
Users & Chats
+ BusinessInfo
+ BusinessMessage
+ BusinessRecipients
+ BusinessSchedule
+ BusinessWeeklyOpen
+ BusinessWorkingHours
User
Chat
ChatPreview
diff --git a/docs/source/api/enums/index.rst b/docs/source/api/enums/index.rst
index aca1a605..03a61bfd 100644
--- a/docs/source/api/enums/index.rst
+++ b/docs/source/api/enums/index.rst
@@ -13,6 +13,7 @@ to apply only a valid value among the expected ones.
.. autosummary::
:nosignatures:
+ BusinessSchedule
ChatAction
ChatEventAction
ChatMemberStatus
diff --git a/pyrogram/enums/__init__.py b/pyrogram/enums/__init__.py
index 4cd76f1a..ab762da5 100644
--- a/pyrogram/enums/__init__.py
+++ b/pyrogram/enums/__init__.py
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see .
+from .business_schedule import BusinessSchedule
from .chat_action import ChatAction
from .chat_event_action import ChatEventAction
from .chat_member_status import ChatMemberStatus
@@ -39,6 +40,7 @@ from .story_privacy import StoryPrivacy
from .user_status import UserStatus
__all__ = [
+ 'BusinessSchedule',
'ChatAction',
'ChatEventAction',
'ChatMemberStatus',
diff --git a/pyrogram/enums/business_schedule.py b/pyrogram/enums/business_schedule.py
new file mode 100644
index 00000000..a395a702
--- /dev/null
+++ b/pyrogram/enums/business_schedule.py
@@ -0,0 +1,33 @@
+# Pyrogram - Telegram MTProto API Client Library for Python
+# Copyright (C) 2017-present Dan
+#
+# This file is part of Pyrogram.
+#
+# Pyrogram is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrogram is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrogram. If not, see .
+
+from pyrogram import raw
+from .auto_name import AutoName
+
+
+class BusinessSchedule(AutoName):
+ """Business away enumeration used in :obj:`~pyrogram.types.BusinessInfo`."""
+
+ ALWAYS = raw.types.BusinessAwayMessageScheduleAlways
+ "Send always"
+
+ OUTSIDE_WORK_HOURS = raw.types.BusinessAwayMessageScheduleOutsideWorkHours
+ "Outside of Business Hours"
+
+ CUSTOM = raw.types.BusinessAwayMessageScheduleCustom
+ "Custom Schedule"
diff --git a/pyrogram/types/user_and_chats/__init__.py b/pyrogram/types/user_and_chats/__init__.py
index 54979ddc..474527d6 100644
--- a/pyrogram/types/user_and_chats/__init__.py
+++ b/pyrogram/types/user_and_chats/__init__.py
@@ -17,6 +17,11 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrofork. If not, see .
+from .business_info import BusinessInfo
+from .business_message import BusinessMessage
+from .business_recipients import BusinessRecipients
+from .business_weekly_open import BusinessWeeklyOpen
+from .business_working_hours import BusinessWorkingHours
from .chat import Chat
from .chat_admin_with_invite_links import ChatAdminWithInviteLinks
from .chat_color import ChatColor
@@ -54,6 +59,11 @@ from .video_chat_scheduled import VideoChatScheduled
from .video_chat_started import VideoChatStarted
__all__ = [
+ "BusinessInfo",
+ "BusinessMessage",
+ "BusinessRecipients",
+ "BusinessWeeklyOpen",
+ "BusinessWorkingHours",
"Chat",
"ChatMember",
"ChatPermissions",
diff --git a/pyrogram/types/user_and_chats/business_info.py b/pyrogram/types/user_and_chats/business_info.py
new file mode 100644
index 00000000..c79e6e63
--- /dev/null
+++ b/pyrogram/types/user_and_chats/business_info.py
@@ -0,0 +1,81 @@
+# Pyrofork - Telegram MTProto API Client Library for Python
+# Copyright (C) 2022-present Mayuri-Chan
+#
+# This file is part of Pyrofork.
+#
+# Pyrofork is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrofork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrofork. If not, see .
+
+from typing import Optional
+
+from pyrogram import types, raw
+from ..object import Object
+
+
+class BusinessInfo(Object):
+ """Business information of a user.
+
+ Parameters:
+ address (``str``, *optional*):
+ Address of the business.
+
+ location (:obj:`~pyrogram.types.Location`, *optional*):
+ Location of the business on the map.
+
+ greeting_message (:obj:`~pyrogram.types.BusinessMessage`, *optional*):
+ Greeting message of the business.
+
+ away_message (:obj:`~pyrogram.types.BusinessMessage`, *optional*):
+ Away message of the business.
+
+ working_hours (:obj:`~pyrogram.types.BusinessWorkingHours`, *optional*):
+ Working hours of the business.
+ """
+
+ def __init__(
+ self,
+ *,
+ address: str = None,
+ location: "types.Location" = None,
+ greeting_message: "types.BusinessMessage" = None,
+ away_message: "types.BusinessMessage" = None,
+ working_hours: "types.BusinessWorkingHours" = None,
+
+ ):
+ self.address = address
+ self.location = location
+ self.greeting_message = greeting_message
+ self.away_message = away_message
+ self.working_hours = working_hours
+
+ @staticmethod
+ def _parse(
+ client,
+ user: "raw.types.UserFull" = None,
+ users: dict = None
+ ) -> Optional["BusinessInfo"]:
+ working_hours = getattr(user, "business_work_hours", None)
+ location = getattr(user, "business_location", None)
+ greeting_message = getattr(user, "business_greeting_message", None)
+ away_message = getattr(user, "business_away_message", None)
+
+ if not any((working_hours, location, greeting_message, away_message)):
+ return None
+
+ return BusinessInfo(
+ address=getattr(location, "address", None),
+ location=types.Location._parse(client, getattr(location, "geo_point", None)),
+ greeting_message=types.BusinessMessage._parse(client, greeting_message, users),
+ away_message=types.BusinessMessage._parse(client, away_message, users),
+ working_hours=types.BusinessWorkingHours._parse(working_hours),
+ )
diff --git a/pyrogram/types/user_and_chats/business_message.py b/pyrogram/types/user_and_chats/business_message.py
new file mode 100644
index 00000000..dfcead79
--- /dev/null
+++ b/pyrogram/types/user_and_chats/business_message.py
@@ -0,0 +1,111 @@
+# Pyrofork - Telegram MTProto API Client Library for Python
+# Copyright (C) 2022-present Mayuri-Chan
+#
+# This file is part of Pyrofork.
+#
+# Pyrofork is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrofork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrofork. If not, see .
+
+from datetime import datetime
+from typing import Optional, Union, List
+
+from pyrogram import types, enums, raw, utils
+from ..object import Object
+
+
+class BusinessMessage(Object):
+ """Business working hours.
+
+ Parameters:
+ shortcut_id (``int``):
+ ID of the shortcut.
+
+ is_greeting (``bool``, *optional*):
+ True, if the message is a greeting message.
+
+ is_away (``bool``, *optional*):
+ True, if the message is an away message.
+
+ no_activity_days (``int``, *optional*):
+ Period of inactivity after which the greeting message should be sent again.
+
+ offline_only (``bool``, *optional*):
+ Dont send the away message if you've recently been online.
+
+ recipients (List of :obj:`~pyrogram.types.User`, *optional*):
+ Recipients of the message.
+
+ schedule (:obj:`~pyrogram.enums.BusinessSchedule`, *optional*):
+ Schedule of the away message to be sent.
+
+ start_date (``datetime``, *optional*):
+ Start date of the away message.
+
+ end_date (``datetime``, *optional*):
+ End date of the away message.
+ """
+
+ def __init__(
+ self,
+ *,
+ shortcut_id: int,
+ is_greeting: bool = None,
+ is_away: bool = None,
+ no_activity_days: int = None,
+ offline_only: bool = None,
+ recipients: List["types.User"] = None,
+ schedule: "enums.BusinessSchedule" = None,
+ start_date: datetime = None,
+ end_date: datetime = None,
+
+ ):
+ self.shortcut_id = shortcut_id
+ self.is_greeting = is_greeting
+ self.is_away = is_away
+ self.no_activity_days = no_activity_days
+ self.offline_only = offline_only
+ self.recipients = recipients
+ self.schedule = schedule
+ self.start_date = start_date
+ self.end_date = end_date
+
+ @staticmethod
+ def _parse(
+ client,
+ message: Union["raw.types.BusinessGreetingMessage", "raw.types.BusinessAwayMessage"] = None,
+ users: dict = None
+ ) -> Optional["BusinessMessage"]:
+ if not message:
+ return None
+
+ schedule = None
+
+ if isinstance(message, raw.types.BusinessAwayMessage):
+ if isinstance(message.schedule, raw.types.BusinessAwayMessageScheduleAlways):
+ schedule = enums.BusinessSchedule.ALWAYS
+ elif isinstance(message.schedule, raw.types.BusinessAwayMessageScheduleOutsideWorkHours):
+ schedule = enums.BusinessSchedule.OUTSIDE_WORK_HOURS
+ elif isinstance(message.schedule, raw.types.BusinessAwayMessageScheduleCustom):
+ schedule = enums.BusinessSchedule.CUSTOM
+
+ return BusinessMessage(
+ shortcut_id=message.shortcut_id,
+ is_greeting=isinstance(message, raw.types.BusinessGreetingMessage),
+ is_away=isinstance(message, raw.types.BusinessAwayMessage),
+ no_activity_days=getattr(message, "no_activity_days", None),
+ offline_only=getattr(message, "offline_only", None),
+ recipients=types.BusinessRecipients._parse(client, message.recipients, users),
+ schedule=schedule,
+ start_date=utils.timestamp_to_datetime(message.schedule.start_date) if schedule == enums.BusinessSchedule.CUSTOM else None,
+ end_date=utils.timestamp_to_datetime(message.schedule.end_date) if schedule == enums.BusinessSchedule.CUSTOM else None
+ )
diff --git a/pyrogram/types/user_and_chats/business_recipients.py b/pyrogram/types/user_and_chats/business_recipients.py
new file mode 100644
index 00000000..bf2fae18
--- /dev/null
+++ b/pyrogram/types/user_and_chats/business_recipients.py
@@ -0,0 +1,78 @@
+# Pyrofork - Telegram MTProto API Client Library for Python
+# Copyright (C) 2022-present Mayuri-Chan
+#
+# This file is part of Pyrofork.
+#
+# Pyrofork is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrofork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrofork. If not, see .
+
+from typing import List
+
+from pyrogram import types, raw
+from ..object import Object
+
+
+class BusinessRecipients(Object):
+ """Business recipients.
+
+ Parameters:
+ existing_chats (``bool``, *optional*):
+ True, if the message should be sent to existing chats.
+
+ new_chats (``bool``, *optional*):
+ True, if the message should be sent to new chats.
+
+ contacts (``bool``, *optional*):
+ True, if the message should be sent to contacts.
+
+ non_contacts (``bool``, *optional*):
+ True, if the message should be sent to non-contacts.
+
+ exclude_selected (``bool``, *optional*):
+ True, if the message should be sent to non-selected contacts.
+
+ users (List of :obj:`~pyrogram.types.User`, *optional*):
+ Recipients of the message.
+ """
+
+ def __init__(
+ self,
+ *,
+ existing_chats: bool = None,
+ new_chats: bool = None,
+ contacts: bool = None,
+ non_contacts: bool = None,
+ exclude_selected: bool = None,
+ users: List[int] = None
+ ):
+ self.existing_chats = existing_chats
+ self.new_chats = new_chats
+ self.contacts = contacts
+ self.non_contacts = non_contacts
+ self.exclude_selected = exclude_selected
+ self.users = users
+
+ @staticmethod
+ def _parse(
+ client,
+ recipients: "raw.types.BusinessRecipients",
+ users: dict = None
+ ) -> "BusinessRecipients":
+ return BusinessRecipients(
+ existing_chats=getattr(recipients, "existing_chats", None),
+ new_chats=getattr(recipients, "new_chats", None),
+ contacts=getattr(recipients, "contacts", None),
+ non_contacts=getattr(recipients, "non_contacts", None),
+ exclude_selected=getattr(recipients, "exclude_selected", None),
+ users=types.List(types.User._parse(client, users[i]) for i in recipients.users) or None if getattr(recipients, "users", None) else None
+ )
diff --git a/pyrogram/types/user_and_chats/business_weekly_open.py b/pyrogram/types/user_and_chats/business_weekly_open.py
new file mode 100644
index 00000000..d8317751
--- /dev/null
+++ b/pyrogram/types/user_and_chats/business_weekly_open.py
@@ -0,0 +1,49 @@
+# Pyrofork - Telegram MTProto API Client Library for Python
+# Copyright (C) 2022-present Mayuri-Chan
+#
+# This file is part of Pyrofork.
+#
+# Pyrofork is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrofork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrofork. If not, see .
+
+from pyrogram import raw
+from ..object import Object
+
+
+class BusinessWeeklyOpen(Object):
+ """Business weekly open hours.
+
+ Parameters:
+ start_minute (``int``):
+ Start minute of the working day.
+
+ end_minute (``int``):
+ End minute of the working day.
+ """
+
+ def __init__(
+ self,
+ *,
+ start_minute: int,
+ end_minute: int,
+
+ ):
+ self.start_minute = start_minute
+ self.end_minute = end_minute
+
+ @staticmethod
+ def _parse(weekly_open: "raw.types.BusinessWeeklyOpen" = None) -> "BusinessWeeklyOpen":
+ return BusinessWeeklyOpen(
+ start_minute=weekly_open.start_minute,
+ end_minute=weekly_open.end_minute,
+ )
diff --git a/pyrogram/types/user_and_chats/business_working_hours.py b/pyrogram/types/user_and_chats/business_working_hours.py
new file mode 100644
index 00000000..bfeb4473
--- /dev/null
+++ b/pyrogram/types/user_and_chats/business_working_hours.py
@@ -0,0 +1,62 @@
+# Pyrofork - Telegram MTProto API Client Library for Python
+# Copyright (C) 2022-present Mayuri-Chan
+#
+# This file is part of Pyrofork.
+#
+# Pyrofork is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pyrofork is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with Pyrofork. If not, see .
+
+from typing import Optional, List
+
+from pyrogram import types, raw
+from ..object import Object
+
+
+class BusinessWorkingHours(Object):
+ """Business working hours.
+
+ Parameters:
+ timezone (``str``):
+ Timezone of the business.
+
+ working_hours (List of :obj:`~pyrogram.types.BusinessWeeklyOpen`):
+ Working hours of the business.
+
+ is_open_now (``bool``, *optional*):
+ True, if the business is open now.
+ """
+
+ def __init__(
+ self,
+ *,
+ timezone: str,
+ working_hours: List["types.BusinessWeeklyOpen"],
+ is_open_now: bool = None
+
+ ):
+ self.timezone = timezone
+ self.is_open_now = is_open_now
+ self.working_hours = working_hours
+
+ @staticmethod
+ def _parse(work_hours: "raw.types.BusinessWorkHours" = None) -> Optional["BusinessWorkingHours"]:
+ if not work_hours:
+ return None
+
+ return BusinessWorkingHours(
+ timezone=work_hours.timezone_id,
+ working_hours=types.List(
+ types.BusinessWeeklyOpen._parse(i) for i in work_hours.weekly_open
+ ),
+ is_open_now=getattr(work_hours, "open_now", None),
+ )
diff --git a/pyrogram/types/user_and_chats/chat.py b/pyrogram/types/user_and_chats/chat.py
index e5c538a7..66ac6371 100644
--- a/pyrogram/types/user_and_chats/chat.py
+++ b/pyrogram/types/user_and_chats/chat.py
@@ -180,6 +180,9 @@ class Chat(Object):
profile_color (:obj:`~pyrogram.types.ChatColor`, *optional*):
Chat profile color.
+
+ business_info (:obj:`~pyrogram.types.BusinessInfo`, *optional*):
+ Business information of a chat.
"""
def __init__(
@@ -226,7 +229,8 @@ class Chat(Object):
available_reactions: Optional["types.ChatReactions"] = None,
usernames: List["types.Username"] = None,
reply_color: "types.ChatColor" = None,
- profile_color: "types.ChatColor" = None
+ profile_color: "types.ChatColor" = None,
+ business_info: "types.BusinessInfo" = None
):
super().__init__(client)
@@ -271,6 +275,7 @@ class Chat(Object):
self.usernames = usernames
self.reply_color = reply_color
self.profile_color = profile_color
+ self.business_info = business_info
@property
def full_name(self) -> str:
@@ -407,6 +412,7 @@ class Chat(Object):
parsed_chat = Chat._parse_user_chat(client, users[full_user.id])
parsed_chat.bio = full_user.about
parsed_chat.folder_id = getattr(full_user, "folder_id", None)
+ parsed_chat.business_info = types.BusinessInfo._parse(client, full_user, users)
if full_user.pinned_msg_id:
parsed_chat.pinned_message = await client.get_messages(