some fixes

This commit is contained in:
levina 2021-10-26 04:15:41 +07:00 committed by GitHub
parent b16c97763d
commit f03b1d1968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,125 +1,139 @@
# Copyright (C) 2021 By VeezMusicProject
from datetime import datetime from datetime import datetime
from sys import version_info
from time import time from time import time
from config import (
ALIVE_IMG,
ALIVE_NAME,
BOT_NAME,
BOT_USERNAME,
GROUP_SUPPORT,
OWNER_NAME,
UPDATES_CHANNEL,
)
from program import __version__
from driver.decorators import sudo_users_only
from driver.filters import command
from pyrogram import Client, filters from pyrogram import Client, filters
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup from pyrogram import __version__ as pyrover
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
__major__ = 0
__minor__ = 2
__micro__ = 1
__python_version__ = f"{version_info[0]}.{version_info[1]}.{version_info[2]}"
from config import Veez
from helpers.decorators import sudo_users_only
from helpers.filters import command
START_TIME = datetime.utcnow() START_TIME = datetime.utcnow()
START_TIME_ISO = START_TIME.replace(microsecond=0).isoformat() START_TIME_ISO = START_TIME.replace(microsecond=0).isoformat()
TIME_DURATION_UNITS = ( TIME_DURATION_UNITS = (
('week', 60 * 60 * 24 * 7), ("week", 60 * 60 * 24 * 7),
('day', 60 * 60 * 24), ("day", 60 * 60 * 24),
('hour', 60 * 60), ("hour", 60 * 60),
('min', 60), ("min", 60),
('sec', 1) ("sec", 1),
) )
async def _human_time_duration(seconds): async def _human_time_duration(seconds):
if seconds == 0: if seconds == 0:
return 'inf' return "inf"
parts = [] parts = []
for unit, div in TIME_DURATION_UNITS: for unit, div in TIME_DURATION_UNITS:
amount, seconds = divmod(int(seconds), div) amount, seconds = divmod(int(seconds), div)
if amount > 0: if amount > 0:
parts.append('{} {}{}' parts.append("{} {}{}".format(amount, unit, "" if amount == 1 else "s"))
.format(amount, unit, "" if amount == 1 else "s")) return ", ".join(parts)
return ', '.join(parts)
@Client.on_message(command(["start", f"start@{Veez.BOT_USERNAME}"])) @Client.on_message(
async def start(_, m: Message): command(["start", f"start@{BOT_USERNAME}"]) & filters.private & ~filters.edited
if m.chat.type == "private":
await m.reply_text(
f"✨ **Hello there, I am a telegram group video streaming bot.**\n\n💭 **I was created to stream videos in group "
f"video chats easily.**\n\n❔ **To find out how to use me, please press the help button below** 👇🏻",
reply_markup=InlineKeyboardMarkup(
[[
InlineKeyboardButton(
" Add me to your Group ", url=f"https://t.me/{Veez.BOT_USERNAME}?startgroup=true")
], [
InlineKeyboardButton(
"❔ HOW TO USE THIS BOT", callback_data="cbguide")
], [
InlineKeyboardButton(
"🌐 Terms & Condition", callback_data="cbinfo")
], [
InlineKeyboardButton(
"💬 Group", url="https://t.me/VeezSupportGroup"),
InlineKeyboardButton(
"📣 Channel", url="https://t.me/levinachannel")
], [
InlineKeyboardButton(
"👩🏻‍💻 Developer", url="https://t.me/dlwrml")
], [
InlineKeyboardButton(
"📚 All Command List", callback_data="cblist")
]]
))
else:
await m.reply_text("**✨ bot is online now ✨**",
reply_markup=InlineKeyboardMarkup(
[[
InlineKeyboardButton(
"❔ HOW TO USE THIS BOT", callback_data="cbguide")
], [
InlineKeyboardButton(
"🌐 Search Youtube", switch_inline_query='')
], [
InlineKeyboardButton(
"📚 Command List", callback_data="cblist")
]]
)
) )
async def start_(client: Client, message: Message):
await message.reply_text(
f"""✨ **Welcome {message.from_user.mention()} !**\n
💭 **[{BOT_NAME}](https://t.me/{BOT_USERNAME}) allows you to play music and video on groups through the new Telegram's video chats!**
💡 **Find out all the Bot's commands and how they work by clicking on the » 📚 Commands button!**
@Client.on_message(command(["alive", f"alive@{Veez.BOT_USERNAME}"]) & filters.group & ~filters.edited) **To know how to use this bot, please click on the » Basic Guide button!**""",
async def alive(_, m: Message):
current_time = datetime.utcnow()
uptime_sec = (current_time - START_TIME).total_seconds()
uptime = await _human_time_duration(int(uptime_sec))
await m.reply_text(
f"""✅ **bot is running**\n<b>💠 **uptime:**</b> `{uptime}`""",
reply_markup=InlineKeyboardMarkup( reply_markup=InlineKeyboardMarkup(
[ [
[ [
InlineKeyboardButton( InlineKeyboardButton(
"✨ Group", url=f"https://t.me/VeezSupportGroup" " Add me to your Group ",
url=f"https://t.me/{BOT_USERNAME}?startgroup=true",
)
],
[InlineKeyboardButton("❓ Basic Guide", callback_data="cbhowtouse")],
[
InlineKeyboardButton("📚 Commands", callback_data="cbcmds"),
InlineKeyboardButton("💝 Donate", url=f"https://t.me/{OWNER_NAME}"),
],
[
InlineKeyboardButton(
"👥 Official Group", url=f"https://t.me/{GROUP_SUPPORT}"
), ),
InlineKeyboardButton( InlineKeyboardButton(
"📣 Channel", url=f"https://t.me/levinachannel" "📣 Official Channel", url=f"https://t.me/{UPDATES_CHANNEL}"
),
],
[
InlineKeyboardButton(
"🌐 Source Code", url="https://github.com/levina-lab/video-stream"
) )
],
] ]
] ),
) disable_web_page_preview=True,
) )
@Client.on_message(command(["ping", f"ping@{Veez.BOT_USERNAME}"]) & ~filters.edited) @Client.on_message(
async def ping_pong(_, m: Message): command(["alive", f"alive@{BOT_USERNAME}"]) & filters.group & ~filters.edited
sturt = time()
m_reply = await m.reply_text("pinging...")
delta_ping = time() - sturt
await m_reply.edit_text(
"🏓 `PONG!!`\n"
f"⚡️ `{delta_ping * 1000:.3f} ms`"
) )
async def alive(client: Client, message: Message):
@Client.on_message(command(["uptime", f"uptime@{Veez.BOT_USERNAME}"]) & ~filters.edited)
@sudo_users_only
async def get_uptime(_, m: 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))
await m.reply_text(
"🤖 bot status 🤖\n\n" keyboard = InlineKeyboardMarkup(
[
[
InlineKeyboardButton("✨ Group", url=f"https://t.me/{GROUP_SUPPORT}"),
InlineKeyboardButton(
"📣 Channel", url=f"https://t.me/{UPDATES_CHANNEL}"
),
]
]
)
alive = f"**Hello {message.from_user.mention()}, i'm {BOT_NAME}**\n\n✨ Bot is working normally\n🍀 My Master: [{ALIVE_NAME}](https://t.me/{OWNER_NAME})\n✨ Bot Version: `v{__version__}`\n🍀 Pyrogram Version: `{pyrover}`\n✨ Python Version: `{__python_version__}`\n🍀 Uptime Status: `{uptime}`\n\n**Thanks for Adding me here, for playing music on your Group voice chat** ❤"
await message.reply_photo(
photo=f"{ALIVE_IMG}",
caption=alive,
reply_markup=keyboard,
)
@Client.on_message(command(["ping", f"ping@{BOT_USERNAME}"]) & ~filters.edited)
async def ping_pong(client: Client, message: Message):
start = time()
m_reply = await message.reply_text("pinging...")
delta_ping = time() - start
await m_reply.edit_text("🏓 `PONG!!`\n" f"⚡️ `{delta_ping * 1000:.3f} ms`")
@Client.on_message(command(["uptime", f"uptime@{BOT_USERNAME}"]) & ~filters.edited)
@sudo_users_only
async def get_uptime(client: Client, message: Message):
current_time = datetime.utcnow()
uptime_sec = (current_time - START_TIME).total_seconds()
uptime = await _human_time_duration(int(uptime_sec))
await message.reply_text(
"🤖 bot status:\n"
f"• **uptime:** `{uptime}`\n" f"• **uptime:** `{uptime}`\n"
f"• **start time:** `{START_TIME_ISO}`" f"• **start time:** `{START_TIME_ISO}`"
) )