-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d6fa5b
commit 17eb918
Showing
1 changed file
with
12 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!") |