mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-03 14:04:51 +00:00
Add updates example
This commit is contained in:
parent
0219ac0b5a
commit
1fca99c712
1 changed files with 25 additions and 0 deletions
25
examples/updates.py
Normal file
25
examples/updates.py
Normal file
|
|
@ -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()
|
||||||
Loading…
Reference in a new issue