-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the classes BusinessOpeningHours and BusinessOpeningHoursInterv…
…al and the field business_opening_hours to the class Chat.
- Loading branch information
Showing
6 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Pyrogram - Telegram MTProto API Client Library for Python | ||
# Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
# | ||
# 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 <http://www.gnu.org/licenses/>. | ||
|
||
from typing import List | ||
from datetime import datetime | ||
|
||
import pyrogram | ||
from pyrogram import raw, types, utils | ||
|
||
from ..object import Object | ||
|
||
|
||
class BusinessOpeningHours(Object): | ||
""" | ||
Parameters: | ||
time_zone_name (``str``): | ||
Unique name of the time zone for which the opening hours are defined | ||
opening_hours (List of :obj:`~pyrogram.types.BusinessOpeningHoursInterval`): | ||
List of time intervals describing business opening hours | ||
""" | ||
|
||
def __init__( | ||
self, | ||
*, | ||
time_zone_name: str = None, | ||
opening_hours: List["types.BusinessOpeningHoursInterval"] = None, | ||
_raw: "raw.types.BusinessWorkHours" = None | ||
): | ||
super().__init__() | ||
|
||
self.time_zone_name = time_zone_name | ||
self.opening_hours = opening_hours | ||
self._raw = _raw | ||
|
||
|
||
@staticmethod | ||
def _parse( | ||
client, | ||
business_work_hours: "raw.types.BusinessWorkHours" | ||
) -> "BusinessOpeningHours": | ||
return BusinessOpeningHours( | ||
time_zone_name=getattr(business_work_hours, "timezone_id", None), | ||
opening_hours=types.List( | ||
[ | ||
types.BusinessOpeningHoursInterval._parse( | ||
weekly_open_ | ||
) for weekly_open_ in business_work_hours.weekly_open | ||
] | ||
) if getattr(business_work_hours, "weekly_open", None) else None, | ||
_raw=business_work_hours | ||
) |
58 changes: 58 additions & 0 deletions
58
pyrogram/types/business/business_opening_hours_interval.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Pyrogram - Telegram MTProto API Client Library for Python | ||
# Copyright (C) 2017-present Dan <https://github.com/delivrance> | ||
# | ||
# 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 <http://www.gnu.org/licenses/>. | ||
|
||
from datetime import datetime | ||
|
||
import pyrogram | ||
from pyrogram import raw, types, utils | ||
|
||
from ..object import Object | ||
|
||
|
||
class BusinessOpeningHoursInterval(Object): | ||
""" | ||
Parameters: | ||
opening_minute (``int``): | ||
The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60 | ||
closing_minute (``int``): | ||
The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60 | ||
""" | ||
|
||
def __init__( | ||
self, | ||
*, | ||
opening_minute: int = None, | ||
closing_minute: int = None | ||
): | ||
super().__init__() | ||
|
||
self.opening_minute = opening_minute | ||
self.closing_minute = closing_minute | ||
|
||
|
||
@staticmethod | ||
def _parse( | ||
weekly_open_: "raw.types.BusinessWeeklyOpen" | ||
) -> "BusinessOpeningHoursInterval": | ||
return BusinessOpeningHoursInterval( | ||
opening_minute=weekly_open_.start_minute, | ||
closing_minute=weekly_open_.end_minute | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters