Skip to content

Commit

Permalink
Added Broadcast On 13 Jan
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTeamAlexa authored Jan 13, 2024
1 parent 7d6fa5b commit 17eb918
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions StringSessionBot/gcast.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
# This code is written by TheTaemAlexa on Jan 13, 2024
# This code is written by TheTaemAlexa

from pyrogram import Client, filters
from pyrogram.types import Message


owner_id = 6174058850
user_ids = {}


@Client.on_message(filters.command("gcast") & filters.private)
def gcast_command(client, message):
async def gcast_command(client, message):
if message.from_user.id == owner_id:
users = client.get_chat_members(message.chat.id)
message.reply_text("Enter the message you want to broadcast:")
client.register_message_handler(
handle_broadcast, (filters.text & filters.private), state=users
)
users = await client.get_chat_members(message.chat.id)
await message.reply_text("Enter the message you want to broadcast:")
client.add_message_handler(handle_broadcast, (filters.text & filters.private), state=users)
else:
message.reply_text("You are not authorized to use this command.")

await message.reply_text("You are not authorized to use this command.")

def handle_broadcast(client, message):
users = message.text.split("\n")
async def handle_broadcast(client, message):
users = message.text.split('\n')
delivered_count = 0

for user_id in users:
try:
user_id = int(user_id)
client.send_message(
user_id, "Broadcast message By @TheTeamAlexa: " + message.text
)
await client.send_message(user_id, "Broadcast message By @TheTeamAlexa: " + message.text)
user_ids[user_id] = message.chat.id
delivered_count += 1
except ValueError:
pass
message.reply_text(f"Broadcast sent successfully to {delivered_count} users/chats!")
await message.reply_text(f"Broadcast sent successfully to {delivered_count} users/chats!")

0 comments on commit 17eb918

Please sign in to comment.