azils3/bash
0
1# Ultroid - UserBot2# Copyright (C) 2021-2025 TeamUltroid3#4# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >5# PLease read the GNU Affero General Public License in6# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.7"""8✘ Commands Available9 10•`{i}invertgif`11 Make Gif Inverted(negative).12 13•`{i}bwgif`14 Make Gif black and white15 16•`{i}rvgif`17 Reverse a gif18 19•`{i}vtog`20 Reply To Video , It will Create Gif21 Video to Gif22 23•`{i}gif <query>`24 Send video regarding to query.25"""26import os27import random28import time29from datetime import datetime as dt30 31from . import HNDLR, LOGS, bash, downloader, get_string, mediainfo, ultroid_cmd32 33 34@ultroid_cmd(pattern="(bw|invert)gif$")35async def igif(e):36 match = e.pattern_match.group(1).strip()37 a = await e.get_reply_message()38 if not (a and a.media):39 return await e.eor("`Reply To gif only`", time=5)40 wut = mediainfo(a.media)41 if "gif" not in wut:42 return await e.eor("`Reply To Gif Only`", time=5)43 xx = await e.eor(get_string("com_1"))44 z = await a.download_media()45 if match == "bw":46 cmd = f'ffmpeg -i "{z}" -vf format=gray ult.gif -y'47 else:48 cmd = f'ffmpeg -i "{z}" -vf lutyuv="y=negval:u=negval:v=negval" ult.gif -y'49 try:50 await bash(cmd)51 await e.client.send_file(e.chat_id, "ult.gif", supports_streaming=True)52 os.remove(z)53 os.remove("ult.gif")54 await xx.delete()55 except Exception as er:56 LOGS.info(er)57 58 59@ultroid_cmd(pattern="rvgif$")60async def reverse_gif(event):61 a = await event.get_reply_message()62 if not (a and a.media) and "video" not in mediainfo(a.media):63 return await event.eor("`Reply To Video only`", time=5)64 msg = await event.eor(get_string("com_1"))65 file = await a.download_media()66 await bash(f'ffmpeg -i "{file}" -vf reverse -af areverse reversed.mp4 -y')67 await event.respond("- **Reversed Video/GIF**", file="reversed.mp4")68 await msg.delete()69 os.remove(file)70 os.remove("reversed.mp4")71 72 73@ultroid_cmd(pattern="gif( (.*)|$)")74async def gifs(ult):75 get = ult.pattern_match.group(1).strip()76 xx = random.randint(0, 5)77 n = 078 if ";" in get:79 try:80 n = int(get.split(";")[-1])81 except IndexError:82 pass83 if not get:84 return await ult.eor(f"`{HNDLR}gif <query>`")85 m = await ult.eor(get_string("com_2"))86 gifs = await ult.client.inline_query("gif", get)87 if not n:88 await gifs[xx].click(89 ult.chat_id, reply_to=ult.reply_to_msg_id, silent=True, hide_via=True90 )91 else:92 for x in range(n):93 await gifs[x].click(94 ult.chat_id, reply_to=ult.reply_to_msg_id, silent=True, hide_via=True95 )96 await m.delete()97 98 99@ultroid_cmd(pattern="vtog$")100async def vtogif(e):101 a = await e.get_reply_message()102 if not (a and a.media):103 return await e.eor("`Reply To video only`", time=5)104 wut = mediainfo(a.media)105 if "video" not in wut:106 return await e.eor("`Reply To Video Only`", time=5)107 xx = await e.eor(get_string("com_1"))108 dur = a.media.document.attributes[0].duration109 tt = time.time()110 if int(dur) < 120:111 z = await a.download_media()112 await bash(113 f'ffmpeg -i {z} -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 ult.gif -y'114 )115 else:116 filename = a.file.name117 if not filename:118 filename = "video_" + dt.now().isoformat("_", "seconds") + ".mp4"119 vid = await downloader(filename, a.media.document, xx, tt, get_string("com_5"))120 z = vid.name121 await bash(122 f'ffmpeg -ss 3 -t 100 -i {z} -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 ult.gif'123 )124 125 await e.client.send_file(e.chat_id, "ult.gif", support_stream=True)126 os.remove(z)127 os.remove("ult.gif")128 await xx.delete()129 