Beispiel #1
0
def get_string(key: str) -> Any:
    try:
        return languages[(udB.get("language") or "en")][key]
    except KeyError:
        try:
            return Trs.translate(languages["en"][key],
                                 lang_tgt=udB.get("language"))
        except KeyError:
            return f"Warning: could not load any string with the key {key}"
Beispiel #2
0
    def ult(func):
        kwargs[
            "func"] = lambda e: not e.is_private and not e.via_bot_id and not e.fwd_from
        handler = udB["VC_HNDLR"] if udB.get("VC_HNDLR") else HNDLR
        kwargs["pattern"] = re.compile(f"\\{handler}" + dec)
        from_users = VC_AUTHS()
        kwargs["from_users"] = from_users
        vc_auth = kwargs.get("vc_auth", True)

        if "vc_auth" in kwargs:
            del kwargs["vc_auth"]

        async def vc_handler(e):
            VCAUTH = list(get_vc().keys())
            if not ((e.out) or (e.sender_id in from_users) or
                    (vc_auth and e.chat_id in VCAUTH)):
                return
            if vc_auth:
                cha, adm = check_vcauth(e.chat_id)
                if adm and not (await admin_check(e)):
                    return
            try:
                await func(e)
            except Exception:
                LOGS.exception(Exception)
                await asst.send_message(
                    LOG_CHANNEL,
                    f"VC Error - <code>{UltVer}</code>\n\n<code>{e.text}</code>\n\n<code>{format_exc()}</code>",
                    parse_mode="html",
                )

        vcClient.add_event_handler(
            vc_handler,
            events.NewMessage(**kwargs),
        )
Beispiel #3
0
from json.decoder import JSONDecodeError

from aiohttp import web
from aiohttp.http_websocket import WSMsgType
from pyUltroid import udB, vcbot
from pyUltroid.dB.database import Var
from telethon import TelegramClient
from telethon.tl.functions.channels import GetFullChannelRequest
from telethon.tl.functions.phone import (
    GetGroupCallRequest,
    JoinGroupCallRequest,
    LeaveGroupCallRequest,
)
from telethon.tl.types import DataJSON

LOG_CHANNEL = int(udB.get("LOG_CHANNEL"))
if vcbot:

    bot = TelegramClient(None, Var.API_ID,
                         Var.API_HASH).start(bot_token=udB.get("BOT_TOKEN"))

    async def get_entity(chat):
        try:
            return await vcbot.get_input_entity(chat["id"])
        except ValueError:
            if "username" in chat:
                return await vcbot.get_entity(chat["username"])
            raise

    async def join_call(data):
        try:
Beispiel #4
0
def gmuted_user():
    gmute = udB.get("GMUTE")
    if gmute is None or gmute == "":
        return [""]
    else:
        return str_to_list(gmute)
Beispiel #5
0
def gbanned_user():
    gbun = udB.get("GBAN")
    if gbun is None or gbun == "":
        return [""]
    else:
        return str_to_list(gbun)
Beispiel #6
0
def VC_AUTHS():
    _vcsudos = udB["VC_SUDOS"].split() if udB.get("VC_SUDOS") else ""
    return [int(a) for a in [*owner_and_sudos(), *_vcsudos]]
def VC_AUTHS():
    _vc_sudos = udB.get("VC_SUDOS").split() if udB.get("VC_SUDOS") else ""
    A_AUTH = [udB["OWNER_ID"], *sudoers(), *_vc_sudos]
    AUTH = [int(x) for x in A_AUTH]
    return AUTH
from pyrogram import Client, filters
from pyrogram.raw import functions
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from pytgcalls import StreamType
from pyUltroid import HNDLR, CallsClient
from pyUltroid import asst as tele_asst
from pyUltroid import udB, ultroid_bot
from pyUltroid import vcasst as asst
from pyUltroid.functions.all import bash, dler, time_formatter
from pyUltroid.misc import sudoers
from youtube_dl import YoutubeDL
from youtubesearchpython import VideosSearch

Client = CallsClient._app

LOG_CHANNEL = int(udB.get("LOG_CHANNEL"))
QUEUE = {}

_yt_base_url = "https://www.youtube.com/watch?v="
vcusername = tele_asst.me.username


def VC_AUTHS():
    _vc_sudos = udB.get("VC_SUDOS").split() if udB.get("VC_SUDOS") else ""
    A_AUTH = [udB["OWNER_ID"], *sudoers(), *_vc_sudos]
    AUTH = [int(x) for x in A_AUTH]
    return AUTH


def reply_markup(chat_id: int):
    return InlineKeyboardMarkup([
Beispiel #9
0
from os import listdir, path
from typing import Any, Dict, List, Union

from google_trans_new import google_translator
from pyUltroid import udB
from yaml import safe_load

language = [udB.get("language") or "en"]
languages = {}

Trs = google_translator()

strings_folder = path.join(path.dirname(path.realpath(__file__)), "strings")

for file in listdir(strings_folder):
    if file.endswith(".yml"):
        code = file[:-4]
        languages[code] = safe_load(
            open(path.join(strings_folder, file), encoding="UTF-8"),
        )


def get_string(key: str) -> Any:
    lang = language[0]
    try:
        return languages[lang][key]
    except KeyError:
        try:
            tr = Trs.translate(languages["en"][key], lang_tgt=lang)
            if languages.get(lang):
                languages[lang][key] = tr