2022-02-22 23:16:07 +00:00
|
|
|
|
"""
|
|
|
|
|
Video + Music Stream Telegram Bot
|
|
|
|
|
Copyright (c) 2022-present levina=lab <https://github.com/levina-lab>
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but without any warranty; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/licenses.html>
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
2022-02-13 06:27:09 +00:00
|
|
|
|
import traceback
|
|
|
|
|
|
2022-01-31 12:41:47 +00:00
|
|
|
|
from cache.admins import admins
|
2022-02-21 08:51:06 +00:00
|
|
|
|
from driver.core import calls
|
2022-01-31 12:41:47 +00:00
|
|
|
|
from pyrogram import Client, filters
|
2022-02-02 15:06:03 +00:00
|
|
|
|
from driver.design.thumbnail import thumb
|
|
|
|
|
from driver.design.chatname import CHAT_TITLE
|
2022-01-31 12:41:47 +00:00
|
|
|
|
from driver.queues import QUEUE, clear_queue
|
|
|
|
|
from driver.filters import command, other_filters
|
2022-02-14 05:38:16 +00:00
|
|
|
|
from driver.decorators import authorized_users_only, check_blacklist
|
2022-02-13 06:43:13 +00:00
|
|
|
|
from driver.utils import skip_current_song, skip_item, remove_if_exists
|
2022-02-21 08:51:06 +00:00
|
|
|
|
from config import BOT_USERNAME, IMG_5
|
2022-02-11 01:58:32 +00:00
|
|
|
|
|
2022-02-10 22:21:21 +00:00
|
|
|
|
from driver.database.dbqueue import (
|
|
|
|
|
is_music_playing,
|
|
|
|
|
remove_active_chat,
|
|
|
|
|
music_off,
|
|
|
|
|
music_on,
|
|
|
|
|
)
|
2022-02-21 08:51:06 +00:00
|
|
|
|
from program.utils.inline import stream_markup, close_mark
|
2022-01-31 12:41:47 +00:00
|
|
|
|
from pyrogram.types import (
|
|
|
|
|
CallbackQuery,
|
|
|
|
|
InlineKeyboardMarkup,
|
|
|
|
|
Message,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_message(command(["reload", f"reload@{BOT_USERNAME}"]) & other_filters)
|
|
|
|
|
@authorized_users_only
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-02-06 05:46:06 +00:00
|
|
|
|
async def update_admin(client, message: Message):
|
2022-01-31 12:41:47 +00:00
|
|
|
|
global admins
|
|
|
|
|
new_admins = []
|
|
|
|
|
new_ads = await client.get_chat_members(message.chat.id, filter="administrators")
|
|
|
|
|
for u in new_ads:
|
|
|
|
|
new_admins.append(u.user.id)
|
|
|
|
|
admins[message.chat.id] = new_admins
|
|
|
|
|
await message.reply_text(
|
2022-03-02 13:01:45 +00:00
|
|
|
|
"✅ **重载完成!**\n"
|
|
|
|
|
"✅ **管理员列表已经刷新!**"
|
2022-01-31 12:41:47 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_message(
|
|
|
|
|
command(["stop", f"stop@{BOT_USERNAME}", "end", f"end@{BOT_USERNAME}", "vstop"])
|
|
|
|
|
& other_filters
|
|
|
|
|
)
|
|
|
|
|
@authorized_users_only
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-01-31 12:41:47 +00:00
|
|
|
|
async def stop(client, m: Message):
|
|
|
|
|
chat_id = m.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
2022-02-07 16:14:32 +00:00
|
|
|
|
await calls.leave_group_call(chat_id)
|
2022-02-10 22:21:21 +00:00
|
|
|
|
await remove_active_chat(chat_id)
|
2022-01-31 12:41:47 +00:00
|
|
|
|
clear_queue(chat_id)
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("✅ 成功退出语音聊天")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply(f"🚫 **错误:**\n\n`{e}`")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("❌ **队列为空**")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_message(
|
|
|
|
|
command(["pause", f"pause@{BOT_USERNAME}", "vpause"]) & other_filters
|
|
|
|
|
)
|
|
|
|
|
@authorized_users_only
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-01-31 12:41:47 +00:00
|
|
|
|
async def pause(client, m: Message):
|
|
|
|
|
chat_id = m.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
2022-02-10 22:21:21 +00:00
|
|
|
|
if not await is_music_playing(chat_id):
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("ℹ️ 已经暂停!")
|
2022-02-10 22:21:21 +00:00
|
|
|
|
return
|
2022-02-07 16:14:32 +00:00
|
|
|
|
await calls.pause_stream(chat_id)
|
2022-02-10 22:21:21 +00:00
|
|
|
|
await music_off(chat_id)
|
2022-01-31 12:41:47 +00:00
|
|
|
|
await m.reply(
|
2022-03-02 13:01:45 +00:00
|
|
|
|
"⏸ **已经暂停**\n\n• **恢复播放请发送下列命令**\n» /resume"
|
2022-01-31 12:41:47 +00:00
|
|
|
|
)
|
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply(f"🚫 **错误:**\n\n`{e}`")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("❌ **队列为空**")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_message(
|
|
|
|
|
command(["resume", f"resume@{BOT_USERNAME}", "vresume"]) & other_filters
|
|
|
|
|
)
|
|
|
|
|
@authorized_users_only
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-01-31 12:41:47 +00:00
|
|
|
|
async def resume(client, m: Message):
|
|
|
|
|
chat_id = m.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
2022-02-10 22:55:25 +00:00
|
|
|
|
if await is_music_playing(chat_id):
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("ℹ️ 已经恢复!")
|
2022-02-10 22:21:21 +00:00
|
|
|
|
return
|
2022-02-07 16:14:32 +00:00
|
|
|
|
await calls.resume_stream(chat_id)
|
2022-02-10 22:21:21 +00:00
|
|
|
|
await music_on(chat_id)
|
2022-01-31 12:41:47 +00:00
|
|
|
|
await m.reply(
|
2022-03-02 13:01:45 +00:00
|
|
|
|
"▶️ **已经恢复**\n\n• **暂停播放请发送下列命令**\n» /pause"
|
2022-01-31 12:41:47 +00:00
|
|
|
|
)
|
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply(f"🚫 **错误:**\n\n`{e}`")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("❌ **队列为空**")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
|
|
|
|
|
|
2022-02-10 22:21:21 +00:00
|
|
|
|
@Client.on_message(command(["skip", f"skip@{BOT_USERNAME}", "vskip"]) & other_filters)
|
|
|
|
|
@authorized_users_only
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-02-10 22:21:21 +00:00
|
|
|
|
async def skip(c: Client, m: Message):
|
|
|
|
|
user_id = m.from_user.id
|
|
|
|
|
chat_id = m.chat.id
|
|
|
|
|
if len(m.command) < 2:
|
|
|
|
|
op = await skip_current_song(chat_id)
|
|
|
|
|
if op == 0:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await c.send_message(chat_id, "❌ 错误,队列为空!")
|
2022-02-10 22:21:21 +00:00
|
|
|
|
elif op == 1:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await c.send_message(chat_id, "» 全部歌曲已播放完毕,自动退出语音聊天")
|
2022-02-10 22:21:21 +00:00
|
|
|
|
elif op == 2:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await c.send_message(chat_id, "🗑️ **已经清空队列**\n\n• 自动退出语音聊天")
|
2022-02-10 22:21:21 +00:00
|
|
|
|
else:
|
|
|
|
|
buttons = stream_markup(user_id)
|
|
|
|
|
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
|
|
|
thumbnail = f"{IMG_5}"
|
|
|
|
|
title = f"{op[0]}"
|
|
|
|
|
userid = m.from_user.id
|
|
|
|
|
gcname = m.chat.title
|
|
|
|
|
ctitle = await CHAT_TITLE(gcname)
|
|
|
|
|
image = await thumb(thumbnail, title, userid, ctitle)
|
|
|
|
|
await c.send_photo(
|
|
|
|
|
chat_id,
|
|
|
|
|
photo=image,
|
|
|
|
|
reply_markup=InlineKeyboardMarkup(buttons),
|
2022-03-02 13:01:45 +00:00
|
|
|
|
caption=f"⏭ **跳到下一首** \n\n"
|
|
|
|
|
f"🗂 **名称:** [{op[0]}]({op[1]})\n"
|
|
|
|
|
f"💭 **会话:** `{chat_id}`\n"
|
|
|
|
|
f"🧸 **添加者:** {requester}",
|
2022-02-10 22:21:21 +00:00
|
|
|
|
)
|
2022-02-13 06:43:13 +00:00
|
|
|
|
remove_if_exists(image)
|
2022-02-10 22:21:21 +00:00
|
|
|
|
else:
|
|
|
|
|
skip = m.text.split(None, 1)[1]
|
2022-03-02 13:01:45 +00:00
|
|
|
|
track = "🗑 已从队列中删除:"
|
2022-02-10 22:21:21 +00:00
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
items = [int(x) for x in skip.split(" ") if x.isdigit()]
|
|
|
|
|
items.sort(reverse=True)
|
|
|
|
|
for x in items:
|
|
|
|
|
if x == 0:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
data = await skip_item(chat_id, x)
|
|
|
|
|
if data == 0:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
2022-02-21 08:51:06 +00:00
|
|
|
|
track = track + "\n" + f"**#{x}** - {data}"
|
2022-02-10 22:21:21 +00:00
|
|
|
|
await m.reply(track)
|
|
|
|
|
|
|
|
|
|
|
2022-01-31 12:41:47 +00:00
|
|
|
|
@Client.on_message(
|
|
|
|
|
command(["mute", f"mute@{BOT_USERNAME}", "vmute"]) & other_filters
|
|
|
|
|
)
|
|
|
|
|
@authorized_users_only
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-01-31 12:41:47 +00:00
|
|
|
|
async def mute(client, m: Message):
|
|
|
|
|
chat_id = m.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
2022-02-10 22:21:21 +00:00
|
|
|
|
if not await is_music_playing(chat_id):
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("ℹ️ 已经静音!")
|
2022-02-10 22:21:21 +00:00
|
|
|
|
return
|
2022-02-07 16:14:32 +00:00
|
|
|
|
await calls.mute_stream(chat_id)
|
2022-02-10 22:21:21 +00:00
|
|
|
|
await music_off(chat_id)
|
2022-01-31 12:41:47 +00:00
|
|
|
|
await m.reply(
|
2022-03-02 13:01:45 +00:00
|
|
|
|
"🔇 **已经静音**\n\n• **解除静音请发送下列命令**\n» /unmute"
|
2022-01-31 12:41:47 +00:00
|
|
|
|
)
|
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply(f"🚫 **错误:**\n\n`{e}`")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("❌ **队列为空**")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_message(
|
|
|
|
|
command(["unmute", f"unmute@{BOT_USERNAME}", "vunmute"]) & other_filters
|
|
|
|
|
)
|
|
|
|
|
@authorized_users_only
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-01-31 12:41:47 +00:00
|
|
|
|
async def unmute(client, m: Message):
|
|
|
|
|
chat_id = m.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
2022-02-10 22:55:25 +00:00
|
|
|
|
if await is_music_playing(chat_id):
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("ℹ️ 已经恢复!")
|
2022-02-10 22:21:21 +00:00
|
|
|
|
return
|
2022-02-07 16:14:32 +00:00
|
|
|
|
await calls.unmute_stream(chat_id)
|
2022-02-10 22:21:21 +00:00
|
|
|
|
await music_on(chat_id)
|
2022-01-31 12:41:47 +00:00
|
|
|
|
await m.reply(
|
2022-03-02 13:01:45 +00:00
|
|
|
|
"🔊 **已解除静音**\n\n• **静音请发送下列命令**\n» /mute"
|
2022-01-31 12:41:47 +00:00
|
|
|
|
)
|
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply(f"🚫 **错误:**\n\n`{e}`")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("❌ **队列为空**")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
|
|
|
|
|
|
2022-02-11 07:05:22 +00:00
|
|
|
|
@Client.on_callback_query(filters.regex("set_pause"))
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-02-11 07:05:22 +00:00
|
|
|
|
async def cbpause(_, query: CallbackQuery):
|
|
|
|
|
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
|
|
|
if not a.can_manage_voice_chats:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
return await query.answer("💡 仅拥有 管理语音聊天 权限的管理员可以按按钮", show_alert=True)
|
2022-01-31 12:41:47 +00:00
|
|
|
|
chat_id = query.message.chat.id
|
2022-02-11 07:05:22 +00:00
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
|
|
|
|
if not await is_music_playing(chat_id):
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("ℹ️ 播放暂停!", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
return
|
|
|
|
|
await calls.pause_stream(chat_id)
|
|
|
|
|
await music_off(chat_id)
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("⏸ 播放暂停!", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.edit_message_text(f"🚫 **错误:**\n\n`{e}`", reply_markup=close_mark)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("❌ 队列为空", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_callback_query(filters.regex("set_resume"))
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-02-11 07:05:22 +00:00
|
|
|
|
async def cbresume(_, query: CallbackQuery):
|
|
|
|
|
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
|
|
|
if not a.can_manage_voice_chats:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
return await query.answer("💡 仅拥有 管理语音聊天 权限的管理员可以按按钮", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
chat_id = query.message.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
|
|
|
|
if await is_music_playing(chat_id):
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("ℹ️ 恢复播放!", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
return
|
|
|
|
|
await calls.resume_stream(chat_id)
|
|
|
|
|
await music_on(chat_id)
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("▶️ 恢复播放!", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.edit_message_text(f"🚫 **错误:**\n\n`{e}`", reply_markup=close_mark)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("❌ 队列为空", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_callback_query(filters.regex("set_stop"))
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-02-11 07:05:22 +00:00
|
|
|
|
async def cbstop(_, query: CallbackQuery):
|
|
|
|
|
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
|
|
|
if not a.can_manage_voice_chats:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
return await query.answer("💡 仅拥有 管理语音聊天 权限的管理员可以按按钮", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
chat_id = query.message.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
|
|
|
|
await calls.leave_group_call(chat_id)
|
|
|
|
|
await remove_active_chat(chat_id)
|
|
|
|
|
clear_queue(chat_id)
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.edit_message_text("✅ **播放已经停止**", reply_markup=close_mark)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.edit_message_text(f"🚫 **错误:**\n\n`{e}`", reply_markup=close_mark)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("❌ 队列为空", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_callback_query(filters.regex("set_mute"))
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-02-11 07:05:22 +00:00
|
|
|
|
async def cbmute(_, query: CallbackQuery):
|
|
|
|
|
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
|
|
|
if not a.can_manage_voice_chats:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
return await query.answer("💡 仅拥有 管理语音聊天 权限的管理员可以按按钮", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
chat_id = query.message.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
|
|
|
|
if not await is_music_playing(chat_id):
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("ℹ️ 静音成功!", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
return
|
|
|
|
|
await calls.mute_stream(chat_id)
|
|
|
|
|
await music_off(chat_id)
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("🔇 已被静音", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.edit_message_text(f"🚫 **错误:**\n\n`{e}`", reply_markup=close_mark)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("❌ 队列为空", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_callback_query(filters.regex("set_unmute"))
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-02-11 07:05:22 +00:00
|
|
|
|
async def cbunmute(_, query: CallbackQuery):
|
|
|
|
|
a = await _.get_chat_member(query.message.chat.id, query.from_user.id)
|
|
|
|
|
if not a.can_manage_voice_chats:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
return await query.answer("💡 仅拥有 管理语音聊天 权限的管理员可以按按钮", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
chat_id = query.message.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
|
|
|
|
if await is_music_playing(chat_id):
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("ℹ️ 解除静音成功!", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
return
|
|
|
|
|
await calls.unmute_stream(chat_id)
|
|
|
|
|
await music_on(chat_id)
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("🔊 解除静音成功", show_alert=True)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.edit_message_text(f"🚫 **错误:**\n\n`{e}`", reply_markup=close_mark)
|
2022-02-11 07:05:22 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await query.answer("❌ 队列为空", show_alert=True)
|
2022-01-31 12:41:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Client.on_message(
|
|
|
|
|
command(["volume", f"volume@{BOT_USERNAME}", "vol"]) & other_filters
|
|
|
|
|
)
|
|
|
|
|
@authorized_users_only
|
2022-02-14 05:38:16 +00:00
|
|
|
|
@check_blacklist()
|
2022-01-31 12:41:47 +00:00
|
|
|
|
async def change_volume(client, m: Message):
|
2022-02-11 15:35:42 +00:00
|
|
|
|
if len(m.command) < 2:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply_text("使用方法:`/volume` (`0-200`)")
|
2022-02-06 05:44:20 +00:00
|
|
|
|
return
|
2022-01-31 12:41:47 +00:00
|
|
|
|
range = m.command[1]
|
|
|
|
|
chat_id = m.chat.id
|
|
|
|
|
if chat_id in QUEUE:
|
|
|
|
|
try:
|
2022-02-07 16:14:32 +00:00
|
|
|
|
await calls.change_volume_call(chat_id, volume=int(range))
|
2022-01-31 12:41:47 +00:00
|
|
|
|
await m.reply(
|
2022-03-02 13:01:45 +00:00
|
|
|
|
f"✅ **音量调整到** `{range}`%"
|
2022-01-31 12:41:47 +00:00
|
|
|
|
)
|
|
|
|
|
except Exception as e:
|
2022-02-13 06:27:09 +00:00
|
|
|
|
traceback.print_exc()
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply(f"🚫 **错误:**\n\n`{e}`")
|
2022-01-31 12:41:47 +00:00
|
|
|
|
else:
|
2022-03-02 13:01:45 +00:00
|
|
|
|
await m.reply("❌ **队列为空**")
|