merge pull request #169 from levina-lab/docs

[feat] some changes & improvements
This commit is contained in:
levina 2022-02-24 12:28:57 +07:00 committed by GitHub
commit ea90793dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 472 additions and 120 deletions

View File

@ -17,11 +17,7 @@ user = Client(
api_hash=API_HASH, api_hash=API_HASH,
) )
calls = PyTgCalls( calls = PyTgCalls(user, overload_quiet_mode=True)
user,
cache_duration=180,
overload_quiet_mode=True
)
with Client(":veez:", API_ID, API_HASH, bot_token=BOT_TOKEN) as app: with Client(":veez:", API_ID, API_HASH, bot_token=BOT_TOKEN) as app:

View File

@ -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 import traceback
from cache.admins import admins from cache.admins import admins

View File

@ -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 import asyncio
from config import BOT_USERNAME, SUDO_USERS from config import BOT_USERNAME, SUDO_USERS
from program.utils.function import get_calls from program.utils.function import get_calls
from driver.queues import QUEUE
from driver.core import user, me_bot from driver.core import user, me_bot
from driver.filters import command, other_filters from driver.filters import command, other_filters
from driver.database.dbchat import remove_served_chat 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 chat_id = m.chat.id
left_member = m.left_chat_member left_member = m.left_chat_member
if left_member.id == bot_id: if left_member.id == bot_id:
await user.leave_chat(chat_id) if chat_id in QUEUE:
await remove_served_chat(chat_id) await remove_active_chat(chat_id)
await remove_active_chat(chat_id) return
try:
await user.leave_chat(chat_id)
await remove_served_chat(chat_id)
except BaseException as err:
print(err)

View File

@ -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.types import Message
from pyrogram import Client, filters from pyrogram import Client, filters

View File

@ -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 This program is free software: you can redistribute it and/or modify
from driver.decorators import check_blacklist 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 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 program.utils.inline import menu_markup, stream_markup
from pyrogram import Client, filters
from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup
from config import ( from config import (
@ -20,11 +38,10 @@ from config import (
@Client.on_callback_query(filters.regex("home_start")) @Client.on_callback_query(filters.regex("home_start"))
@check_blacklist() @check_blacklist()
async def start_set(_, query: CallbackQuery): async def start_set(_, query: CallbackQuery):
BOT_NAME = me_bot.first_name
await query.answer("home start") await query.answer("home start")
await query.edit_message_text( await query.edit_message_text(
f"""✨ **Welcome [{query.message.chat.first_name}](tg://user?id={query.message.chat.id}) !**\n 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!** 💡 **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")) @Client.on_callback_query(filters.regex("user_guide"))
@check_blacklist() @check_blacklist()
async def guide_set(_, query: CallbackQuery): async def guide_set(_, query: CallbackQuery):
ass_uname = me_bot.first_name
await query.answer("user guide") await query.answer("user guide")
await query.edit_message_text( await query.edit_message_text(
f"""❓ How to use this Bot ?, read the Guide below ! 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. 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. 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.) 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. 4.) Turn on/Start the video chat first before start to play video/music.
`- END, EVERYTHING HAS BEEN SETUP -` `- END, EVERYTHING HAS BEEN SETUP -`

View File

@ -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 re
import sys import sys
import subprocess import subprocess
@ -9,11 +28,13 @@ from inspect import getfullargspec
from config import BOT_USERNAME as bname from config import BOT_USERNAME as bname
from driver.core import bot from driver.core import bot
from driver.queues import QUEUE
from driver.filters import command from driver.filters import command
from pyrogram import Client, filters
from driver.database.dbchat import remove_served_chat from driver.database.dbchat import remove_served_chat
from driver.decorators import bot_creator, sudo_users_only, errors from driver.decorators import bot_creator, sudo_users_only, errors
from driver.utils import remove_if_exists from driver.utils import remove_if_exists
from pyrogram import Client, filters
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
@ -174,15 +195,18 @@ async def shellrunner(client, message):
async def bot_leave_group(_, message): async def bot_leave_group(_, message):
if len(message.command) != 2: if len(message.command) != 2:
await message.reply_text( await message.reply_text(
"**usage:**\n\n» /leavebot [chat id]" "**usage:**\n\n» /leavebot (`chat_id`)"
) )
return return
chat = message.text.split(None, 2)[1] chat = message.text.split(None, 2)[1]
if chat in QUEUE:
await remove_active_chat(chat)
return
try: try:
await bot.leave_chat(chat) await bot.leave_chat(chat)
await user.leave_chat(chat)
await remove_served_chat(chat) await remove_served_chat(chat)
except Exception as e: except Exception as e:
await message.reply_text(f"❌ procces failed\n\nreason: `{e}`") await message.reply_text(f"❌ procces failed\n\nreason: `{e}`")
print(e)
return return
await message.reply_text(f"✅ Bot successfully left from the Group:\n\n💭 » `{chat}`") await message.reply_text(f"✅ Bot successfully left from the Group:\n\n💭 » `{chat}`")

View File

@ -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 wget
import yt_dlp import yt_dlp
@ -89,8 +106,6 @@ async def video_downloader(_, message):
await message.delete() await message.delete()
ydl_opts = { ydl_opts = {
"format": "best", "format": "best",
"keepvideo": True,
"prefer-ffmpeg": False,
"geo-bypass": True, "geo-bypass": True,
"noprogress": 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", "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)") return await message.reply_text("**usage:**\n\n/lyrics (song name)")
m = await message.reply_text("🔍 Searching lyrics...") m = await message.reply_text("🔍 Searching lyrics...")
query = message.text.split(None, 1)[1] query = message.text.split(None, 1)[1]
x = "OXaVabSRKQLqwpiYOn-E4Y7k3wj-TNdL5RfDPXlnXhCErbcqVvdCF-WnMR5TBctI" api = "OXaVabSRKQLqwpiYOn-E4Y7k3wj-TNdL5RfDPXlnXhCErbcqVvdCF-WnMR5TBctI"
y = lyricsgenius.Genius(x) data = lyricsgenius.Genius(api)
y.verbose = False data.verbose = False
S = y.search_song(query, get_full_info=False) result = data.search_song(query, get_full_info=False)
if S is None: if result is None:
return await m.edit("❌ `404` lyrics not found") return await m.edit("❌ `404` lyrics not found")
xxx = f""" xxx = f"""
**Song Name:** __{query}__ **Title song:** {query}
**Artist Name:** {S.artist} **Artist name:** {result.artist}
**__Lyrics:__** **Lyrics:**
{S.lyrics}"""
{result.lyrics}"""
if len(xxx) > 4096: if len(xxx) > 4096:
await m.delete() await m.delete()
filename = "lyrics.txt" filename = "lyrics.txt"

View File

@ -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 import asyncio
@ -6,13 +22,12 @@ import traceback
from pyrogram.types import Message 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 driver.core import me_bot
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
from driver.core import me_bot
from driver.filters import command from driver.filters import command
from driver.decorators import bot_creator, sudo_users_only 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

View File

@ -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 import Client, errors
from pyrogram.types import ( from pyrogram.types import (
InlineQuery, InlineQuery,

View File

@ -1,19 +1,33 @@
# Copyright (C) 2021 By Veez Music-Project """
# Commit Start Date 20/10/2021 Video + Music Stream Telegram Bot
# Finished On 28/10/2021 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 import traceback
from pyrogram import Client from pyrogram import Client
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
from pyrogram.types import InlineKeyboardMarkup, Message from pyrogram.types import InlineKeyboardMarkup, Message
# pytgcalls stuff
from pytgcalls import idle
from pytgcalls import StreamType from pytgcalls import StreamType
from pytgcalls.types.input_stream import AudioPiped from pytgcalls.types.input_stream import AudioPiped
from pytgcalls.types.input_stream.quality import HighQualityAudio 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 driver.decorators import require_admin, check_blacklist
from program.utils.inline import stream_markup from program.utils.inline import stream_markup
from driver.design.thumbnail import thumb 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.utils import bash, remove_if_exists, from_tg_get_msg
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
from config import BOT_USERNAME, IMG_5 from config import BOT_USERNAME, IMG_5
# youtube-dl stuff
from youtubesearchpython import VideosSearch from youtubesearchpython import VideosSearch
@ -41,7 +55,6 @@ def ytsearch(query: str):
print(e) print(e)
return 0 return 0
async def ytdl(link: str): async def ytdl(link: str):
stdout, stderr = await bash( stdout, stderr = await bash(
f'yt-dlp --geo-bypass -g -f "best[height<=?720][width<=?1280]/best" {link}' 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"⏱️ **Duration:** `{duration}`\n"
f"🧸 **Request by:** {requester}", f"🧸 **Request by:** {requester}",
) )
await idle()
remove_if_exists(image) remove_if_exists(image)
except Exception as e: except (NoActiveGroupCall, GroupCallNotFound):
await suhu.delete() await suhu.delete()
await remove_active_chat(chat_id) await remove_active_chat(chat_id)
traceback.print_exc() 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: else:
await m.reply( await m.reply(
"» reply to an **audio file** or **give something to search.**" "» reply to an **audio file** or **give something to search.**"
@ -182,18 +196,21 @@ async def play(c: Client, m: Message):
try: try:
ubot = me_user.id ubot = me_user.id
b = await c.get_chat_member(chat_id, ubot) b = await c.get_chat_member(chat_id, ubot)
if b.status == "kicked": if b.status == "banned":
await c.unban_chat_member(chat_id, ubot) 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)
invitelink = (await c.get_chat(chat_id)).invite_link invitelink = (await c.get_chat(chat_id)).invite_link
if not invitelink: if invitelink.startswith("https://t.me/+"):
await c.export_chat_invite_link(chat_id) invitelink = invitelink.replace(
invitelink = (await c.get_chat(chat_id)).invite_link "https://t.me/+", "https://t.me/joinchat/"
if invitelink.startswith("https://t.me/+"): )
invitelink = invitelink.replace(
"https://t.me/+", "https://t.me/joinchat/"
)
await user.join_chat(invitelink) await user.join_chat(invitelink)
await remove_active_chat(chat_id) await remove_active_chat(chat_id)
except UserAlreadyParticipant:
pass
except UserNotParticipant: except UserNotParticipant:
try: try:
invitelink = (await c.get_chat(chat_id)).invite_link invitelink = (await c.get_chat(chat_id)).invite_link
@ -279,12 +296,17 @@ async def play(c: Client, m: Message):
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}", caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
) )
await idle()
remove_if_exists(image) remove_if_exists(image)
except Exception as ep: except (NoActiveGroupCall, GroupCallNotFound):
await suhu.delete() await suhu.delete()
await remove_active_chat(chat_id) 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: else:
if len(m.command) < 2: if len(m.command) < 2:
@ -350,9 +372,14 @@ async def play(c: Client, m: Message):
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}", caption=f"🗂 **Name:** [{songname}]({url}) | `music`\n**⏱ Duration:** `{duration}`\n🧸 **Request by:** {requester}",
) )
await idle()
remove_if_exists(image) remove_if_exists(image)
except Exception as ep: except (NoActiveGroupCall, GroupCallNotFound):
await suhu.delete() await suhu.delete()
await remove_active_chat(chat_id) 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)

View File

@ -1,14 +1,30 @@
# Copyright (C) 2021 By Veez Music-Project """
# Commit Start Date 20/10/2021 Video + Music Stream Telegram Bot
# Finished On 28/10/2021 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 config import BOT_USERNAME
from pyrogram import Client
from pyrogram.types import ( from pyrogram.types import (
InlineKeyboardButton, InlineKeyboardButton,
InlineKeyboardMarkup, InlineKeyboardMarkup,
Message, Message,
) )
from pyrogram import Client
from driver.decorators import check_blacklist from driver.decorators import check_blacklist
from driver.queues import QUEUE, get_queue from driver.queues import QUEUE, get_queue

View File

@ -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 import asyncio
@ -6,6 +22,7 @@ import asyncio
from pyrogram import Client from pyrogram import Client
from pyrogram.types import Message from pyrogram.types import Message
from pyrogram.errors import FloodWait from pyrogram.errors import FloodWait
from driver.core import me_bot from driver.core import me_bot
from driver.filters import command, other_filters from driver.filters import command, other_filters
from driver.decorators import bot_creator from driver.decorators import bot_creator
@ -157,9 +174,23 @@ async def ungban_global(c: Client, message: Message):
if not is_gbanned: if not is_gbanned:
await message.reply_text("This user is not gbanned !") await message.reply_text("This user is not gbanned !")
else: else:
await c.unban_chat_member(chat_id, user.id) msg = await message.reply_text("» ungbanning user...")
await remove_gban_user(user.id) 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 return
from_user_id = message.from_user.id from_user_id = message.from_user.id
user_id = message.reply_to_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: if not is_gbanned:
await message.reply_text("This user is not gbanned !") await message.reply_text("This user is not gbanned !")
else: else:
await c.unban_chat_member(chat_id, user_id) msg = await message.reply_text("» ungbanning user...")
await remove_gban_user(user_id) 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")

View File

@ -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 wget
import speedtest import speedtest
from PIL import Image from PIL import Image
from config import BOT_USERNAME as bname
from driver.filters import command from driver.filters import command
from driver.decorators import sudo_users_only from driver.decorators import sudo_users_only
from config import BOT_USERNAME as bname
from driver.core import bot as app from driver.core import bot as app
from driver.utils import remove_if_exists from driver.utils import remove_if_exists
from pyrogram import Client, filters from pyrogram import Client, filters
from pyrogram.types import Message from pyrogram.types import Message

View File

@ -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 import asyncio
from datetime import datetime 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.dbpunish import is_gbanned_user
from driver.database.dbusers import add_served_user from driver.database.dbusers import add_served_user
from driver.database.dblockchat import blacklisted_chats from driver.database.dblockchat import blacklisted_chats
from pyrogram import Client, filters, __version__ as pyrover from pyrogram import Client, filters, __version__ as pyrover
from pyrogram.errors import FloodWait from pyrogram.errors import FloodWait
from pytgcalls import (__version__ as pytover) from pytgcalls import (__version__ as pytover)
@ -59,10 +79,9 @@ async def _human_time_duration(seconds):
) )
@check_blacklist() @check_blacklist()
async def start_(c: Client, message: Message): async def start_(c: Client, message: Message):
BOT_NAME = me_bot.first_name
await message.reply_text( await message.reply_text(
f"""✨ **Welcome {message.from_user.mention()} !**\n 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!** 💡 **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() current_time = datetime.utcnow()
uptime_sec = (current_time - START_TIME).total_seconds() uptime_sec = (current_time - START_TIME).total_seconds()
uptime = await _human_time_duration(int(uptime_sec)) uptime = await _human_time_duration(int(uptime_sec))
BOT_NAME = me_bot.first_name
keyboard = InlineKeyboardMarkup( 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( await c.send_photo(
chat_id, chat_id,
@ -172,15 +190,13 @@ async def new_chat(c: Client, m: Message):
pass pass
else: else:
await add_served_chat(chat_id) await add_served_chat(chat_id)
ass_uname = me_user.username
bot_id = me_bot.id
for member in m.new_chat_members: for member in m.new_chat_members:
if chat_id in await blacklisted_chats(): if chat_id in await blacklisted_chats():
await m.reply( await m.reply(
"❗️ This chat has blacklisted by sudo user and You're not allowed to use me in this chat." "❗️ 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) return await bot.leave_chat(chat_id)
if member.id == bot_id: if member.id == me_bot.id:
return await m.reply( return await m.reply(
"❤️ Thanks for adding me to the **Group** !\n\n" "❤️ 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" "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("💭 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}")
] ]
] ]
) )

View File

@ -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 re
import uuid import uuid
import socket import socket
import psutil import psutil
import platform import platform
from config import BOT_USERNAME from config import BOT_USERNAME
from driver.filters import command from driver.filters import command
from pyrogram import Client, filters
from driver.decorators import sudo_users_only, humanbytes 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) @Client.on_message(command(["sysinfo", f"sysinfo@{BOT_USERNAME}"]) & ~filters.edited)
@sudo_users_only @sudo_users_only

View File

@ -1,12 +1,26 @@
# Copyright (C) 2021 By Veez Music-Project """
# Commit Start Date 20/10/2021 Video + Music Stream Telegram Bot
# Finished On 28/10/2021 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 re
import asyncio import asyncio
import traceback import traceback
# repository stuff
from config import BOT_USERNAME, IMG_1, IMG_2, IMG_5 from config import BOT_USERNAME, IMG_1, IMG_2, IMG_5
from driver.decorators import require_admin, check_blacklist from driver.decorators import require_admin, check_blacklist
from program.utils.inline import stream_markup 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.core import calls, user, me_user
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
from driver.utils import remove_if_exists, from_tg_get_msg from driver.utils import remove_if_exists, from_tg_get_msg
# pyrogram stuff
from pyrogram import Client from pyrogram import Client
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
from pyrogram.types import InlineKeyboardMarkup, Message from pyrogram.types import InlineKeyboardMarkup, Message
# py-tgcalls stuff
from pytgcalls import idle
from pytgcalls import StreamType from pytgcalls import StreamType
from pytgcalls.types.input_stream import AudioVideoPiped from pytgcalls.types.input_stream import AudioVideoPiped
from pytgcalls.types.input_stream.quality import ( from pytgcalls.types.input_stream.quality import (
@ -31,7 +44,8 @@ from pytgcalls.types.input_stream.quality import (
LowQualityVideo, LowQualityVideo,
MediumQualityVideo, MediumQualityVideo,
) )
# youtube-dl stuff from pytgcalls.exceptions import NoVideoSourceFound, NoActiveGroupCall, GroupCallNotFound
from youtubesearchpython import VideosSearch 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) remove_if_exists(image)
else: else:
try:
await loser.edit("🔄 Joining Group Call...") await loser.edit("🔄 Joining Group Call...")
gcname = m.chat.title gcname = m.chat.title
ctitle = await CHAT_TITLE(gcname) 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"⏱️ **Duration:** `{duration}`\n"
f"🧸 **Request by:** {requester}", f"🧸 **Request by:** {requester}",
) )
await idle()
remove_if_exists(image) 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: else:
await m.reply( await m.reply(
"» reply to an **video file** or **give something to search.**" "» reply to an **video file** or **give something to search.**"
@ -196,18 +217,21 @@ async def vplay(c: Client, m: Message):
try: try:
ubot = me_user.id ubot = me_user.id
b = await c.get_chat_member(chat_id, ubot) b = await c.get_chat_member(chat_id, ubot)
if b.status == "kicked": if b.status == "banned":
await c.unban_chat_member(chat_id, ubot) 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)
invitelink = (await c.get_chat(chat_id)).invite_link invitelink = (await c.get_chat(chat_id)).invite_link
if not invitelink: if invitelink.startswith("https://t.me/+"):
await c.export_chat_invite_link(chat_id) invitelink = invitelink.replace(
invitelink = (await c.get_chat(chat_id)).invite_link "https://t.me/+", "https://t.me/joinchat/"
if invitelink.startswith("https://t.me/+"): )
invitelink = invitelink.replace(
"https://t.me/+", "https://t.me/joinchat/"
)
await user.join_chat(invitelink) await user.join_chat(invitelink)
await remove_active_chat(chat_id) await remove_active_chat(chat_id)
except UserAlreadyParticipant:
pass
except UserNotParticipant: except UserNotParticipant:
try: try:
invitelink = (await c.get_chat(chat_id)).invite_link invitelink = (await c.get_chat(chat_id)).invite_link
@ -294,12 +318,21 @@ async def vplay(c: Client, m: Message):
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}", caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
) )
await idle()
remove_if_exists(image) remove_if_exists(image)
except Exception as ep: except (NoActiveGroupCall, GroupCallNotFound):
await loser.delete() await loser.delete()
await remove_active_chat(chat_id) 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: else:
if len(m.command) < 2: if len(m.command) < 2:
@ -370,12 +403,21 @@ async def vplay(c: Client, m: Message):
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}", caption=f"🗂 **Name:** [{songname}]({url}) | `video`\n⏱ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
) )
await idle()
remove_if_exists(image) remove_if_exists(image)
except Exception as ep: except (NoActiveGroupCall, GroupCallNotFound):
await loser.delete() await loser.delete()
await remove_active_chat(chat_id) 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) @Client.on_message(command(["vstream", f"vstream@{BOT_USERNAME}"]) & other_filters)
@ -392,16 +434,17 @@ async def vstream(c: Client, m: Message):
try: try:
ubot = me_user.id ubot = me_user.id
b = await c.get_chat_member(chat_id, ubot) b = await c.get_chat_member(chat_id, ubot)
if b.status == "kicked": if b.status == "banned":
await c.unban_chat_member(chat_id, ubot) 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)
invitelink = (await c.get_chat(chat_id)).invite_link invitelink = (await c.get_chat(chat_id)).invite_link
if not invitelink: if invitelink.startswith("https://t.me/+"):
await c.export_chat_invite_link(chat_id) invitelink = invitelink.replace(
invitelink = (await c.get_chat(chat_id)).invite_link "https://t.me/+", "https://t.me/joinchat/"
if invitelink.startswith("https://t.me/+"): )
invitelink = invitelink.replace(
"https://t.me/+", "https://t.me/joinchat/"
)
await user.join_chat(invitelink) await user.join_chat(invitelink)
await remove_active_chat(chat_id) await remove_active_chat(chat_id)
except UserNotParticipant: except UserNotParticipant:
@ -503,8 +546,9 @@ async def vstream(c: Client, m: Message):
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"🗂 **Name:** [{songname}]({url}) | `live`\n🧸 **Requested by:** {requester}", caption=f"🗂 **Name:** [{songname}]({url}) | `live`\n🧸 **Requested by:** {requester}",
) )
await idle() except (NoActiveGroupCall, GroupCallNotFound):
except Exception as ep:
await loser.delete() await loser.delete()
await remove_active_chat(chat_id) 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)

View File

@ -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 config import BOT_USERNAME
from driver.decorators import check_blacklist from driver.decorators import check_blacklist
from driver.filters import command from driver.filters import command