async def an(e): wrd = (e.pattern_match.group(1)).lower() wt = await e.get_reply_message() if not (wt and wrd): return await eor(e, "Give word to set as snip and reply to a message.") if "$" in wrd: wrd = wrd.replace("$", "") if wt and wt.media: wut = mediainfo(wt.media) if wut.startswith(("pic", "gif")): dl = await wt.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if wt.media.document.size > 8 * 1000 * 1000: return await eod(x, "`Unsupported Media`") else: dl = await wt.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] else: m = pack_bot_file_id(wt.media) if wt.text: add_snip(wrd, wt.text, m) else: add_snip(wrd, None, m) else: add_snip(wrd, wt.text, None) await eor(e, f"Done : snip `${wrd}` Saved.")
async def an(e): wrd = (e.pattern_match.group(1)).lower() wt = await e.get_reply_message() chat = e.chat_id if not (wt and wrd): return await eor( e, "`Use this Command with Reply and word to use a note.`", time=5 ) if "#" in wrd: wrd = wrd.replace("#", "") if wt and wt.media: wut = mediainfo(wt.media) if wut.startswith(("pic", "gif")): dl = await wt.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if wt.media.document.size > 8 * 1000 * 1000: return await eor(x, "`Unsupported Media`", time=5) dl = await wt.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] else: m = pack_bot_file_id(wt.media) if wt.text: add_note(int(chat), wrd, wt.text, m) else: add_note(int(chat), wrd, None, m) else: add_note(int(chat), wrd, wt.text, None) await eor(e, f"Done Note : `#{wrd}` saved.")
async def butt(event): media, wut, text = None, None, None if event.reply_to: wt = await event.get_reply_message() if wt.text: text = wt.text if wt.media: wut = mediainfo(wt.media) if wut and wut.startswith(("pic", "gif")): dl = await wt.download_media() variable = uf(dl) media = "https://telegra.ph" + variable[0] elif wut == "video": if wt.media.document.size > 8 * 1000 * 1000: return await event.eor(get_string("com_4"), time=5) dl = await wt.download_media() variable = uf(dl) os.remove(dl) media = "https://telegra.ph" + variable[0] else: media = pack_bot_file_id(wt.media) try: text = event.text.split(maxsplit=1)[1] except IndexError: if not text: return await event.eor( f"**Please give some text in correct format.**\n\n`{HNDLR}help button`", ) text, buttons = get_msg_button(text) if buttons: buttons = create_tl_btn(buttons) await something(event, text, media, buttons) await event.delete()
async def ac(e): wrd = (e.pattern_match.group(1)).lower() wt = await e.get_reply_message() if not (wt and wrd): return await eod( e, "`Use this Command with Reply and word to use a command.`") if "/" in wrd: wrd = wrd.replace("/", "") if wt and wt.media: wut = mediainfo(wt.media) if wut.startswith(("pic", "gif")): dl = await e.client.download_media(wt.media) variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if wt.media.document.size > 8 * 1000 * 1000: return await eod(x, "`Unsupported Media`") else: dl = await e.client.download_media(wt.media) variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] else: m = pack_bot_file_id(wt.media) if wt.text: add_cmd(wrd, wt.text, m) else: add_cmd(wrd, None, m) else: add_cmd(wrd, wt.text, None) await eor(e, f"Done Command : `/{wrd}` saved.")
async def af(e): wrd = e.pattern_match.group(1) wt = await e.get_reply_message() chat = e.chat_id if not (wt and wrd): return await eor( e, "`Use this command word to set as filter and reply...`") try: rem_filter(int(chat), wrd) except: pass if wt and wt.media: wut = mediainfo(wt.media) if wut.startswith(("pic", "gif")): dl = await bot.download_media(wt.media) variable = uf(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if wt.media.document.size > 8 * 1000 * 1000: return await eod(x, "`Unsupported Media`") else: dl = await bot.download_media(wt.media) variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] else: m = pack_bot_file_id(wt.media) if wt.text: add_filter(int(chat), wrd, wt.text, m) else: add_filter(int(chat), wrd, None, m) else: add_filter(int(chat), wrd, wt.text, None) await eor(e, f"Done : Filter `{wrd}` Saved.")
async def setwel(event): x = await eor(event, get_string("com_1")) r = await event.get_reply_message() if event.is_private: return await eod(x, "Please use this in a group and not PMs!", time=10) if r and r.media: wut = mediainfo(r.media) if wut.startswith(("pic", "gif")): dl = await bot.download_media(r.media) variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if r.media.document.size > 8 * 1000 * 1000: return await eod(x, "`Unsupported Media`") else: dl = await bot.download_media(r.media) variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] else: m = pack_bot_file_id(r.media) if r.text: add_welcome(event.chat_id, r.message, m) else: add_welcome(event.chat_id, None, m) await eor(x, "`Welcome note saved`") elif r.text: add_welcome(event.chat_id, r.message, None) await eor(x, "`Welcome note saved`") else: await eod(x, "`Reply to message which u want to set as welcome`")
async def af(e): wrd = (e.pattern_match.group(1)).lower() wt = await e.get_reply_message() chat = e.chat_id if not (wt and wrd): return await eor(e, get_string("flr_1")) btn = format_btn(wt.buttons) if wt.buttons else None if wt and wt.media: wut = mediainfo(wt.media) if wut.startswith(("pic", "gif")): dl = await wt.download_media() variable = uf(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if wt.media.document.size > 8 * 1000 * 1000: return await eor(e, get_string("com_4"), time=5) dl = await wt.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] else: m = pack_bot_file_id(wt.media) if wt.text: txt = wt.text if not btn: txt, btn = get_msg_button(wt.text) add_filter(int(chat), wrd, txt, m, btn) else: add_filter(int(chat), wrd, None, m, btn) else: txt = wt.text if not btn: txt, btn = get_msg_button(wt.text) add_filter(int(chat), wrd, txt, None, btn) await eor(e, get_string("flr_4").format(wrd))
async def telegraphcmd(event): ultroid_bot = event.client input_str = event.pattern_match.group(1) if event.reply_to_msg_id: getmsg = await event.get_reply_message() if getmsg.photo or getmsg.video or getmsg.gif: getit = await ultroid_bot.download_media(getmsg) try: variable = uf(getit) os.remove(getit) nn = "https://telegra.ph" + variable[0] amsg = f"Uploaded to [Telegraph]({nn}) !" except Exception as e: amsg = f"Error - {e}" await eor(event, amsg) elif "pic" in mediainfo(getmsg.media): getit = await ultroid_bot.download_media(getmsg) try: variable = uf(getit) os.remove(getit) nn = "https://telegra.ph" + variable[0] amsg = f"Uploaded to [Telegraph]({nn}) !" except Exception as e: amsg = f"Error - {e}" await eor(event, amsg) elif getmsg.document: getit = await ultroid_bot.download_media(getmsg) ab = open(getit) cd = ab.read() ab.close() if input_str: tcom = input_str else: tcom = "Ultroid" makeit = telegraph.create_page(title=tcom, content=[f"{cd}"]) war = makeit["url"] os.remove(getit) await eor(event, f"Pasted to Telegraph : [Telegraph]({war})") elif getmsg.text: if input_str: tcom = input_str else: tcom = "Ultroid" makeit = telegraph.create_page(title=tcom, content=[f"{getmsg.text}"]) war = makeit["url"] await eor(event, f"Pasted to Telegraph : [Telegraph]({war})") else: await eor(event, "Reply to a Media or Text !") else: await eor(event, "Reply to a Message !")
async def telegraphcmd(event): match = event.pattern_match.group(1) or "Ultroid" reply = await event.get_reply_message() if not reply: return await event.eor("`Reply to Message.`") if not reply.media and reply.message: content = reply.message else: getit = await reply.download_media() dar = mediainfo(reply.media) if dar == "sticker": file = getit + ".png" Image.open(getit).save(file) os.remove(getit) getit = file elif dar.endswith("animated"): file = getit + ".gif" await bash(f"lottie_convert.py '{getit}' {file}") os.remove(getit) getit = file if "document" not in dar: try: nn = "https://telegra.ph" + uf(getit)[0] amsg = f"Uploaded to [Telegraph]({nn}) !" except Exception as e: amsg = f"Error : {e}" os.remove(getit) return await event.eor(amsg) with open(getit) as ab: content = ab.read() os.remove(getit) makeit = Telegraph.create_page(title=match, content=[content]) await eor(event, f"Pasted to Telegraph : [Telegraph]({makeit['url']})", link_preview=False)
async def telegraphcmd(event): match = event.pattern_match.group(1) or "Ultroid" reply = await event.get_reply_message() if not reply: return await eor(event, "`Reply to Message.`") if not reply.media and reply.message: content = reply.message else: getit = await reply.download_media() dar = mediainfo(reply.media) if dar == "sticker": os.rename(getit, getit + ".jpg") getit = getit + ".jpg" if "document" not in dar: try: nn = "https://telegra.ph" + uf(getit)[0] amsg = f"Uploaded to [Telegraph]({nn}) !" except Exception as e: amsg = f"Error : {e}" os.remove(getit) return await eor(event, amsg) with open(getit) as ab: content = ab.read() os.remove(getit) makeit = telegraph.create_page(title=match, content=[content]) war = makeit["url"] await eor(event, f"Pasted to Telegraph : [Telegraph]({war})")
async def ac(e): wrd = (e.pattern_match.group(1).strip()).lower() wt = await e.get_reply_message() if not (wt and wrd): return await e.eor(get_string("asstcmd_1"), time=5) if "/" in wrd: wrd = wrd.replace("/", "") btn = format_btn(wt.buttons) if wt.buttons else None if wt and wt.media: wut = mediainfo(wt.media) if wut.startswith(("pic", "gif")): dl = await e.client.download_media(wt.media) variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if wt.media.document.size > 8 * 1000 * 1000: return await e.eor(get_string("com_4"), time=5) dl = await e.client.download_media(wt.media) variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] else: m = utils.pack_bot_file_id(wt.media) if wt.text: txt = wt.text if not btn: txt, btn = get_msg_button(wt.text) add_cmd(wrd, txt, m, btn) else: add_cmd(wrd, None, m, btn) else: txt = wt.text if not btn: txt, btn = get_msg_button(wt.text) add_cmd(wrd, txt, None, btn) asst.add_handler( astcmds, events.NewMessage( func=lambda x: x.text.startswith("/") and x.text[1:] in list(list_cmds()) ), ) await e.eor(get_string("asstcmd_4").format(wrd))
async def _(e): r = await e.get_reply_message() if not (r and r.media): return await eor(e, "`Reply to img`") dl = await ultroid_bot.download_media(r.media) variable = uf(dl) os.remove(dl) nn = "https://telegra.ph" + variable[0] udB.set("CUSTOM_THUMBNAIL", str(nn)) await eor(e, f"Added [This]({nn}) As Your Custom Thumbnail", link_preview=False)
async def _(event): carb = None try: cmd = event.text.split(" ", maxsplit=1)[1] if cmd.split()[0] in ["-c", "--carbon"]: cmd = cmd.split(maxsplit=1)[1] carb = True except IndexError: return await event.eor(get_string("devs_1"), time=10) xx = await event.eor(get_string("com_1")) if event.sender_id in _ignore_eval: return await xx.edit( "`You cannot use this command now. Contact owner of this bot!`") reply_to_id = event.reply_to_msg_id or event.id stdout, stderr = await bash(cmd) OUT = f"**☞ BASH\n\n• COMMAND:**\n`{cmd}` \n\n" err, out = "", "" if stderr: err = f"**• ERROR:** \n`{stderr}`\n\n" if stdout: if (carb or udB.get_key("CARBON_ON_BASH")) and ( event.chat.admin_rights or event.chat.creator or event.chat.default_banned_rights.embed_links): li = await Carbon( code=stdout, file_name="bash", download=True, backgroundColor=choice(ATRA_COL), ) url = "https://telegra.ph" + uf(li)[-1] OUT = f"[\xad]({url})" + OUT out = "**• OUTPUT:**" remove(li) else: out = f"**• OUTPUT:**\n`{stdout}`" if not stderr and not stdout: out = "**• OUTPUT:**\n`Success`" OUT += err + out if len(OUT) > 4096: ultd = err + out with BytesIO(str.encode(ultd)) as out_file: out_file.name = "bash.txt" await event.client.send_file( event.chat_id, out_file, force_document=True, thumb="resources/extras/ultroid.jpg", allow_cache=False, caption=f"`{cmd}`" if len(cmd) < 998 else None, reply_to=reply_to_id, ) await xx.delete() else: await xx.edit(OUT, link_preview=True)
async def set_afk(event): if event.client._bot or is_afk(): return text, media, media_type = None, None, None if event.pattern_match.group(1): text = event.text.split(maxsplit=1)[1] reply = await event.get_reply_message() if reply: if reply.text and not text: text = reply.text if reply.media: media_type = mediainfo(reply.media) if media_type.startswith(("pic", "gif")): file = await event.client.download_media(reply.media) iurl = uf(file) media = f"https://telegra.ph{iurl[0]}" else: media = reply.file.id await event.eor("`Done`", time=2) add_afk(text, media_type, media) ultroid_bot.add_handler(remove_afk, events.NewMessage(outgoing=True)) ultroid_bot.add_handler( on_afk, events.NewMessage( incoming=True, func=lambda e: bool(e.mentioned or e.is_private) ), ) msg1, msg2 = None, None if text and media: if "sticker" in media_type: msg1 = await ultroid_bot.send_file(event.chat_id, file=media) msg2 = await ultroid_bot.send_message( event.chat_id, get_string("afk_5").format(text) ) else: msg1 = await ultroid_bot.send_message( event.chat_id, get_string("afk_5").format(text), file=media ) elif media: if "sticker" in media_type: msg1 = await ultroid_bot.send_file(event.chat_id, file=media) msg2 = await ultroid_bot.send_message(event.chat_id, get_string("afk_6")) else: msg1 = await ultroid_bot.send_message( event.chat_id, get_string("afk_6"), file=media ) elif text: msg1 = await event.respond(get_string("afk_5").format(text)) else: msg1 = await event.respond(get_string("afk_6")) old_afk_msg.append(msg1) if msg2: old_afk_msg.append(msg2) return await asst.send_message(LOG_CHANNEL, msg2.text) await asst.send_message(LOG_CHANNEL, msg1.text)
async def set_afk(event): if event.client._bot: await eor(event, "Master, I am a Bot, I cant go AFK..") elif is_afk(): return text, media, media_type = None, None, None if event.pattern_match.group(1): text = event.text.split(maxsplit=1)[1] reply = await event.get_reply_message() if reply: if reply.text and not text: text = reply.text if reply.media: media_type = mediainfo(reply.media) if media_type.startswith(("pic", "gif")): file = await event.client.download_media(reply.media) iurl = uf(file) media = f"https://telegra.ph{iurl[0]}" elif "sticker" in media_type: media = reply.file.id else: return await eor(event, "`Unsupported media`", time=5) await eor(event, "`Done`", time=2) add_afk(text, media_type, media) msg1, msg2 = None, None if text and media: if "sticker" in media_type: msg1 = await ultroid_bot.send_file(event.chat_id, file=media) msg2 = await ultroid_bot.send_message( event.chat_id, get_string("afk_5").format(text)) else: msg1 = await ultroid_bot.send_message( event.chat_id, get_string("afk_5").format(text), file=media) elif media: if "sticker" in media_type: msg1 = await ultroid_bot.send_file(event.chat_id, file=media) msg2 = await ultroid_bot.send_message(event.chat_id, get_string("afk_6")) else: msg1 = await ultroid_bot.send_message(event.chat_id, get_string("afk_6"), file=media) elif text: msg1 = await ultroid_bot.send_message(event.chat_id, get_string("afk_5").format(text)) else: msg1 = await ultroid_bot.send_message(event.chat_id, get_string("afk_6")) old_afk_msg.append(msg1) if msg2: old_afk_msg.append(msg2) return await asst.send_message(LOG_CHANNEL, msg2.text) await asst.send_message(LOG_CHANNEL, msg1.text)
async def setwel(event): x = await event.eor(get_string("com_1")) r = await event.get_reply_message() btn = format_btn(r.buttons) if (r and r.buttons) else None try: text = event.text.split(maxsplit=1)[1] except IndexError: text = r.text if r else None if r and r.media: wut = mediainfo(r.media) if wut.startswith(("pic", "gif")): dl = await r.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if r.media.document.size > 8 * 1000 * 1000: return await eor(x, get_string("com_4"), time=5) dl = await r.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "web": m = None else: m = pack_bot_file_id(r.media) if r.text: txt = r.text if not btn: txt, btn = get_msg_button(r.text) add_welcome(event.chat_id, txt, m, btn) else: add_welcome(event.chat_id, None, m, btn) await eor(x, get_string("grt_1")) elif text: if not btn: txt, btn = get_msg_button(text) add_welcome(event.chat_id, txt, None, btn) await eor(x, get_string("grt_1")) else: await eor(x, get_string("grt_3"), time=5)
async def an(e): wrd = (e.pattern_match.group(1)).lower() wt = await e.get_reply_message() chat = e.chat_id if not (wt and wrd): return await e.eor(get_string("notes_1"), time=5) if "#" in wrd: wrd = wrd.replace("#", "") btn = format_btn(wt.buttons) if wt.buttons else None if wt and wt.media: wut = mediainfo(wt.media) if wut.startswith(("pic", "gif")): dl = await wt.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if wt.media.document.size > 8 * 1000 * 1000: return await e.eor(get_string("com_4"), time=5) dl = await wt.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] else: m = pack_bot_file_id(wt.media) if wt.text: txt = wt.text if not btn: txt, btn = get_msg_button(wt.text) add_note(chat, wrd, txt, m, btn) else: add_note(chat, wrd, None, m, btn) else: txt = wt.text if not btn: txt, btn = get_msg_button(wt.text) add_note(chat, wrd, txt, None, btn) await e.eor(get_string("notes_2").format(wrd)) ultroid_bot.add_handler(notes, events.NewMessage())
async def setgb(event): x = await eor(event, get_string("com_1")) r = await event.get_reply_message() btn = format_btn(r.buttons) if (r and r.buttons) else None if r and r.media: wut = mediainfo(r.media) if wut.startswith(("pic", "gif")): dl = await r.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "video": if r.media.document.size > 8 * 1000 * 1000: return await eor(x, get_string("com_4"), time=5) dl = await r.download_media() variable = uf(dl) os.remove(dl) m = "https://telegra.ph" + variable[0] elif wut == "web": m = None else: m = pack_bot_file_id(r.media) if r.text: txt = r.text if not btn: txt, btn = get_msg_button(r.text) add_goodbye(event.chat_id, txt, m, btn) else: add_goodbye(event.chat_id, None, m, btn) await eor(x, "`Goodbye note saved`") elif r and r.text: txt = r.text if not btn: txt, btn = get_msg_button(r.text) add_goodbye(event.chat_id, txt, None, btn) await eor(x, "`Goodbye note saved`") else: await eor(x, get_string("grt_7"), time=5)
async def _(e): r = await e.get_reply_message() if r.photo: dl = await r.download_media() elif r.document and r.document.thumbs: dl = await r.download_media(thumb=-1) else: return await e.eor("`Reply to Photo or media with thumb...`") variable = uf(dl) os.remove(dl) nn = "https://telegra.ph" + variable[0] udB.set_key("CUSTOM_THUMBNAIL", str(nn)) await bash(f"wget {nn} -O resources/extras/ultroid.jpg") await e.eor(get_string("cvt_6").format(nn), link_preview=False)
async def _(e): r = await e.get_reply_message() pop = "`Reply to img or file with thumbnail.`" if not r: return await eor(e, pop) if isinstance(r.media, photu): dl = await e.client.download_media(r.media) elif isinstance(r.media, doc): if r.media.document.thumbs: dl = await e.client.download_media(r, thumb=-1) else: return await eor(e, pop) variable = uf(dl) os.remove(dl) nn = "https://telegra.ph" + variable[0] udB.set("CUSTOM_THUMBNAIL", str(nn)) await bash(f"wget {nn} -O resources/extras/ultroid.jpg") await eor(e, f"Added [This]({nn}) As Your Custom Thumbnail", link_preview=False)
async def ocrify(ult): if not ult.is_reply: return await eor(ult, "`Reply to Photo...`") msg = await eor(ult, "`Processing..`") OAPI = udB.get("OCR_API") if not OAPI: return await msg.edit(TE) pat = ult.pattern_match.group(1) repm = await ult.get_reply_message() if not (repm.media and repm.media.photo): return await msg.edit("`Not a Photo..`") dl = await repm.download_media() if pat: atr = f"&language={pat}&" else: atr = "&" tt = uf(dl) li = "https://telegra.ph" + tt[0] gr = r.get( f"https://api.ocr.space/parse/imageurl?apikey={OAPI}{atr}url={li}" ).json() trt = gr["ParsedResults"][0]["ParsedText"] await msg.edit(f"**🎉 OCR PORTAL\n\nRESULTS ~ ** `{trt}`")