-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: wulan17 <wulan17@nusantararom.org>
- Loading branch information
Showing
6 changed files
with
167 additions
and
4 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,65 @@ | ||
# Pyrofork - Telegram MTProto API Client Library for Python | ||
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/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 <http://www.gnu.org/licenses/>. | ||
|
||
from typing import Optional | ||
|
||
from pyrogram import raw, types | ||
from ..object import Object | ||
|
||
|
||
class BotAllowed(Object): | ||
|
||
"""Contains information about a allowed bot. | ||
Parameters: | ||
attach_menu (``bool``, *optional*): | ||
True, if the bot can attach to menu. | ||
from_request (``bool``, *optional*): | ||
True, if the bot is allowed from request. | ||
domain (``str``, *optional*): | ||
The domain of the bot. | ||
app (:obj:`types.BotApp`, *optional*): | ||
The app of the bot. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
*, | ||
attach_menu: Optional[bool] = None, | ||
from_request: Optional[bool] = None, | ||
domain: Optional[str] = None, | ||
app: Optional["types.BotApp"] = None | ||
): | ||
super().__init__() | ||
|
||
self.attach_menu = attach_menu | ||
self.from_request = from_request | ||
self.domain = domain | ||
self.app = app | ||
|
||
@staticmethod | ||
def _parse(bot_allowed: "raw.types.BotAllowed") -> "BotAllowed": | ||
return BotAllowed( | ||
attach_menu=getattr(bot_allowed, "attach_menu", None), | ||
from_request=getattr(bot_allowed, "from_request", None), | ||
domain=getattr(bot_allowed, "domain", None), | ||
app=types.BotApp._parse(getattr(bot_allowed, "app", None)) | ||
) |
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,76 @@ | ||
# Pyrofork - Telegram MTProto API Client Library for Python | ||
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/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 <http://www.gnu.org/licenses/>. | ||
|
||
from typing import Optional | ||
|
||
from pyrogram import raw, types | ||
from ..object import Object | ||
|
||
|
||
class BotApp(Object): | ||
|
||
"""Contains information about a bot app. | ||
Parameters: | ||
id (``int``): | ||
The id of the app. | ||
short_name (``str``): | ||
The short name of the app. | ||
title (``str``): | ||
The title of the app. | ||
description (``str``): | ||
The description of the app. | ||
photo (``types.Photo``): | ||
The photo of the app. | ||
document (``types.Document``, *optional*): | ||
The document of the app. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
id: int, | ||
short_name: str, | ||
title: str, | ||
description: str, | ||
photo: "types.Photo", | ||
document: Optional["types.Document"] = None | ||
): | ||
super().__init__() | ||
|
||
self.id = id | ||
self.short_name = short_name | ||
self.title = title | ||
self.description = description | ||
self.photo = photo | ||
self.document = document | ||
|
||
@staticmethod | ||
def _parse(bot_app: "raw.types.BotApp") -> "BotApp": | ||
return BotApp( | ||
id=bot_app.id, | ||
short_name=bot_app.short_name, | ||
title=bot_app.title, | ||
description=bot_app.description, | ||
photo=types.Photo._parse(bot_app.photo), | ||
document=types.Document._parse(getattr(bot_app, "document", None)) | ||
) |
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