11#(©)Codexbotz
2-
2+ import os
33import asyncio
44from pyrogram import Client , filters , __version__
55from pyrogram .types import Message , InlineKeyboardMarkup , InlineKeyboardButton
88from bot import Bot
99from config import ADMINS , START_MSG , OWNER_ID , CUSTOM_CAPTION , DISABLE_CHANNEL_BUTTON
1010from helper_func import subscribed , encode , decode , get_messages
11+ from database .support import users_info
12+ from database .sql import add_user , query_msg
13+
14+
15+ #=====================================================================================##
16+
17+ USERS_LIST = """<b>⭕️Total:</b>\n \n ⭕️Subscribers - {}\n ⭕️Blocked- {}"""
18+
19+ WAIT_MSG = """"<b>Processing ...</b>"""
20+
21+ REPLY_ERROR = """<code>Use this command as a replay to any telegram message with out any spaces.</code>"""
22+
23+
24+ #=====================================================================================##
25+
1126
1227@Bot .on_message (filters .command ('start' ) & filters .private & subscribed )
1328async def start_command (client : Client , message : Message ):
29+ id = message .from_user .id
30+ user_name = '@' + message .from_user .username if message .from_user .username else None
31+ await add_user (id , user_name )
1432 text = message .text
1533 if len (text )> 7 :
1634 try :
@@ -108,3 +126,43 @@ async def not_joined(client: Client, message: Message):
108126 quote = True ,
109127 disable_web_page_preview = True
110128 )
129+
130+ @Bot .on_message (filters .private & filters .command ('users' ))
131+ async def subscribers_count (bot , m : Message ):
132+ id = m .from_user .id
133+ if id not in ADMINS :
134+ return
135+ msg = await m .reply_text (WAIT_MSG )
136+ messages = await users_info (bot )
137+ active = messages [0 ]
138+ blocked = messages [1 ]
139+ await m .delete ()
140+ await msg .edit (USERS_LIST .format (active , blocked ))
141+
142+
143+
144+ @Bot .on_message (filters .private & filters .command ('broadcast' ))
145+ async def send_text (bot , m : Message ):
146+ id = m .from_user .id
147+ if id not in ADMINS :
148+ return
149+ if (" " not in m .text ) and ("broadcast" in m .text ) and (m .reply_to_message is not None ):
150+ query = await query_msg ()
151+ for row in query :
152+ chat_id = int (row [0 ])
153+ try :
154+ await bot .copy_message (
155+ chat_id = chat_id ,
156+ from_chat_id = m .chat .id ,
157+ message_id = m .reply_to_message .message_id ,
158+ caption = m .caption ,
159+ reply_markup = m .reply_markup
160+ )
161+ except FloodWait as e :
162+ await asyncio .sleep (e .x )
163+ except Exception :
164+ pass
165+ else :
166+ msg = await m .reply_text (REPLY_ERROR , m .message_id )
167+ await asyncio .sleep (8 )
168+ await msg .delete ()
0 commit comments