Skip to content

Commit f5610c7

Browse files
committed
Merge branch 'develop' of https://github.com/pyrogram/pyrogram into develop
2 parents 417cc49 + 0189e3a commit f5610c7

File tree

3 files changed

+124
-0
lines changed

3 files changed

+124
-0
lines changed

docs/source/glossary.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Terms
5656
Userbot
5757
Also known as *user bot* or *ubot* for short, is a user logged in by third-party Telegram libraries --- such as
5858
Pyrogram --- to automate some behaviours, like sending messages or reacting to text commands or any other event.
59+
Not to be confused with *bot*, that is, a normal Telegram bot created by `@BotFather <https://t.me/botfather>`_.
5960

6061
Session
6162
Also known as *login session*, is a strictly personal piece of data created and held by both parties
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from typing import Union
20+
21+
from pyrogram.api import functions, types
22+
from pyrogram.client.ext import BaseClient
23+
24+
25+
class DeleteUserHistory(BaseClient):
26+
def delete_user_history(
27+
self,
28+
chat_id: Union[int, str],
29+
user_id: Union[int, str],
30+
) -> bool:
31+
"""Delete all messages sent by a certain user in a supergroup.
32+
33+
Parameters:
34+
chat_id (``int`` | ``str``):
35+
Unique identifier (int) or username (str) of the target chat.
36+
37+
user_id (``int`` | ``str``):
38+
Unique identifier (int) or username (str) of the user whose messages will be deleted.
39+
40+
Returns:
41+
``bool``: True on success, False otherwise.
42+
"""
43+
44+
r = self.send(
45+
functions.channels.DeleteUserHistory(
46+
channel=self.resolve_peer(chat_id),
47+
user_id=self.resolve_peer(user_id)
48+
)
49+
)
50+
51+
# Deleting messages you don't have right onto won't raise any error.
52+
# Check for pts_count, which is 0 in case deletes fail.
53+
return bool(r.pts_count)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from pyrogram.api import functions
20+
from ...ext import BaseClient
21+
22+
23+
class UpdateProfile(BaseClient):
24+
def update_profile(
25+
self,
26+
first_name: str = None,
27+
last_name: str = None,
28+
bio: str = None
29+
) -> bool:
30+
"""Update your profile details such as first name, last name and bio.
31+
32+
You can omit the parameters you don't want to change.
33+
34+
Parameters:
35+
first_name (``str``, *optional*):
36+
The new first name.
37+
38+
last_name (``str``, *optional*):
39+
The new last name.
40+
Pass "" (empty string) to remove it.
41+
42+
bio (``str``, *optional*):
43+
The new bio, also known as "about". Max 70 characters.
44+
Pass "" (empty string) to remove it.
45+
46+
Returns:
47+
``bool``: True on success.
48+
49+
Example:
50+
.. code-block:: python
51+
52+
# Update your first name only
53+
app.update_bio(first_name="Pyrogram")
54+
55+
# Update first name and bio
56+
app.update_bio(first_name="Pyrogram", bio="https://docs.pyrogram.org/")
57+
58+
# Remove the last name
59+
app.update_bio(last_name="")
60+
"""
61+
62+
return bool(
63+
self.send(
64+
functions.account.UpdateProfile(
65+
first_name=first_name,
66+
last_name=last_name,
67+
about=bio
68+
)
69+
)
70+
)

0 commit comments

Comments
 (0)