You can download this code by clicking the button below.
This code is now available for download.
This function uses the Pyrogram library to send a random sticker to a specified chat ID.
Technology Stack : Pyrogram
Code Type : Pyrogram API Function
Code Difficulty : Intermediate
def send_random_sticker(chat_id, sticker_id):
from pyrogram import Client, enums
from pyrogram.errors import FloodWait
app = Client("my_bot", session_name="send_sticker_bot")
try:
app.send_sticker(chat_id, sticker_id)
except FloodWait as e:
print(f"Waiting for {e.x} seconds before sending another sticker.")
finally:
app.stop()