Ejemplo n.º 1
0
from userbot import catub
from userbot.core.logger import logging

from ..Config import Config
from ..core.managers import edit_delete, edit_or_reply
from ..sql_helper.globals import addgvar, delgvar, gvarstatus

plugin_category = "utils"
LOGS = logging.getLogger(__name__)
cmdhd = Config.COMMAND_HAND_LER
vlist = [
    "ALIVE_PIC",
    "ALIVE_EMOJI",
    "ALIVE_TEXT",
    "ALLOW_NSFW",
    "HELP_EMOJI",
    "HELP_TEXT",
    "IALIVE_PIC",
    "PM_PIC",
]


@catub.cat_cmd(
    pattern="(set|get|del)dv(?: |$)(.*)",
    command=("dv", plugin_category),
    info={
        "header":
        "Set vars in database or Check or Delete",
        "description":
        "Set , Fetch or Delete values or vars directly in database without restart or heroku vars.\n\nYou can set multiple pics by giving space after links in alive, ialive, pm permit.",
        "flags": {
Ejemplo n.º 2
0
from telethon.tl.types import MessageEntityMentionName
from userbot.core.logger import logging
from userbot.utils.tools import edit_delete

LOGS = logging.getLogger("userbot")


async def get_user_from_event(
    event, kingevent=None, secondgroup=None, nogroup=False, noedits=False
):  # sourcery no-metrics
    if kingevent is None:
        kingevent = event
    if nogroup is False:
        if secondgroup:
            args = event.pattern_match.group(2).split(" ", 1)
        else:
            args = event.pattern_match.group(1).split(" ", 1)
    extra = None
    try:
        if args:
            user = args[0]
            if len(args) > 1:
                extra = "".join(args[1:])
            if user.isnumeric() or (user.startswith("-")
                                    and user[1:].isnumeric()):
                user = int(user)
            if event.message.entities:
                probable_user_mention_entity = event.message.entities[0]
                if isinstance(
                        probable_user_mention_entity,
                        MessageEntityMentionName):
Ejemplo n.º 3
0
    media_type,
    progress,
    readable_time,
    reply_id,
    time_formatter,
)

plugin_category = "utils"

thumb_image_path = os.path.join(Config.TMP_DOWNLOAD_DIRECTORY,
                                "thumb_image.jpg")
FF_MPEG_DOWN_LOAD_MEDIA_PATH = os.path.join(Config.TMP_DOWNLOAD_DIRECTORY,
                                            "catuserbot.media.ffmpeg")
FINISHED_PROGRESS_STR = Config.FINISHED_PROGRESS_STR
UN_FINISHED_PROGRESS_STR = Config.UNFINISHED_PROGRESS_STR
LOGGER = logging.getLogger(__name__)


async def convert_video(video_file, output_directory, crf, total_time, bot,
                        message):
    # https://stackoverflow.com/a/13891070/4723940
    out_put_file_name = output_directory + "/" + str(round(
        time.time())) + ".mp4"
    progress = output_directory + "/" + "progress.txt"
    with open(progress, "w") as f:
        pass
    COMPRESSION_START_TIME = time.time()
    process = await asyncio.create_subprocess_shell(
        f'ffmpeg -hide_banner -loglevel quiet -progress {progress} -i """{video_file}""" -preset ultrafast -vcodec libx265 -crf {crf} -c:a copy """{out_put_file_name}"""',
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE,
Ejemplo n.º 4
0
from telethon import Button, functions, types, utils

import userbot
from userbot import BOTLOG, BOTLOG_CHATID
from userbot.Config import Config
from userbot.core.logger import logging
from userbot.core.session import catub
from userbot.utils import load_module

from .sql_helper.global_collection import (
    del_keyword_collectionlist,
    get_item_collectionlist,
)
from .sql_helper.globals import gvarstatus

LOGS = logging.getLogger("CatUserbot")

print(userbot.__copyright__)
print("Licensed under the terms of the " + userbot.__license__)

cmdhr = Config.COMMAND_HAND_LER


async def testing_bot():
    try:
        await catub.connect()
        config = await catub(functions.help.GetConfigRequest())
        for option in config.dc_options:
            if option.ip_address == catub.session.server_address:
                if catub.session.dc_id != option.id:
                    LOGS.warning(