From 1fca99c7124c1fff7002a9bd8bf571409be2a265 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 26 Feb 2018 16:07:48 +0100 Subject: [PATCH] Add updates example --- examples/updates.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/updates.py diff --git a/examples/updates.py b/examples/updates.py new file mode 100644 index 00000000..db28eeb6 --- /dev/null +++ b/examples/updates.py @@ -0,0 +1,25 @@ +from pyrogram import Client + + +# This function will be called every time a new Update is received from Telegram +def update_handler(client, update, users, chats): + # Send EVERY update that arrives to your own chat (Saved Messages) + # Use triple backticks to make the text look nicer. + client.send_message("me", "```\n" + str(update) + "```") + + +def main(): + # Pyrogram setup + client = Client("example") + + # Set the update_handler callback function + client.set_update_handler(update_handler) + client.start() + + # Blocks the program execution until you press CTRL+C then + # automatically stops the Client by closing the underlying connection + client.idle() + + +if __name__ == "__main__": + main()