new command

for generating list of all active group call in bot database
This commit is contained in:
levina 2022-02-09 06:05:26 +07:00 committed by GitHub
parent af4020bafb
commit bf7f83f324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,6 @@ from pyrogram.types import Message
from pyrogram import Client, filters, __version__ as pyrover from pyrogram import Client, filters, __version__ as pyrover
from pytgcalls import (__version__ as pytgver) from pytgcalls import (__version__ as pytgver)
from program import __version__ as ver from program import __version__ as ver
from program.start import __python_version__ as pyver from program.start import __python_version__ as pyver
@ -15,6 +14,7 @@ from driver.decorators import bot_creator, sudo_users_only
from driver.database.dbchat import get_served_chats from driver.database.dbchat import get_served_chats
from driver.database.dbusers import get_served_users from driver.database.dbusers import get_served_users
from driver.database.dbpunish import get_gbans_count from driver.database.dbpunish import get_gbans_count
from driver.database.dbqueue import get_active_chats
from config import BOT_NAME as name, BOT_USERNAME as uname from config import BOT_NAME as name, BOT_USERNAME as uname
@ -123,7 +123,7 @@ async def broadcast_message_pin(c: Client, message: Message):
@Client.on_message(command(["stats", f"stats@{uname}"]) & ~filters.edited) @Client.on_message(command(["stats", f"stats@{uname}"]) & ~filters.edited)
@sudo_users_only @sudo_users_only
async def broadcast(c: Client, message: Message): async def bot_statistic(c: Client, message: Message):
chat_id = message.chat.id chat_id = message.chat.id
user_id = message.from_user.id user_id = message.from_user.id
msg = await c.send_message( msg = await c.send_message(
@ -146,3 +146,37 @@ async def broadcast(c: Client, message: Message):
🤖 bot version: `{ver}`""" 🤖 bot version: `{ver}`"""
await msg.edit(tgm, disable_web_page_preview=True) await msg.edit(tgm, disable_web_page_preview=True)
@Client.on_message(command(["calls", f"calls@{uname}"]) & ~filters.edited)
@sudo_users_only
async def active_calls(c: Client, message: Message):
served_chats = []
try:
chats = await get_active_chats()
for chat in chats:
served_chats.append(int(chat["chat_id"]))
except Exception as e:
await message.reply_text(f"🚫 error: `{e}`")
text = ""
j = 0
for x in served_chats:
try:
title = (await c.get_chat(x)).title
except Exception:
title = "Private Group"
if (await c.get_chat(x)).username:
user = (await c.get_chat(x)).username
text += (
f"**{j + 1}.** [{title}](https://t.me/{user}) [`{x}`]\n"
)
else:
text += f"**{j + 1}.** {title} [`{x}`]\n"
j += 1
if not text:
await message.reply_text("❌ no active group calls")
else:
await message.reply_text(
f"✏️ **Active video chats list:**\n\n{text}",
disable_web_page_preview=True,
)