コード例 #1
0
async def _(c, m):
    if not is_valid_file(m):
        return

    snt = await m.reply_text(
        "Hi there, Please wait while I'm getting everything ready to process your request!",
        quote=True)

    file_link = await generate_stream_link(m)
    if file_link is None:
        await snt.edit_text(
            "😟 Sorry! I cannot help you right now, I'm having hard time processing the file.",
            quote=True)
        l = await m.forward(Config.LOG_CHANNEL)
        await l.reply_text(f'Could not create stream link', True)
        return

    duration = await get_duration(file_link)
    if duration is None:
        await snt.edit_text("😟 Sorry! I cannot open the file.")
        l = await m.forward(Config.LOG_CHANNEL)
        await l.reply_text(
            f'stream link : {file_link}\n\n Could not open the file.', True)
        return

    hh, mm, ss = [int(i) for i in duration.split(":")]
    seconds = hh * 60 * 60 + mm * 60 + ss

    btns = [[
        InlineKeyboardButton("📸 2", 'scht+2'),
        InlineKeyboardButton('📸 3', 'scht+3')
    ],
            [
                InlineKeyboardButton('📸 4', 'scht+4'),
                InlineKeyboardButton('📸 5', 'scht+5')
            ],
            [
                InlineKeyboardButton('📸 6', 'scht+6'),
                InlineKeyboardButton('📸 7', 'scht+7')
            ],
            [
                InlineKeyboardButton('📸 8', 'scht+8'),
                InlineKeyboardButton('📸 9', 'scht+9')
            ], [InlineKeyboardButton('📸 10', 'scht+10')]]

    if seconds >= 600:
        btns.append([InlineKeyboardButton('Generate Sample Video!', 'smpl')])

    await snt.edit_text(
        text=
        f"Hi, Choose the number of screenshots you need.\n\nTotal duration: `{duration}` (`{seconds}s`)",
        reply_markup=InlineKeyboardMarkup(btns))
コード例 #2
0
ファイル: media.py プロジェクト: imlogeshr/animated-lamp
async def _(c, m):
    
    chat_id = m.chat.id
    if not CHAT_FLOOD.get(chat_id):
        CHAT_FLOOD[chat_id] = int(time.time()) - Config.SLOW_SPEED_DELAY-1

    if int(time.time()) - CHAT_FLOOD.get(chat_id) < Config.SLOW_SPEED_DELAY:
        return
    
    CHAT_FLOOD[chat_id] = int(time.time())
    
    if not await db.is_user_exist(chat_id):
        await db.add_user(chat_id)
        await c.send_message(
            Config.LOG_CHANNEL,
            f"New User [{m.from_user.first_name}](tg://user?id={chat_id}) started."
        )
    
    ban_status = await db.get_ban_status(chat_id)
    if ban_status['is_banned']:
        if (datetime.date.today() - datetime.date.fromisoformat(ban_status['banned_on'])).days > ban_status['ban_duration']:
            await db.remove_ban(chat_id)
        else:
            await m.reply_text(
                f"Sorry Dear, You misused me. So you are **Blocked!**.\n\nBlock Reason: __{ban_status['ban_reason']}__",
                quote=True
            )
            return
    
    if not is_valid_file(m):
        return
    
    snt = await m.reply_text("Hi there, Please wait while I'm getting everything ready to process your request!", quote=True)
    
    file_link = generate_stream_link(m)
    
    duration = await get_duration(file_link)
    if isinstance(duration, str):
        await snt.edit_text("😟 Sorry! I cannot open the file.")
        l = await m.forward(Config.LOG_CHANNEL)
        await l.reply_text(f'stream link : {file_link}\n\n {duration}', True)
        return
    
    btns = gen_ik_buttons()
    
    if duration >= 600:
        btns.append([InlineKeyboardButton('Generate Sample Video!', 'smpl')])
    
    await snt.edit_text(
        text=f"Hi, Choose the number of screenshots you need.\n\nTotal duration: `{datetime.timedelta(seconds=duration)}` (`{duration}s`)",
        reply_markup=InlineKeyboardMarkup(btns)
    )
コード例 #3
0
ファイル: media.py プロジェクト: pkpgaming/animated-lamp
async def _(c, m):
    if not await db.is_user_exist(m.chat.id):
        await db.add_user(m.chat.id)
        await c.send_message(
            Config.LOG_CHANNEL,
            f"New User [{m.from_user.first_name}](tg://user?id={m.chat.id}) started."
        )

    if not is_valid_file(m):
        return

    snt = await m.reply_text(
        "Hi there, Please wait while I'm getting everything ready to process your request!",
        quote=True)

    file_link = await generate_stream_link(m)
    if file_link is None:
        await snt.edit_text(
            "😟 Sorry! I cannot help you right now, I'm having hard time processing the file."
        )
        l = await m.forward(Config.LOG_CHANNEL)
        await l.reply_text(f'Could not create stream link', True)
        return

    duration = await get_duration(file_link)
    if isinstance(duration, str):
        await snt.edit_text("😟 Sorry! I cannot open the file.")
        l = await m.forward(Config.LOG_CHANNEL)
        await l.reply_text(f'stream link : {file_link}\n\n {duration}', True)
        return

    btns = gen_ik_buttons()

    if duration >= 600:
        btns.append([InlineKeyboardButton('Generate Sample Video!', 'smpl')])

    await snt.edit_text(
        text=
        f"Hi, Choose the number of screenshots you need.\n\nTotal duration: `{datetime.timedelta(seconds=duration)}` (`{duration}s`)",
        reply_markup=InlineKeyboardMarkup(btns))