From 1b424b3fe7accb14ae5e10015e1d93c00fc134cd Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 3 Jan 2019 19:20:52 +0100 Subject: [PATCH] Update documentation to reflect new methods --- .../extra/examples/telegram-client.rst | 35 ++++++++++++++++++- readthedocs/index.rst | 1 + readthedocs/telethon.tl.custom.rst | 8 +++++ telethon_generator/data/errors.csv | 1 + telethon_generator/data/methods.csv | 2 +- 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/readthedocs/extra/examples/telegram-client.rst b/readthedocs/extra/examples/telegram-client.rst index b97cff6c..b9e08665 100644 --- a/readthedocs/extra/examples/telegram-client.rst +++ b/readthedocs/extra/examples/telegram-client.rst @@ -402,7 +402,7 @@ location, phone number, or simply for them to easily send a message: .. code-block:: python client.send_message(chat, 'Welcome', buttons=[ - Button.text('Thanks!'), + Button.text('Thanks!', resize=True, single_use=True), Button.request_phone('Send phone'), Button.request_location('Send location') ]) @@ -644,3 +644,36 @@ Note that the utils package also has a `get_peer_id ` but it won't work with things that need access to the network such as usernames or phones, 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 +`, and be sure +to also check the properties of the returned `AdminLogEvent +` to know what +you can access. diff --git a/readthedocs/index.rst b/readthedocs/index.rst index 110f4da7..236a9742 100644 --- a/readthedocs/index.rst +++ b/readthedocs/index.rst @@ -19,6 +19,7 @@ when you upgrade! * Are you new here? Jump straight into :ref:`getting-started`! * Looking for available friendly methods? See :ref:`telethon-client`. * Used Telethon before v1.0? See :ref:`compatibility-and-convenience`. + * Need the full API reference? https://lonamiwebs.github.io/Telethon/. What is this? diff --git a/readthedocs/telethon.tl.custom.rst b/readthedocs/telethon.tl.custom.rst index 1c1de4d0..3187e315 100644 --- a/readthedocs/telethon.tl.custom.rst +++ b/readthedocs/telethon.tl.custom.rst @@ -97,3 +97,11 @@ telethon\.tl\.custom\.conversation module :members: :undoc-members: :show-inheritance: + +telethon\.tl\.custom\.adminlogevent module +------------------------------------------ + +.. automodule:: telethon.tl.custom.adminlogevent + :members: + :undoc-members: + :show-inheritance: diff --git a/telethon_generator/data/errors.csv b/telethon_generator/data/errors.csv index fc640bc4..54aa8791 100644 --- a/telethon_generator/data/errors.csv +++ b/telethon_generator/data/errors.csv @@ -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_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_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_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 diff --git a/telethon_generator/data/methods.csv b/telethon_generator/data/methods.csv index 36884d65..02e9b1c2 100644 --- a/telethon_generator/data/methods.csv +++ b/telethon_generator/data/methods.csv @@ -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.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.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.leaveChannel,unknown,CHANNEL_INVALID CHANNEL_PRIVATE CHANNEL_PUBLIC_GROUP_NA USER_CREATOR USER_NOT_PARTICIPANT channels.readHistory,user,CHANNEL_INVALID CHANNEL_PRIVATE