mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +03:00
Created Privacy settings (markdown)
parent
e37a11afc0
commit
5f44dc1a3f
31
Privacy-settings.md
Normal file
31
Privacy-settings.md
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
There are three "types" (keys) of privacy settings, which are separate from each other:
|
||||||
|
* Last seen (also affects whether you can see the other person's)
|
||||||
|
* Chat invite (whether you can be added to groups)
|
||||||
|
* Phone calls (who can call you)
|
||||||
|
|
||||||
|
For each of these, you have 3 modes (rules):
|
||||||
|
* All telegram users
|
||||||
|
* Your contacts only
|
||||||
|
* Nobody
|
||||||
|
|
||||||
|
To set any of these, you need a key to work on and a list of values, which will be a global rule, such as `InputPrivacyValueAllowAll` and exceptions, such as allowing or disallowing specific users.
|
||||||
|
|
||||||
|
### Last seen example
|
||||||
|
|
||||||
|
To allow no one except "@best_friend" to see your last seen, you would use this:
|
||||||
|
```python
|
||||||
|
from telethon import TelegramClient
|
||||||
|
from telethon.tl.functions.account import SetPrivacyRequest
|
||||||
|
from telethon.tl.types import InputPrivacyKeyStatusTimestamp, InputPrivacyValueAllowUsers, InputPrivacyValueDisallowAll
|
||||||
|
|
||||||
|
client = TelegramClient(session, api_id, api_hash).start()
|
||||||
|
bff = client.get_input_entity('@best_friend')
|
||||||
|
|
||||||
|
key = InputPrivacyKeyStatusTimestamp() # working with last seen privacy
|
||||||
|
|
||||||
|
rule = InputPrivacyValueDisallowAll() # main rule is to disallow everyone
|
||||||
|
exceptions = InputPrivacyValueAllowUsers([bff]) # more people can be allowed
|
||||||
|
values = [rule, exceptions]
|
||||||
|
|
||||||
|
client(SetPrivacyRequest(key, values))
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user