MCPcopy Create free account
hub / github.com/VJBots/VJ-File-Store / verupikkals

Function verupikkals

plugins/broadcast.py:42–87  ·  view source on GitHub ↗
(bot, message)

Source from the content-addressed store, hash-verified

40
41@Client.on_message(filters.command("broadcast") & filters.user(ADMINS) & filters.reply)
42async def verupikkals(bot, message):
43 users = await db.get_all_users()
44 b_msg = message.reply_to_message
45 sts = await message.reply_text(text='**Broadcasting your messages...**')
46 start_time = time.time()
47 total_users = await db.total_users_count()
48 done = 0
49 blocked = 0
50 deleted = 0
51 failed = 0
52 success = 0
53
54# Don't Remove Credit Tg - @VJ_Bots
55# Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ
56# Ask Doubt on telegram @KingVJ01
57
58 async for user in users:
59 if 'id' in user:
60 pti, sh = await broadcast_messages(int(user['id']), b_msg)
61 if pti:
62 success += 1
63 elif pti == False:
64 if sh == "Blocked":
65 blocked += 1
66 elif sh == "Deleted":
67 deleted += 1
68 elif sh == "Error":
69 failed += 1
70 done += 1
71 if not done % 20:
72 try:
73 await sts.edit(f"Broadcast in progress:\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}")
74 except:
75 pass
76 else:
77 # Handle the case where 'id' key is missing in the user dictionary
78 done += 1
79 failed += 1
80 if not done % 20:
81 try:
82 await sts.edit(f"Broadcast in progress:\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}")
83 except:
84 pass
85
86 time_taken = datetime.timedelta(seconds=int(time.time()-start_time))
87 await sts.edit(f"Broadcast Completed:\nCompleted in {time_taken} seconds.\n\nTotal Users {total_users}\nCompleted: {done} / {total_users}\nSuccess: {success}\nBlocked: {blocked}\nDeleted: {deleted}")
88
89# Don't Remove Credit Tg - @VJ_Bots
90# Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ

Callers

nothing calls this directly

Calls 3

broadcast_messagesFunction · 0.70
get_all_usersMethod · 0.45
total_users_countMethod · 0.45

Tested by

no test coverage detected