Skip to content

Commit

Permalink
Pyrofork: Add support for t.me/<username> link in resolve_peer method
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Jan 3, 2024
1 parent 00caac6 commit 0b2420e
Show file tree
Hide file tree
Showing 128 changed files with 169 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pyrogram/methods/advanced/resolve_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def resolve_peer(
Parameters:
peer_id (``int`` | ``str``):
The peer id you want to extract the InputPeer from.
Can be a direct id (int), a username (str) or a phone number (str).
Can be a direct id (int), a username (str) or a phone number (str) or *t.me/<username>* link.
Returns:
``InputPeer``: On success, the resolved peer id is returned in form of an InputPeer object.
Expand All @@ -66,6 +66,7 @@ async def resolve_peer(
return raw.types.InputPeerSelf()

peer_id = re.sub(r"[@+\s]", "", peer_id.lower())
peer_id = re.sub(r"https://t.me/", "", peer_id.lower())

try:
int(peer_id)
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/bots/get_chat_menu_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async def get_chat_menu_button(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use user profile/chat public link in form of *t.me/<username>* (str).
If not specified, default bot's menu button will be returned.
"""

Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/bots/get_game_high_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async def get_game_high_scores(
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile link in form of *t.me/<username>* (str).
chat_id (``int`` | ``str``, *optional*):
Unique identifier (int) or username (str) of the target chat.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/bots/get_inline_bot_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ async def get_inline_bot_results(
bot (``int`` | ``str``):
Unique identifier of the inline bot you want to get results from. You can specify
a @username (str) or a bot ID (int).
You can also use bot profile link in form of *t.me/<username>* (str).
query (``str``, *optional*):
Text of the query (up to 512 characters).
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/bots/request_callback_answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async def request_callback_answer(
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile/chat public link in form of *t.me/<username>* (str).
message_id (``int``):
The message id the inline keyboard is attached on.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/bots/send_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ async def send_game(
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile/chat public link in form of *t.me/<username>* (str).
game_short_name (``str``):
Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/bots/send_inline_bot_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ async def send_inline_bot_result(
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile/chat public link in form of *t.me/<username>* (str).
query_id (``int``):
Unique identifier for the answered query.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/bots/set_game_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def set_game_score(
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile link in form of *t.me/<username>* (str).
score (``int``):
New score, must be non-negative.
Expand Down
3 changes: 2 additions & 1 deletion pyrogram/methods/chats/add_chat_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ async def add_chat_members(
Parameters:
chat_id (``int`` | ``str``):
The group, supergroup or channel id
The group, supergroup or channel id or chat/channel public link
user_ids (``int`` | ``str`` | List of ``int`` or ``str``):
Users to add in the chat
You can pass an ID (int), username (str) or phone number (str).
Multiple users can be added by passing a list of IDs, usernames or phone numbers.
You can also use user profile link in form of *t.me/<username>* (str).
forward_limit (``int``, *optional*):
How many of the latest messages you want to forward to the new members. Pass 0 to forward none of them.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/archive_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async def archive_chats(
chat_ids (``int`` | ``str`` | List[``int``, ``str``]):
Unique identifier (int) or username (str) of the target chat.
You can also pass a list of ids (int) or usernames (str).
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
``bool``: On success, True is returned.
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/chats/ban_chat_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ async def ban_chat_member(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
user_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target user.
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile link in form of *t.me/<username>* (str).
until_date (:py:obj:`~datetime.datetime`, *optional*):
Date when the user will be unbanned.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/close_forum_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def close_forum_topic(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
topic_id (``int``):
Unique identifier (int) of the target forum topic.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/close_general_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async def close_general_topic(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
`bool`: On success, a True is returned.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/create_forum_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def create_forum_topic(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
title (``str``):
The forum topic title.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/delete_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def delete_channel(
Parameters:
chat_id (``int`` | ``str``):
The id of the channel to be deleted.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
``bool``: On success, True is returned.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/delete_chat_photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def delete_chat_photo(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
``bool``: True on success.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/delete_forum_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def delete_forum_topic(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
topic_id (``int``):
Unique identifier (int) of the target forum topic.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/delete_supergroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def delete_supergroup(
Parameters:
chat_id (``int`` | ``str``):
The id of the supergroup to be deleted.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
``bool``: On success, True is returned.
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/chats/delete_user_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ async def delete_user_history(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
user_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the user whose messages will be deleted.
You can also use user profile link in form of *t.me/<username>* (str).
Returns:
``bool``: True on success, False otherwise.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/edit_forum_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def edit_forum_topic(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
topic_id (``int``):
Unique identifier (int) of the target forum topic.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/edit_general_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def edit_general_topic(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
title (``str``):
The general forum topic title.
Expand Down
5 changes: 3 additions & 2 deletions pyrogram/methods/chats/get_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ async def get_chat(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Unique identifier for the target chat in form of a *t.me/joinchat/* link, identifier (int) or username
of the target channel/supergroup (in the format @username).
Unique identifier for the target chat in form of a *t.me/joinchat/* or *t.me/<username>* link link,
identifier (int) or username of the target channel/supergroup (in the format @username).
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
:obj:`~pyrogram.types.Chat` | :obj:`~pyrogram.types.ChatPreview`: On success, if you've already joined the chat, a chat object is returned,
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/get_chat_event_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def get_chat_event_log(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
query (``str``, *optional*):
Search query to filter events based on text.
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/chats/get_chat_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ async def get_chat_member(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
user_id (``int`` | ``str``)::
Unique identifier (int) or username (str) of the target user.
For you yourself you can simply use "me" or "self".
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile link in form of *t.me/<username>* (str).
Returns:
:obj:`~pyrogram.types.ChatMember`: On success, a chat member is returned.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/get_chat_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ async def get_chat_members(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
query (``str``, *optional*):
Query string to filter members based on their display names and usernames.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/get_chat_members_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def get_chat_members_count(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
``int``: On success, the chat members count is returned.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/get_chat_online_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def get_chat_online_count(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
``int``: On success, the chat members online count is returned.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/get_forum_topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ async def get_forum_topics(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
limit (``int``, *optional*):
Limits the number of topics to be retrieved.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/get_forum_topics_by_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ async def get_forum_topics_by_id(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
topic_ids (``int`` | Iterable of ``int``, *optional*):
Pass a single topic identifier or an iterable of topic ids (as integers) to get the information of the
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/get_send_as_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async def get_send_as_chats(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
List[:obj:`~pyrogram.types.Chat`]: The list of chats.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/hide_general_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async def hide_general_topic(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
`bool`: On success, a True is returned.
Expand Down
4 changes: 2 additions & 2 deletions pyrogram/methods/chats/join_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ async def join_chat(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier for the target chat in form of a *t.me/joinchat/* link, a username of the target
channel/supergroup (in the format @username) or a chat id of a linked chat (channel or supergroup).
Unique identifier for the target chat in form of a *t.me/joinchat/* or *t.me/<username>* link,
a username of the target channel/supergroup (in the format @username) or a chat id of a linked chat (channel or supergroup).
Returns:
:obj:`~pyrogram.types.Chat`: On success, a chat object is returned.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/leave_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def leave_chat(
chat_id (``int`` | ``str``):
Unique identifier for the target chat or username of the target channel/supergroup
(in the format @username).
You can also use chat public link in form of *t.me/<username>* (str).
delete (``bool``, *optional*):
Deletes the group chat dialog after leaving (for simple group chats, not supergroups).
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/mark_chat_unread.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def mark_chat_unread(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
``bool``: On success, True is returned.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/pin_chat_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async def pin_chat_message(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
message_id (``int``):
Identifier of a message to pin.
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/chats/promote_chat_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ async def promote_chat_member(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
user_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target user.
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile link in form of *t.me/<username>* (str).
privileges (:obj:`~pyrogram.types.ChatPrivileges`, *optional*):
New user privileges.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/reopen_forum_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def reopen_forum_topic(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
topic_id (``int``):
Unique identifier (int) of the target forum topic.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/reopen_general_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async def reopen_general_topic(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
Returns:
`bool`: On success, a True is returned.
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/chats/restrict_chat_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ async def restrict_chat_member(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
user_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target user.
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile link in form of *t.me/<username>* (str).
permissions (:obj:`~pyrogram.types.ChatPermissions`):
New user permissions.
Expand Down
2 changes: 2 additions & 0 deletions pyrogram/methods/chats/set_administrator_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ async def set_administrator_title(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
user_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target user.
For a contact that exists in your Telegram address book you can use his phone number (str).
You can also use user profile link in form of *t.me/<username>* (str).
title (``str``, *optional*):
A custom title that will be shown to all members instead of "Owner" or "Admin".
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/set_chat_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def set_chat_description(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
description (``str``):
New chat description, 0-255 characters.
Expand Down
1 change: 1 addition & 0 deletions pyrogram/methods/chats/set_chat_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async def set_chat_permissions(
Parameters:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
You can also use chat public link in form of *t.me/<username>* (str).
permissions (:obj:`~pyrogram.types.ChatPermissions`):
New default chat permissions.
Expand Down
Loading

0 comments on commit 0b2420e

Please sign in to comment.