💡 TBC Broadcast Working Code All Type Like Photo Video Etc!
➡️ Command:- /broadcast
# Admin ID
admin_id = "5960085256"
# Command: /broadcast
if admin_id != str(u):
raise ReturnCommand()
if options is None:
bot.replyText(
u,
"<b>🎙️ Send Any Message to Broadcast in HTML\n\nTo Cancel: /cancel</b>",
parse_mode="html",
)
Bot.handleNextCommand("/broadcast", options=True)
raise ReturnCommand()
if message.text == "/cancel":
bot.sendMessage(
chat_id=u, text="<b>❌ Broadcast Cancelled</b>", parse_mode="html"
)
raise ReturnCommand()
file_types = {
"photo": ("send_photo", message.photo[0].file_id if message.photo else None),
"video": ("send_video", message.video.file_id if message.video else None),
"audio": ("send_audio", message.audio.file_id if message.audio else None),
"document": ("send_document", message.document.file_id if message.document else None),
"sticker": ("send_sticker", message.sticker.file_id if message.sticker else None),
"animation": ("send_animation", message.animation.file_id if message.animation else None),
"voice": ("send_voice", message.voice.file_id if message.voice else None),
}
response = None # To store broadcast response
for key, (func, file_id) in file_types.items():
if file_id:
# Send the file with an optional caption
caption = message.caption if 'caption' in message else ""
response = Bot.broadcast(
function=func,
**{key: file_id},
caption=caption if func != "send_sticker" else None,
)
break
if not response and message.text:
response = Bot.broadcast(function="send_message", text=message.text, parse_mode="html")
elif not response and message.forward_from:
response = Bot.broadcast(
function="forward_message",
from_chat_id=message.chat.id,
message_id=message.message_id,
)
success_msg = (
"Broadcast completed successfully! ✅"
if response and 'broadcast_id' in response
else "Broadcast failed! ❌"
)
bot.sendMessage(chat_id=u, text=success_msg)
⚠️ 𝐆ɪᴠᴇ ᴄʀᴇᴅɪᴛ ɪғ ʏᴏᴜ ᴀʀᴇ ᴘᴏsᴛɪɴɢ ᴏɴ ʏᴏᴜʀ ᴄʜᴀɴɴᴇʟ.
© 𝐂ᴏᴘʏɪɴɢ ᴀɴᴅ ᴘᴜʙʟɪsʜɪɴɢ ᴄᴏᴅᴇ ᴀɴʏᴡʜᴇʀᴇ ᴏʀ sᴇʟʟɪɴɢ ᴛʜᴇ ᴀʙᴏᴠᴇ ᴄᴏᴅᴇ ɪs sᴛʀɪᴄᴛʟʏ ɴᴏᴛ ᴀʟʟᴏᴡᴇᴅ. 𝐑ɪɢʜᴛ ᴏғ ᴛʜᴇ ᴀʙᴏᴠᴇ ᴄᴏᴅᴇs ʙᴇʟᴏɴɢ ᴛᴏ ᴛʜᴇ ᴄᴏᴅᴇ ᴏᴡɴᴇʀ ᴀɴᴅ ᴏᴡɴᴇʀ ᴏғ ᴛʜᴇ ᴛʜɪs ᴄʜᴀɴɴᴇʟ. 𝐒ᴛɪʟʟ ɪғ ᴀɴʏᴏɴᴇ ʜᴀᴠᴇ ᴀɴʏ ᴘʀᴏʙʟᴇᴍ ʀᴇɢᴀʀᴅɪɴɢ ᴄᴏᴘʏʀɪɢʜᴛ ᴄᴀɴ ᴄᴏɴᴛᴀᴄᴛ ᴜs.