Skip to content

Commit

Permalink
No !!!
Browse files Browse the repository at this point in the history
  • Loading branch information
KSKOP69 committed Nov 5, 2024
1 parent 07846ad commit 0a842cc
Showing 1 changed file with 0 additions and 283 deletions.
283 changes: 0 additions & 283 deletions AlexaMusic/plugins/modules/broadcast.py
Original file line number Diff line number Diff line change
@@ -1,283 +0,0 @@
# Copyright (C) 2024 by Alexa_Help @ Github, < https://github.com/TheTeamAlexa >
# Subscribe On YT < Jankari Ki Duniya >. All rights reserved. © Alexa © Yukki.

""""
TheTeamAlexa is a project of Telegram bots with variety of purposes.
Copyright (c) 2024 -present Team=Alexa <https://github.com/TheTeamAlexa>
This program is free software: you can redistribute it and can modify
as you want or you can collabe if you have new ideas.
"""


import asyncio
from datetime import datetime, timedelta

from pyrogram import filters
from pyrogram.errors import FloodWait
from pyrogram.raw import types

import config
from config import adminlist, chatstats, clean, userstats
from pyrogram.enums import ChatMembersFilter
from strings import get_command
from AlexaMusic import app, userbot
from AlexaMusic.misc import SUDOERS
from AlexaMusic.utils.database import (
get_active_chats,
get_authuser_names,
get_client,
get_particular_top,
get_served_chats,
get_served_users,
get_user_top,
is_cleanmode_on,
set_queries,
update_particular_top,
update_user_top,
)
from AlexaMusic.utils.decorators.language import language
from AlexaMusic.utils.formatters import alpha_to_int
from config import OWNER_ID

BROADCAST_COMMAND = get_command("BROADCAST_COMMAND")
AUTO_DELETE = config.CLEANMODE_DELETE_MINS
AUTO_SLEEP = 5
IS_BROADCASTING = False
cleanmode_group = 15


@app.on_raw_update(group=cleanmode_group)
async def clean_mode(client, update, users, chats):
global IS_BROADCASTING
if IS_BROADCASTING:
return
try:
if not isinstance(update, types.UpdateReadChannelOutbox):
return
except:
return
if users:
return
if chats:
return
message_id = update.max_id
chat_id = int(f"-100{update.channel_id}")
if not await is_cleanmode_on(chat_id):
return
if chat_id not in clean:
clean[chat_id] = []
time_now = datetime.now()
put = {
"msg_id": message_id,
"timer_after": time_now + timedelta(minutes=AUTO_DELETE),
}
clean[chat_id].append(put)
await set_queries(1)


@app.on_message(filters.command(BROADCAST_COMMAND))
@language
async def braodcast_message(client, message, _):
if message.from_user.id not in OWNER_ID:
return await message.reply_text(
"» **😁 ʜᴇʜᴇʜᴇ ᴏɴʟʏ ᴍʏ ᴏᴡɴᴇʀ ᴄᴀɴ ʙʀᴏᴀᴅᴄᴀsᴛ**\n» 🤫 ᴊᴏɪɴ @Alexa_Help ғᴏʀ ᴘʀᴏᴍᴏᴛɪᴏɴ"
)
global IS_BROADCASTING
if message.reply_to_message:
x = message.reply_to_message.id
y = message.chat.id
else:
if len(message.command) < 2:
return await message.reply_text(_["broad_5"])
query = message.text.split(None, 1)[1]
if "-pin" in query:
query = query.replace("-pin", "")
if "-nobot" in query:
query = query.replace("-nobot", "")
if "-pinloud" in query:
query = query.replace("-pinloud", "")
if "-assistant" in query:
query = query.replace("-assistant", "")
if "-user" in query:
query = query.replace("-user", "")
if query == "":
return await message.reply_text(_["broad_6"])

IS_BROADCASTING = True

# Bot broadcast inside chats
if "-nobot" not in message.text:
sent = 0
pin = 0
chats = []
schats = await get_served_chats()
for chat in schats:
chats.append(int(chat["chat_id"]))
for i in chats:
if i == config.LOG_GROUP_ID:
continue
try:
m = (
await app.forward_messages(i, y, x)
if message.reply_to_message
else await app.send_message(i, text=query)
)
if "-pin" in message.text:
try:
await m.pin(disable_notification=True)
pin += 1
except Exception:
continue
elif "-pinloud" in message.text:
try:
await m.pin(disable_notification=False)
pin += 1
except Exception:
continue
sent += 1
except FloodWait as e:
flood_time = int(e.x)
if flood_time > 200:
continue
await asyncio.sleep(flood_time)
except Exception:
continue
try:
await message.reply_text(_["broad_1"].format(sent, pin))
except:
pass

# Bot broadcasting to users
if "-user" in message.text:
susr = 0
served_users = []
susers = await get_served_users()
for user in susers:
served_users.append(int(user["user_id"]))
for i in served_users:
try:
m = (
await app.forward_messages(i, y, x)
if message.reply_to_message
else await app.send_message(i, text=query)
)
susr += 1
except FloodWait as e:
flood_time = int(e.x)
if flood_time > 200:
continue
await asyncio.sleep(flood_time)
except Exception:
pass
try:
await message.reply_text(_["broad_7"].format(susr))
except:
pass

# Bot broadcasting by assistant
if "-assistant" in message.text:
aw = await message.reply_text(_["broad_2"])
text = _["broad_3"]
from AlexaMusic.core.userbot import assistants

for num in assistants:
sent = 0
client = await get_client(num)
async for dialog in client.get_dialogs():
if dialog.chat.id == config.LOG_GROUP_ID:
continue
try:
(
await client.forward_messages(dialog.chat.id, y, x)
if message.reply_to_message
else await client.send_message(dialog.chat.id, text=query)
)
sent += 1
except FloodWait as e:
flood_time = int(e.x)
if flood_time > 200:
continue
await asyncio.sleep(flood_time)
except Exception as e:
print(e)
continue
text += _["broad_4"].format(num, sent)
try:
await aw.edit_text(text)
except:
pass
IS_BROADCASTING = False


async def auto_clean():
while not await asyncio.sleep(AUTO_SLEEP):
try:
for chat_id in chatstats:
for dic in chatstats[chat_id]:
vidid = dic["vidid"]
title = dic["title"]
chatstats[chat_id].pop(0)
spot = await get_particular_top(chat_id, vidid)
if spot:
spot = spot["spot"]
next_spot = spot + 1
new_spot = {"spot": next_spot, "title": title}
await update_particular_top(chat_id, vidid, new_spot)
else:
next_spot = 1
new_spot = {"spot": next_spot, "title": title}
await update_particular_top(chat_id, vidid, new_spot)
for user_id in userstats:
for dic in userstats[user_id]:
vidid = dic["vidid"]
title = dic["title"]
userstats[user_id].pop(0)
spot = await get_user_top(user_id, vidid)
if spot:
spot = spot["spot"]
next_spot = spot + 1
new_spot = {"spot": next_spot, "title": title}
await update_user_top(user_id, vidid, new_spot)
else:
next_spot = 1
new_spot = {"spot": next_spot, "title": title}
await update_user_top(user_id, vidid, new_spot)
except:
continue
try:
for chat_id in clean:
if chat_id == config.LOG_GROUP_ID:
continue
for x in clean[chat_id]:
if datetime.now() > x["timer_after"]:
try:
await app.delete_messages(chat_id, x["msg_id"])
except FloodWait as e:
await asyncio.sleep(e.x)
except:
continue
else:
continue
except:
continue
try:
served_chats = await get_active_chats()
for chat_id in served_chats:
if chat_id not in adminlist:
adminlist[chat_id] = []
admins = app.get_chat_members(
chat_id, filter=ChatMembersFilter.ADMINISTRATORS
)
async for user in admins:
if user.privileges.can_manage_video_chats:
adminlist[chat_id].append(user.user.id)
authusers = await get_authuser_names(chat_id)
for user in authusers:
user_id = await alpha_to_int(user)
adminlist[chat_id].append(user_id)
except:
continue


asyncio.create_task(auto_clean())

0 comments on commit 0a842cc

Please sign in to comment.