merge pull request #169 from levina-lab/docs
[feat] some changes & improvements
This commit is contained in:
commit
ea90793dad
@ -17,11 +17,7 @@ user = Client(
|
||||
api_hash=API_HASH,
|
||||
)
|
||||
|
||||
calls = PyTgCalls(
|
||||
user,
|
||||
cache_duration=180,
|
||||
overload_quiet_mode=True
|
||||
)
|
||||
calls = PyTgCalls(user, overload_quiet_mode=True)
|
||||
|
||||
|
||||
with Client(":veez:", API_ID, API_HASH, bot_token=BOT_TOKEN) as app:
|
||||
|
@ -1,3 +1,22 @@
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import traceback
|
||||
|
||||
from cache.admins import admins
|
||||
|
@ -1,9 +1,29 @@
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import asyncio
|
||||
|
||||
from config import BOT_USERNAME, SUDO_USERS
|
||||
|
||||
from program.utils.function import get_calls
|
||||
|
||||
from driver.queues import QUEUE
|
||||
from driver.core import user, me_bot
|
||||
from driver.filters import command, other_filters
|
||||
from driver.database.dbchat import remove_served_chat
|
||||
@ -142,6 +162,11 @@ async def bot_kicked(c: Client, m: Message):
|
||||
chat_id = m.chat.id
|
||||
left_member = m.left_chat_member
|
||||
if left_member.id == bot_id:
|
||||
if chat_id in QUEUE:
|
||||
await remove_active_chat(chat_id)
|
||||
return
|
||||
try:
|
||||
await user.leave_chat(chat_id)
|
||||
await remove_served_chat(chat_id)
|
||||
await remove_active_chat(chat_id)
|
||||
except BaseException as err:
|
||||
print(err)
|
@ -1,3 +1,22 @@
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
from pyrogram.types import Message
|
||||
from pyrogram import Client, filters
|
||||
|
||||
|
@ -1,10 +1,28 @@
|
||||
# Copyright (C) 2021 By VeezMusicProject
|
||||
"""
|
||||
Video + Music Stream Telegram Bot
|
||||
Copyright (c) 2022-present levina=lab <https://github.com/levina-lab>
|
||||
|
||||
from driver.core import me_bot
|
||||
from driver.decorators import check_blacklist
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
from driver.core import me_bot, me_user
|
||||
from driver.queues import QUEUE
|
||||
from pyrogram import Client, filters
|
||||
from driver.decorators import check_blacklist
|
||||
from program.utils.inline import menu_markup, stream_markup
|
||||
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
|
||||
from config import (
|
||||
@ -20,11 +38,10 @@ from config import (
|
||||
@Client.on_callback_query(filters.regex("home_start"))
|
||||
@check_blacklist()
|
||||
async def start_set(_, query: CallbackQuery):
|
||||
BOT_NAME = me_bot.first_name
|
||||
await query.answer("home start")
|
||||
await query.edit_message_text(
|
||||
f"""✨ **Welcome [{query.message.chat.first_name}](tg://user?id={query.message.chat.id}) !**\n
|
||||
💭 [{BOT_NAME}](https://t.me/{BOT_USERNAME}) **Is a bot to play music and video in groups, through the Telegram Group video chat!**
|
||||
💭 [{me_bot.first_name}](https://t.me/{BOT_USERNAME}) **Is a bot to play music and video in groups, through the Telegram Group video chat!**
|
||||
|
||||
💡 **Find out all the Bot's commands and how they work by clicking on the » 📚 Commands button!**
|
||||
|
||||
@ -85,7 +102,6 @@ async def quick_set(_, query: CallbackQuery):
|
||||
@Client.on_callback_query(filters.regex("user_guide"))
|
||||
@check_blacklist()
|
||||
async def guide_set(_, query: CallbackQuery):
|
||||
ass_uname = me_bot.first_name
|
||||
await query.answer("user guide")
|
||||
await query.edit_message_text(
|
||||
f"""❓ How to use this Bot ?, read the Guide below !
|
||||
@ -93,7 +109,7 @@ async def guide_set(_, query: CallbackQuery):
|
||||
1.) First, add this bot to your Group.
|
||||
2.) Then, promote this bot as administrator on the Group also give all permissions except Anonymous admin.
|
||||
3.) After promoting this bot, type /reload in Group to update the admin data.
|
||||
3.) Invite @{ass_uname} to your group or type /userbotjoin to invite her, unfortunately the userbot will joined by itself when you type `/play (song name)` or `/vplay (song name)`.
|
||||
3.) Invite @{me_user.username} to your group or type /userbotjoin to invite her, unfortunately the userbot will joined by itself when you type `/play (song name)` or `/vplay (song name)`.
|
||||
4.) Turn on/Start the video chat first before start to play video/music.
|
||||
|
||||
`- END, EVERYTHING HAS BEEN SETUP -`
|
||||
|
@ -1,3 +1,22 @@
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import re
|
||||
import sys
|
||||
import subprocess
|
||||
@ -9,11 +28,13 @@ from inspect import getfullargspec
|
||||
|
||||
from config import BOT_USERNAME as bname
|
||||
from driver.core import bot
|
||||
from driver.queues import QUEUE
|
||||
from driver.filters import command
|
||||
from pyrogram import Client, filters
|
||||
from driver.database.dbchat import remove_served_chat
|
||||
from driver.decorators import bot_creator, sudo_users_only, errors
|
||||
from driver.utils import remove_if_exists
|
||||
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
|
||||
|
||||
|
||||
@ -174,15 +195,18 @@ async def shellrunner(client, message):
|
||||
async def bot_leave_group(_, message):
|
||||
if len(message.command) != 2:
|
||||
await message.reply_text(
|
||||
"**usage:**\n\n» /leavebot [chat id]"
|
||||
"**usage:**\n\n» /leavebot (`chat_id`)"
|
||||
)
|
||||
return
|
||||
chat = message.text.split(None, 2)[1]
|
||||
if chat in QUEUE:
|
||||
await remove_active_chat(chat)
|
||||
return
|
||||
try:
|
||||
await bot.leave_chat(chat)
|
||||
await user.leave_chat(chat)
|
||||
await remove_served_chat(chat)
|
||||
except Exception as e:
|
||||
await message.reply_text(f"❌ procces failed\n\nreason: `{e}`")
|
||||
print(e)
|
||||
return
|
||||
await message.reply_text(f"✅ Bot successfully left from the Group:\n\n💭 » `{chat}`")
|
||||
|
@ -1,4 +1,21 @@
|
||||
# Copyright (C) 2021 By Veez Music-Project
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import wget
|
||||
import yt_dlp
|
||||
@ -89,8 +106,6 @@ async def video_downloader(_, message):
|
||||
await message.delete()
|
||||
ydl_opts = {
|
||||
"format": "best",
|
||||
"keepvideo": True,
|
||||
"prefer-ffmpeg": False,
|
||||
"geo-bypass": True,
|
||||
"noprogress": True,
|
||||
"user-agent": "Mozilla/5.0 (Linux; Android 7.0; k960n_mt6580_32_n) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36",
|
||||
@ -144,17 +159,18 @@ async def get_lyric_genius(_, message: Message):
|
||||
return await message.reply_text("**usage:**\n\n/lyrics (song name)")
|
||||
m = await message.reply_text("🔍 Searching lyrics...")
|
||||
query = message.text.split(None, 1)[1]
|
||||
x = "OXaVabSRKQLqwpiYOn-E4Y7k3wj-TNdL5RfDPXlnXhCErbcqVvdCF-WnMR5TBctI"
|
||||
y = lyricsgenius.Genius(x)
|
||||
y.verbose = False
|
||||
S = y.search_song(query, get_full_info=False)
|
||||
if S is None:
|
||||
api = "OXaVabSRKQLqwpiYOn-E4Y7k3wj-TNdL5RfDPXlnXhCErbcqVvdCF-WnMR5TBctI"
|
||||
data = lyricsgenius.Genius(api)
|
||||
data.verbose = False
|
||||
result = data.search_song(query, get_full_info=False)
|
||||
if result is None:
|
||||
return await m.edit("❌ `404` lyrics not found")
|
||||
xxx = f"""
|
||||
**Song Name:** __{query}__
|
||||
**Artist Name:** {S.artist}
|
||||
**__Lyrics:__**
|
||||
{S.lyrics}"""
|
||||
**Title song:** {query}
|
||||
**Artist name:** {result.artist}
|
||||
**Lyrics:**
|
||||
|
||||
{result.lyrics}"""
|
||||
if len(xxx) > 4096:
|
||||
await m.delete()
|
||||
filename = "lyrics.txt"
|
||||
|
@ -1,4 +1,20 @@
|
||||
""" broadcast & statistic collector """
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import asyncio
|
||||
@ -6,13 +22,12 @@ import traceback
|
||||
|
||||
from pyrogram.types import Message
|
||||
from pyrogram import Client, filters, __version__ as pyrover
|
||||
|
||||
from pytgcalls import (__version__ as pytgver)
|
||||
|
||||
from driver.core import me_bot
|
||||
from program import __version__ as ver
|
||||
from program.start import __python_version__ as pyver
|
||||
|
||||
from driver.core import me_bot
|
||||
from driver.filters import command
|
||||
from driver.decorators import bot_creator, sudo_users_only
|
||||
from driver.database.dbchat import get_served_chats
|
@ -1,3 +1,22 @@
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
from pyrogram import Client, errors
|
||||
from pyrogram.types import (
|
||||
InlineQuery,
|
||||
|
@ -1,19 +1,33 @@
|
||||
# Copyright (C) 2021 By Veez Music-Project
|
||||
# Commit Start Date 20/10/2021
|
||||
# Finished On 28/10/2021
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
# pyrogram stuff
|
||||
import traceback
|
||||
|
||||
from pyrogram import Client
|
||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
||||
from pyrogram.types import InlineKeyboardMarkup, Message
|
||||
# pytgcalls stuff
|
||||
from pytgcalls import idle
|
||||
|
||||
from pytgcalls import StreamType
|
||||
from pytgcalls.types.input_stream import AudioPiped
|
||||
from pytgcalls.types.input_stream.quality import HighQualityAudio
|
||||
# repository stuff
|
||||
from pytgcalls.exceptions import NoAudioSourceFound, NoActiveGroupCall, GroupCallNotFound
|
||||
|
||||
from driver.decorators import require_admin, check_blacklist
|
||||
from program.utils.inline import stream_markup
|
||||
from driver.design.thumbnail import thumb
|
||||
@ -24,7 +38,7 @@ from driver.core import calls, user, me_user
|
||||
from driver.utils import bash, remove_if_exists, from_tg_get_msg
|
||||
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
||||
from config import BOT_USERNAME, IMG_5
|
||||
# youtube-dl stuff
|
||||
|
||||
from youtubesearchpython import VideosSearch
|
||||
|
||||
|
||||
@ -41,7 +55,6 @@ def ytsearch(query: str):
|
||||
print(e)
|
||||
return 0
|
||||
|
||||
|
||||
async def ytdl(link: str):
|
||||
stdout, stderr = await bash(
|
||||
f'yt-dlp --geo-bypass -g -f "best[height<=?720][width<=?1280]/best" {link}'
|
||||
@ -154,13 +167,14 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
|
||||
f"⏱️ **Duration:** `{duration}`\n"
|
||||
f"🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
remove_if_exists(image)
|
||||
except Exception as e:
|
||||
except (NoActiveGroupCall, GroupCallNotFound):
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
traceback.print_exc()
|
||||
await m.reply_text(f"🚫 error:\n\n» {e}")
|
||||
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||
except BaseException as err:
|
||||
print(err)
|
||||
else:
|
||||
await m.reply(
|
||||
"» reply to an **audio file** or **give something to search.**"
|
||||
@ -182,8 +196,9 @@ async def play(c: Client, m: Message):
|
||||
try:
|
||||
ubot = me_user.id
|
||||
b = await c.get_chat_member(chat_id, ubot)
|
||||
if b.status == "kicked":
|
||||
await c.unban_chat_member(chat_id, ubot)
|
||||
if b.status == "banned":
|
||||
await m.reply_text("❌ The userbot is banned in this chat, unban the userbot first to be able to play music !")
|
||||
return
|
||||
invitelink = (await c.get_chat(chat_id)).invite_link
|
||||
if not invitelink:
|
||||
await c.export_chat_invite_link(chat_id)
|
||||
@ -194,6 +209,8 @@ async def play(c: Client, m: Message):
|
||||
)
|
||||
await user.join_chat(invitelink)
|
||||
await remove_active_chat(chat_id)
|
||||
except UserAlreadyParticipant:
|
||||
pass
|
||||
except UserNotParticipant:
|
||||
try:
|
||||
invitelink = (await c.get_chat(chat_id)).invite_link
|
||||
@ -279,12 +296,17 @@ async def play(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
remove_if_exists(image)
|
||||
except Exception as ep:
|
||||
except (NoActiveGroupCall, GroupCallNotFound):
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text(f"🚫 error: `{ep}`")
|
||||
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||
except NoAudioSourceFound:
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text("❌ The content you provide to play has no audio source")
|
||||
except BaseException as err:
|
||||
print(err)
|
||||
|
||||
else:
|
||||
if len(m.command) < 2:
|
||||
@ -350,9 +372,14 @@ async def play(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
remove_if_exists(image)
|
||||
except Exception as ep:
|
||||
except (NoActiveGroupCall, GroupCallNotFound):
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text(f"🚫 error: `{ep}`")
|
||||
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||
except NoAudioSourceFound:
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text("❌ The content you provide to play has no audio source.\n\n» Try to play another song or try again later !")
|
||||
except BaseException as err:
|
||||
print(err)
|
@ -1,14 +1,30 @@
|
||||
# Copyright (C) 2021 By Veez Music-Project
|
||||
# Commit Start Date 20/10/2021
|
||||
# Finished On 28/10/2021
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
from config import BOT_USERNAME
|
||||
|
||||
from pyrogram import Client
|
||||
from pyrogram.types import (
|
||||
InlineKeyboardButton,
|
||||
InlineKeyboardMarkup,
|
||||
Message,
|
||||
)
|
||||
from pyrogram import Client
|
||||
|
||||
from driver.decorators import check_blacklist
|
||||
from driver.queues import QUEUE, get_queue
|
||||
|
@ -1,4 +1,20 @@
|
||||
""" global banned and un-global banned module """
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import asyncio
|
||||
@ -6,6 +22,7 @@ import asyncio
|
||||
from pyrogram import Client
|
||||
from pyrogram.types import Message
|
||||
from pyrogram.errors import FloodWait
|
||||
|
||||
from driver.core import me_bot
|
||||
from driver.filters import command, other_filters
|
||||
from driver.decorators import bot_creator
|
||||
@ -157,9 +174,23 @@ async def ungban_global(c: Client, message: Message):
|
||||
if not is_gbanned:
|
||||
await message.reply_text("This user is not gbanned !")
|
||||
else:
|
||||
await c.unban_chat_member(chat_id, user.id)
|
||||
msg = await message.reply_text("» ungbanning user...")
|
||||
await remove_gban_user(user.id)
|
||||
await message.reply_text("✅ This user has ungbanned")
|
||||
served_chats = []
|
||||
chats = await get_served_chats()
|
||||
for chat in chats:
|
||||
served_chats.append(int(chat["chat_id"]))
|
||||
number_of_chats = 0
|
||||
for num in served_chats:
|
||||
try:
|
||||
await c.unban_chat_member(num, user.id)
|
||||
number_of_chats += 1
|
||||
await asyncio.sleep(1)
|
||||
except FloodWait as e:
|
||||
await asyncio.sleep(int(e.x))
|
||||
except BaseException:
|
||||
pass
|
||||
await msg.edit_text("✅ This user has ungbanned")
|
||||
return
|
||||
from_user_id = message.from_user.id
|
||||
user_id = message.reply_to_message.from_user.id
|
||||
@ -178,6 +209,20 @@ async def ungban_global(c: Client, message: Message):
|
||||
if not is_gbanned:
|
||||
await message.reply_text("This user is not gbanned !")
|
||||
else:
|
||||
await c.unban_chat_member(chat_id, user_id)
|
||||
msg = await message.reply_text("» ungbanning user...")
|
||||
await remove_gban_user(user_id)
|
||||
await message.reply_text("✅ This user has ungbanned")
|
||||
served_chats = []
|
||||
chats = await get_served_chats()
|
||||
for chat in chats:
|
||||
served_chats.append(int(chat["chat_id"]))
|
||||
number_of_chats = 0
|
||||
for num in served_chats:
|
||||
try:
|
||||
await c.unban_chat_member(num, user_id)
|
||||
number_of_chats += 1
|
||||
await asyncio.sleep(1)
|
||||
except FloodWait as e:
|
||||
await asyncio.sleep(int(e.x))
|
||||
except BaseException:
|
||||
pass
|
||||
await msg.edit_text("✅ This user has ungbanned")
|
||||
|
@ -1,14 +1,33 @@
|
||||
# credit to TeamYukki for this speedtest module
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import wget
|
||||
import speedtest
|
||||
|
||||
from PIL import Image
|
||||
from config import BOT_USERNAME as bname
|
||||
|
||||
from driver.filters import command
|
||||
from driver.decorators import sudo_users_only
|
||||
from config import BOT_USERNAME as bname
|
||||
from driver.core import bot as app
|
||||
from driver.utils import remove_if_exists
|
||||
|
||||
from pyrogram import Client, filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
|
@ -1,3 +1,22 @@
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import asyncio
|
||||
|
||||
from datetime import datetime
|
||||
@ -20,6 +39,7 @@ from driver.database.dbchat import add_served_chat, is_served_chat
|
||||
from driver.database.dbpunish import is_gbanned_user
|
||||
from driver.database.dbusers import add_served_user
|
||||
from driver.database.dblockchat import blacklisted_chats
|
||||
|
||||
from pyrogram import Client, filters, __version__ as pyrover
|
||||
from pyrogram.errors import FloodWait
|
||||
from pytgcalls import (__version__ as pytover)
|
||||
@ -59,10 +79,9 @@ async def _human_time_duration(seconds):
|
||||
)
|
||||
@check_blacklist()
|
||||
async def start_(c: Client, message: Message):
|
||||
BOT_NAME = me_bot.first_name
|
||||
await message.reply_text(
|
||||
f"""✨ **Welcome {message.from_user.mention()} !**\n
|
||||
💭 [{BOT_NAME}](https://t.me/{BOT_USERNAME}) **Is a bot to play music and video in groups, through the Telegram Group video chat!**
|
||||
💭 [{me_bot.first_name}](https://t.me/{BOT_USERNAME}) **Is a bot to play music and video in groups, through the Telegram Group video chat!**
|
||||
|
||||
💡 **Find out all the Bot's commands and how they work by clicking on the » 📚 Commands button!**
|
||||
|
||||
@ -109,7 +128,6 @@ async def alive(c: Client, message: Message):
|
||||
current_time = datetime.utcnow()
|
||||
uptime_sec = (current_time - START_TIME).total_seconds()
|
||||
uptime = await _human_time_duration(int(uptime_sec))
|
||||
BOT_NAME = me_bot.first_name
|
||||
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
[
|
||||
@ -122,7 +140,7 @@ async def alive(c: Client, message: Message):
|
||||
]
|
||||
)
|
||||
|
||||
alive = f"**Hello {message.from_user.mention()}, i'm {BOT_NAME}**\n\n🧑🏼💻 My Master: [{ALIVE_NAME}](https://t.me/{OWNER_USERNAME})\n👾 Bot Version: `v{__version__}`\n🔥 Pyrogram Version: `{pyrover}`\n🐍 Python Version: `{__python_version__}`\n✨ PyTgCalls Version: `{pytover.__version__}`\n🆙 Uptime Status: `{uptime}`\n\n❤ **Thanks for Adding me here, for playing video & music on your Group's video chat**"
|
||||
alive = f"**Hello {message.from_user.mention()}, I'm {me_bot.first_name}**\n\n🧑🏼💻 My Master: [{ALIVE_NAME}](https://t.me/{OWNER_USERNAME})\n👾 Bot Version: `v{__version__}`\n🔥 Pyrogram Version: `{pyrover}`\n🐍 Python Version: `{__python_version__}`\n✨ PyTgCalls Version: `{pytover.__version__}`\n🆙 Uptime Status: `{uptime}`\n\n❤ **Thanks for Adding me here, for playing video & music on your Group's video chat**"
|
||||
|
||||
await c.send_photo(
|
||||
chat_id,
|
||||
@ -172,15 +190,13 @@ async def new_chat(c: Client, m: Message):
|
||||
pass
|
||||
else:
|
||||
await add_served_chat(chat_id)
|
||||
ass_uname = me_user.username
|
||||
bot_id = me_bot.id
|
||||
for member in m.new_chat_members:
|
||||
if chat_id in await blacklisted_chats():
|
||||
await m.reply(
|
||||
"❗️ This chat has blacklisted by sudo user and You're not allowed to use me in this chat."
|
||||
)
|
||||
return await bot.leave_chat(chat_id)
|
||||
if member.id == bot_id:
|
||||
if member.id == me_bot.id:
|
||||
return await m.reply(
|
||||
"❤️ Thanks for adding me to the **Group** !\n\n"
|
||||
"Appoint me as administrator in the **Group**, otherwise I will not be able to work properly, and don't forget to type `/userbotjoin` for invite the assistant.\n\n"
|
||||
@ -192,7 +208,7 @@ async def new_chat(c: Client, m: Message):
|
||||
InlineKeyboardButton("💭 Support", url=f"https://t.me/{GROUP_SUPPORT}")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton("👤 Assistant", url=f"https://t.me/{ass_uname}")
|
||||
InlineKeyboardButton("👤 Assistant", url=f"https://t.me/{me_user.username}")
|
||||
]
|
||||
]
|
||||
)
|
||||
|
@ -1,18 +1,35 @@
|
||||
# Copyright (C) 2021 Veez Project
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import re
|
||||
import uuid
|
||||
import socket
|
||||
|
||||
import psutil
|
||||
import platform
|
||||
|
||||
from config import BOT_USERNAME
|
||||
|
||||
from driver.filters import command
|
||||
from pyrogram import Client, filters
|
||||
from driver.decorators import sudo_users_only, humanbytes
|
||||
|
||||
from pyrogram import Client, filters
|
||||
|
||||
# FETCH SYSINFO
|
||||
|
||||
@Client.on_message(command(["sysinfo", f"sysinfo@{BOT_USERNAME}"]) & ~filters.edited)
|
||||
@sudo_users_only
|
||||
|
@ -1,12 +1,26 @@
|
||||
# Copyright (C) 2021 By Veez Music-Project
|
||||
# Commit Start Date 20/10/2021
|
||||
# Finished On 28/10/2021
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
import re
|
||||
import asyncio
|
||||
import traceback
|
||||
# repository stuff
|
||||
|
||||
from config import BOT_USERNAME, IMG_1, IMG_2, IMG_5
|
||||
from driver.decorators import require_admin, check_blacklist
|
||||
from program.utils.inline import stream_markup
|
||||
@ -17,12 +31,11 @@ from driver.queues import QUEUE, add_to_queue
|
||||
from driver.core import calls, user, me_user
|
||||
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
||||
from driver.utils import remove_if_exists, from_tg_get_msg
|
||||
# pyrogram stuff
|
||||
|
||||
from pyrogram import Client
|
||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
||||
from pyrogram.types import InlineKeyboardMarkup, Message
|
||||
# py-tgcalls stuff
|
||||
from pytgcalls import idle
|
||||
|
||||
from pytgcalls import StreamType
|
||||
from pytgcalls.types.input_stream import AudioVideoPiped
|
||||
from pytgcalls.types.input_stream.quality import (
|
||||
@ -31,7 +44,8 @@ from pytgcalls.types.input_stream.quality import (
|
||||
LowQualityVideo,
|
||||
MediumQualityVideo,
|
||||
)
|
||||
# youtube-dl stuff
|
||||
from pytgcalls.exceptions import NoVideoSourceFound, NoActiveGroupCall, GroupCallNotFound
|
||||
|
||||
from youtubesearchpython import VideosSearch
|
||||
|
||||
|
||||
@ -138,6 +152,7 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
|
||||
)
|
||||
remove_if_exists(image)
|
||||
else:
|
||||
try:
|
||||
await loser.edit("🔄 Joining Group Call...")
|
||||
gcname = m.chat.title
|
||||
ctitle = await CHAT_TITLE(gcname)
|
||||
@ -173,8 +188,14 @@ async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str
|
||||
f"⏱️ **Duration:** `{duration}`\n"
|
||||
f"🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
remove_if_exists(image)
|
||||
except (NoActiveGroupCall, GroupCallNotFound):
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
traceback.print_exc()
|
||||
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||
except BaseException as err:
|
||||
print(err)
|
||||
else:
|
||||
await m.reply(
|
||||
"» reply to an **video file** or **give something to search.**"
|
||||
@ -196,8 +217,9 @@ async def vplay(c: Client, m: Message):
|
||||
try:
|
||||
ubot = me_user.id
|
||||
b = await c.get_chat_member(chat_id, ubot)
|
||||
if b.status == "kicked":
|
||||
await c.unban_chat_member(chat_id, ubot)
|
||||
if b.status == "banned":
|
||||
await m.reply_text("❌ The userbot is banned in this chat, unban the userbot first to be able to play music !")
|
||||
return
|
||||
invitelink = (await c.get_chat(chat_id)).invite_link
|
||||
if not invitelink:
|
||||
await c.export_chat_invite_link(chat_id)
|
||||
@ -208,6 +230,8 @@ async def vplay(c: Client, m: Message):
|
||||
)
|
||||
await user.join_chat(invitelink)
|
||||
await remove_active_chat(chat_id)
|
||||
except UserAlreadyParticipant:
|
||||
pass
|
||||
except UserNotParticipant:
|
||||
try:
|
||||
invitelink = (await c.get_chat(chat_id)).invite_link
|
||||
@ -294,12 +318,21 @@ async def vplay(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
remove_if_exists(image)
|
||||
except Exception as ep:
|
||||
except (NoActiveGroupCall, GroupCallNotFound):
|
||||
await loser.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text(f"🚫 error: `{ep}`")
|
||||
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||
except NoVideoSourceFound:
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text("❌ The content you provide to play has no video source")
|
||||
except NoAudioSourceFound:
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text("❌ The content you provide to play has no audio source")
|
||||
except BaseException as err:
|
||||
print(err)
|
||||
|
||||
else:
|
||||
if len(m.command) < 2:
|
||||
@ -370,12 +403,21 @@ async def vplay(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
remove_if_exists(image)
|
||||
except Exception as ep:
|
||||
except (NoActiveGroupCall, GroupCallNotFound):
|
||||
await loser.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text(f"🚫 error: `{ep}`")
|
||||
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||
except NoVideoSourceFound:
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text("❌ The content you provide to play has no video source")
|
||||
except NoAudioSourceFound:
|
||||
await suhu.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text("❌ The content you provide to play has no audio source")
|
||||
except BaseException as err:
|
||||
print(err)
|
||||
|
||||
|
||||
@Client.on_message(command(["vstream", f"vstream@{BOT_USERNAME}"]) & other_filters)
|
||||
@ -392,8 +434,9 @@ async def vstream(c: Client, m: Message):
|
||||
try:
|
||||
ubot = me_user.id
|
||||
b = await c.get_chat_member(chat_id, ubot)
|
||||
if b.status == "kicked":
|
||||
await c.unban_chat_member(chat_id, ubot)
|
||||
if b.status == "banned":
|
||||
await m.reply_text("❌ The userbot is banned in this chat, unban the userbot first to be able to play music !")
|
||||
return
|
||||
invitelink = (await c.get_chat(chat_id)).invite_link
|
||||
if not invitelink:
|
||||
await c.export_chat_invite_link(chat_id)
|
||||
@ -503,8 +546,9 @@ async def vstream(c: Client, m: Message):
|
||||
reply_markup=InlineKeyboardMarkup(buttons),
|
||||
caption=f"🗂 **Name:** [{songname}]({url}) | `live`\n🧸 **Requested by:** {requester}",
|
||||
)
|
||||
await idle()
|
||||
except Exception as ep:
|
||||
except (NoActiveGroupCall, GroupCallNotFound):
|
||||
await loser.delete()
|
||||
await remove_active_chat(chat_id)
|
||||
await m.reply_text(f"🚫 error: `{ep}`")
|
||||
await m.reply_text("❌ The bot can't find the Group call or it's inactive.\n\n» Use /startvc command to turn on the Group call !")
|
||||
except BaseException as err:
|
||||
print(err)
|
@ -1,3 +1,22 @@
|
||||
"""
|
||||
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>
|
||||
"""
|
||||
|
||||
|
||||
from config import BOT_USERNAME
|
||||
from driver.decorators import check_blacklist
|
||||
from driver.filters import command
|
||||
|
Loading…
Reference in New Issue
Block a user