Rename update_personal_channel to set_personal_channel

This commit is contained in:
KurimuzonAkuma 2024-07-16 17:03:37 +03:00
parent 0cda4f9c79
commit aa9b1072e4
3 changed files with 16 additions and 14 deletions

View File

@ -274,6 +274,7 @@ def pyrogram_api():
get_chat_photos get_chat_photos
get_chat_photos_count get_chat_photos_count
set_profile_photo set_profile_photo
set_personal_channel
delete_profile_photos delete_profile_photos
set_username set_username
update_profile update_profile
@ -285,7 +286,6 @@ def pyrogram_api():
update_status update_status
check_username check_username
update_birthday update_birthday
update_personal_channel
""", """,
invite_links=""" invite_links="""
Invite Links Invite Links

View File

@ -26,11 +26,11 @@ from .get_default_emoji_statuses import GetDefaultEmojiStatuses
from .get_me import GetMe from .get_me import GetMe
from .get_users import GetUsers from .get_users import GetUsers
from .set_emoji_status import SetEmojiStatus from .set_emoji_status import SetEmojiStatus
from .set_personal_channel import SetPersonalChannel
from .set_profile_photo import SetProfilePhoto from .set_profile_photo import SetProfilePhoto
from .set_username import SetUsername from .set_username import SetUsername
from .unblock_user import UnblockUser from .unblock_user import UnblockUser
from .update_birthday import UpdateBirthday from .update_birthday import UpdateBirthday
from .update_personal_channel import UpdatePersonalChannel
from .update_profile import UpdateProfile from .update_profile import UpdateProfile
from .update_status import UpdateStatus from .update_status import UpdateStatus
@ -40,6 +40,7 @@ class Users(
CheckUsername, CheckUsername,
GetCommonChats, GetCommonChats,
GetChatPhotos, GetChatPhotos,
SetPersonalChannel,
SetProfilePhoto, SetProfilePhoto,
DeleteProfilePhotos, DeleteProfilePhotos,
GetUsers, GetUsers,
@ -48,7 +49,6 @@ class Users(
GetChatPhotosCount, GetChatPhotosCount,
UnblockUser, UnblockUser,
UpdateBirthday, UpdateBirthday,
UpdatePersonalChannel,
UpdateProfile, UpdateProfile,
UpdateStatus, UpdateStatus,
GetDefaultEmojiStatuses, GetDefaultEmojiStatuses,

View File

@ -16,25 +16,27 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import Union from typing import Union, Optional
import pyrogram import pyrogram
from pyrogram import raw from pyrogram import raw
class UpdatePersonalChannel: class SetPersonalChannel:
async def update_personal_channel( async def set_personal_channel(
self: "pyrogram.Client", self: "pyrogram.Client",
chat_id: Union[int, str] = None chat_id: Optional[Union[int, str]] = None
) -> bool: ) -> bool:
"""Update your personal channel. """Set a personal channel in bio.
.. include:: /_includes/usable-by/users.rst .. include:: /_includes/usable-by/users.rst
To get all available channels you can use
:meth:`~pyrogram.Client.get_personal_channels`.
Parameters: Parameters:
chat_id (``int`` | ``str``): chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target user. Unique identifier (int) or username (str) of the target user or None to remove it.
Use :meth:`~pyrogram.Client.get_personal_channels` to get available channels.
Returns: Returns:
``bool``: True on success. ``bool``: True on success.
@ -42,18 +44,18 @@ class UpdatePersonalChannel:
Example: Example:
.. code-block:: python .. code-block:: python
# Update your personal channel # Set your personal channel
await app.update_personal_channel(chat_id) await app.set_personal_channel(chat_id)
# Remove personal channel from your profile # Remove personal channel from your profile
await app.update_personal_channel() await app.set_personal_channel()
""" """
if chat_id is None: if chat_id is None:
peer = raw.types.InputChannelEmpty() peer = raw.types.InputChannelEmpty()
else: else:
peer = await self.resolve_peer(chat_id) peer = await self.resolve_peer(chat_id)
if not isinstance(peer, raw.types.InputChannel): if not isinstance(peer, raw.types.InputPeerChannel):
return False return False
return bool( return bool(