MCPcopy Index your code
hub / github.com/CodeXBotz/File-Sharing-Bot / send_text

Function send_text

plugins/start.py:162–205  ·  view source on GitHub ↗
(client: Bot, message: Message)

Source from the content-addressed store, hash-verified

160
161@Bot.on_message(filters.private & filters.command('broadcast') & filters.user(ADMINS))
162async def send_text(client: Bot, message: Message):
163 if message.reply_to_message:
164 query = await full_userbase()
165 broadcast_msg = message.reply_to_message
166 total = 0
167 successful = 0
168 blocked = 0
169 deleted = 0
170 unsuccessful = 0
171
172 pls_wait = await message.reply("<i>Broadcasting Message.. This will Take Some Time</i>")
173 for chat_id in query:
174 try:
175 await broadcast_msg.copy(chat_id)
176 successful += 1
177 except FloodWait as e:
178 await asyncio.sleep(e.x)
179 await broadcast_msg.copy(chat_id)
180 successful += 1
181 except UserIsBlocked:
182 await del_user(chat_id)
183 blocked += 1
184 except InputUserDeactivated:
185 await del_user(chat_id)
186 deleted += 1
187 except:
188 unsuccessful += 1
189 pass
190 total += 1
191
192 status = f"""<b><u>Broadcast Completed</u>
193
194Total Users: <code>{total}</code>
195Successful: <code>{successful}</code>
196Blocked Users: <code>{blocked}</code>
197Deleted Accounts: <code>{deleted}</code>
198Unsuccessful: <code>{unsuccessful}</code></b>"""
199
200 return await pls_wait.edit(status)
201
202 else:
203 msg = await message.reply(REPLY_ERROR)
204 await asyncio.sleep(8)
205 await msg.delete()

Callers

nothing calls this directly

Calls 2

full_userbaseFunction · 0.90
del_userFunction · 0.90

Tested by

no test coverage detected