Update documentation to reflect new methods

This commit is contained in:
Lonami Exo 2019-01-03 19:20:52 +01:00
parent eda8d0dbc8
commit 1b424b3fe7
5 changed files with 45 additions and 2 deletions

View File

@ -402,7 +402,7 @@ location, phone number, or simply for them to easily send a message:
.. code-block:: python .. code-block:: python
client.send_message(chat, 'Welcome', buttons=[ client.send_message(chat, 'Welcome', buttons=[
Button.text('Thanks!'), Button.text('Thanks!', resize=True, single_use=True),
Button.request_phone('Send phone'), Button.request_phone('Send phone'),
Button.request_location('Send location') Button.request_location('Send location')
]) ])
@ -644,3 +644,36 @@ Note that the utils package also has a `get_peer_id
<telethon.utils.get_peer_id>` but it won't work with things <telethon.utils.get_peer_id>` but it won't work with things
that need access to the network such as usernames or phones, that need access to the network such as usernames or phones,
which need to be in your contact list. which need to be in your contact list.
Getting the Admin Log
*********************
If you're an administrator in a channel or megagroup, then you have access
to the admin log. This is a list of events within the last 48 hours of
different actions, such as joining or leaving members, edited or deleted
messages, new promotions, bans or restrictions.
You can iterate over all the available actions like so:
.. code-block:: python
for event in client.iter_admin_log(channel):
if event.changed_title:
print('The title changed from', event.old, 'to', event.new)
You can also filter to only show some text or actions.
Let's find people who swear to ban them:
.. code-block:: python
# Get a list of deleted message events which said "heck"
events = client.get_admin_log(channel, search='heck', delete=True)
# Print the old message before it was deleted
print(events[0].old)
You can find here the documentation for `client.iter_admin_log
<telethon.client.chats.ChatMethods.iter_admin_log>`, and be sure
to also check the properties of the returned `AdminLogEvent
<telethon.tl.custom.adminlogevent.AdminLogEvent>` to know what
you can access.

View File

@ -19,6 +19,7 @@ when you upgrade!
* Are you new here? Jump straight into :ref:`getting-started`! * Are you new here? Jump straight into :ref:`getting-started`!
* Looking for available friendly methods? See :ref:`telethon-client`. * Looking for available friendly methods? See :ref:`telethon-client`.
* Used Telethon before v1.0? See :ref:`compatibility-and-convenience`. * Used Telethon before v1.0? See :ref:`compatibility-and-convenience`.
* Need the full API reference? https://lonamiwebs.github.io/Telethon/.
What is this? What is this?

View File

@ -97,3 +97,11 @@ telethon\.tl\.custom\.conversation module
:members: :members:
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
telethon\.tl\.custom\.adminlogevent module
------------------------------------------
.. automodule:: telethon.tl.custom.adminlogevent
:members:
:undoc-members:
:show-inheritance:

View File

@ -41,6 +41,7 @@ CHAT_ADMIN_REQUIRED,400 403,"Chat admin privileges are required to do that in th
CHAT_FORBIDDEN,,You cannot write in this chat CHAT_FORBIDDEN,,You cannot write in this chat
CHAT_ID_EMPTY,400,The provided chat ID is empty CHAT_ID_EMPTY,400,The provided chat ID is empty
CHAT_ID_INVALID,400,"Invalid object ID for a chat. Make sure to pass the right types, for instance making sure that the request is designed for chats (not channels/megagroups) or otherwise look for a different one more suited\nAn example working with a megagroup and AddChatUserRequest, it will fail because megagroups are channels. Use InviteToChannelRequest instead" CHAT_ID_INVALID,400,"Invalid object ID for a chat. Make sure to pass the right types, for instance making sure that the request is designed for chats (not channels/megagroups) or otherwise look for a different one more suited\nAn example working with a megagroup and AddChatUserRequest, it will fail because megagroups are channels. Use InviteToChannelRequest instead"
CHAT_INVALID,400,The chat is invalid for this request
CHAT_NOT_MODIFIED,400,"The chat or channel wasn't modified (title, invites, username, admins, etc. are the same)" CHAT_NOT_MODIFIED,400,"The chat or channel wasn't modified (title, invites, username, admins, etc. are the same)"
CHAT_RESTRICTED,400,The chat is restricted and cannot be used in that request CHAT_RESTRICTED,400,The chat is restricted and cannot be used in that request
CHAT_SEND_GIFS_FORBIDDEN,403,You can't send gifs in this chat CHAT_SEND_GIFS_FORBIDDEN,403,You can't send gifs in this chat

1 name codes description
41 CHAT_FORBIDDEN You cannot write in this chat
42 CHAT_ID_EMPTY 400 The provided chat ID is empty
43 CHAT_ID_INVALID 400 Invalid object ID for a chat. Make sure to pass the right types, for instance making sure that the request is designed for chats (not channels/megagroups) or otherwise look for a different one more suited\nAn example working with a megagroup and AddChatUserRequest, it will fail because megagroups are channels. Use InviteToChannelRequest instead
44 CHAT_INVALID 400 The chat is invalid for this request
45 CHAT_NOT_MODIFIED 400 The chat or channel wasn't modified (title, invites, username, admins, etc. are the same)
46 CHAT_RESTRICTED 400 The chat is restricted and cannot be used in that request
47 CHAT_SEND_GIFS_FORBIDDEN 403 You can't send gifs in this chat

View File

@ -54,7 +54,7 @@ channels.getFullChannel,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHANNEL_PUBLIC_G
channels.getMessages,unknown,CHANNEL_INVALID CHANNEL_PRIVATE MESSAGE_IDS_EMPTY channels.getMessages,unknown,CHANNEL_INVALID CHANNEL_PRIVATE MESSAGE_IDS_EMPTY
channels.getParticipant,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED USER_ID_INVALID USER_NOT_PARTICIPANT channels.getParticipant,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED USER_ID_INVALID USER_NOT_PARTICIPANT
channels.getParticipants,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED INPUT_CONSTRUCTOR_INVALID Timeout channels.getParticipants,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED INPUT_CONSTRUCTOR_INVALID Timeout
channels.inviteToChannel,user,BOTS_TOO_MUCH BOT_GROUPS_BLOCKED CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_WRITE_FORBIDDEN INPUT_USER_DEACTIVATED USERS_TOO_MUCH USER_BANNED_IN_CHANNEL USER_BLOCKED USER_BOT USER_CHANNELS_TOO_MUCH USER_ID_INVALID USER_KICKED USER_NOT_MUTUAL_CONTACT USER_PRIVACY_RESTRICTED channels.inviteToChannel,user,BOTS_TOO_MUCH BOT_GROUPS_BLOCKED CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_INVALID CHAT_WRITE_FORBIDDEN INPUT_USER_DEACTIVATED USERS_TOO_MUCH USER_BANNED_IN_CHANNEL USER_BLOCKED USER_BOT USER_CHANNELS_TOO_MUCH USER_ID_INVALID USER_KICKED USER_NOT_MUTUAL_CONTACT USER_PRIVACY_RESTRICTED
channels.joinChannel,user,CHANNELS_TOO_MUCH CHANNEL_INVALID CHANNEL_PRIVATE channels.joinChannel,user,CHANNELS_TOO_MUCH CHANNEL_INVALID CHANNEL_PRIVATE
channels.leaveChannel,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHANNEL_PUBLIC_GROUP_NA USER_CREATOR USER_NOT_PARTICIPANT channels.leaveChannel,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHANNEL_PUBLIC_GROUP_NA USER_CREATOR USER_NOT_PARTICIPANT
channels.readHistory,user,CHANNEL_INVALID CHANNEL_PRIVATE channels.readHistory,user,CHANNEL_INVALID CHANNEL_PRIVATE

1 method usability errors
54 channels.getMessages unknown CHANNEL_INVALID CHANNEL_PRIVATE MESSAGE_IDS_EMPTY
55 channels.getParticipant unknown CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED USER_ID_INVALID USER_NOT_PARTICIPANT
56 channels.getParticipants unknown CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED INPUT_CONSTRUCTOR_INVALID Timeout
57 channels.inviteToChannel user BOTS_TOO_MUCH BOT_GROUPS_BLOCKED CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_WRITE_FORBIDDEN INPUT_USER_DEACTIVATED USERS_TOO_MUCH USER_BANNED_IN_CHANNEL USER_BLOCKED USER_BOT USER_CHANNELS_TOO_MUCH USER_ID_INVALID USER_KICKED USER_NOT_MUTUAL_CONTACT USER_PRIVACY_RESTRICTED BOTS_TOO_MUCH BOT_GROUPS_BLOCKED CHANNEL_INVALID CHANNEL_PRIVATE CHAT_ADMIN_REQUIRED CHAT_INVALID CHAT_WRITE_FORBIDDEN INPUT_USER_DEACTIVATED USERS_TOO_MUCH USER_BANNED_IN_CHANNEL USER_BLOCKED USER_BOT USER_CHANNELS_TOO_MUCH USER_ID_INVALID USER_KICKED USER_NOT_MUTUAL_CONTACT USER_PRIVACY_RESTRICTED
58 channels.joinChannel user CHANNELS_TOO_MUCH CHANNEL_INVALID CHANNEL_PRIVATE
59 channels.leaveChannel unknown CHANNEL_INVALID CHANNEL_PRIVATE CHANNEL_PUBLIC_GROUP_NA USER_CREATOR USER_NOT_PARTICIPANT
60 channels.readHistory user CHANNEL_INVALID CHANNEL_PRIVATE