diff --git a/assistant/callbackstuffs.py b/assistant/callbackstuffs.py index d623de9..ea5ee2c 100644 --- a/assistant/callbackstuffs.py +++ b/assistant/callbackstuffs.py @@ -1044,7 +1044,7 @@ async def disus(event): name = "Pm Logger Group" async with event.client.conversation(pru) as conv: await conv.send_message( - f"Send The Symbol Which u want as your {name}\n\n use /cancel to cancel.", + f"Send The Chat Id of group Which u want as your {name}\n\n use /cancel to cancel.", ) response = conv.wait_event(events.NewMessage(chats=pru)) response = await response @@ -1054,11 +1054,6 @@ async def disus(event): "Cancelled!!", buttons=get_back_button("pml"), ) - elif len(themssg) > 1: - await conv.send_message( - "Incorrect Value", - buttons=get_back_button("pml"), - ) else: await setit(event, var, themssg) await conv.send_message( diff --git a/plugins/calculator.py b/plugins/calculator.py index 67de8d1..5d60dce 100644 --- a/plugins/calculator.py +++ b/plugins/calculator.py @@ -14,6 +14,8 @@ import re from . import * +CALC = {} + m = [ "AC", "C", @@ -62,54 +64,64 @@ async def _(e): @owner async def _(e): x = (e.data_match.group(1)).decode() + user = e.query.user_id + get = None if x == "AC": - udB.delete("calc") + if CALC.get(user): + CALC.pop(user) await e.edit( "• Ultroid Inline Calculator •", buttons=[Button.inline("Open Calculator Again", data="recalc")], ) elif x == "C": - udB.delete("calc") + if CALC.get(user): + CALC.pop(user) await e.answer("cleared") elif x == "⌫": - get = udB.get("calc") + if CALC.get(user): + get = CALC[user] if get: - udB.set("calc", get[:-1]) + CALC.update({user: get[:-1]}) await e.answer(str(get[:-1])) elif x == "%": - get = udB.get("calc") + if CALC.get(user): + get = CALC[user] if get: - udB.set("calc", get + "/100") + CALC.update({user: get + "/100"}) await e.answer(str(get + "/100")) elif x == "÷": - get = udB.get("calc") + if CALC.get(user): + get = CALC[user] if get: - udB.set("calc", get + "/") + CALC.update({user: get + "/"}) await e.answer(str(get + "/")) elif x == "x": - get = udB.get("calc") + if CALC.get(user): + get = CALC[user] if get: - udB.set("calc", get + "*") + CALC.update({user: get + "*"}) await e.answer(str(get + "*")) elif x == "=": - get = udB.get("calc") + if CALC.get(user): + get = CALC[user] if get: if get.endswith(("*", ".", "/", "-", "+")): get = get[:-1] - out = await calcc(get, e) + out = eval(get) try: num = float(out) await e.answer(f"Answer : {num}", cache_time=0, alert=True) except BaseException: - udB.delete("calc") + CALC.pop(user) await e.answer("Error", cache_time=0, alert=True) await e.answer("None") else: - get = udB.get("calc") + if CALC.get(user): + get = CALC[user] if get: - udB.set("calc", get + x) - await e.answer(str(get + x)) - udB.set("calc", x) + CALC.update({user: get + x}) + return await e.answer(str(get + x)) + CALC.update({user: x}) await e.answer(str(x)) diff --git a/plugins/compressor.py b/plugins/compressor.py index e9ef2e4..6c483d4 100644 --- a/plugins/compressor.py +++ b/plugins/compressor.py @@ -95,7 +95,7 @@ async def _(e): text = fil.read() frames = re.findall("frame=(\\d+)", text) size = re.findall("total_size=(\\d+)", text) - + speed = 0 if len(frames): elapse = int(frames[-1]) if len(size): diff --git a/plugins/polls.py b/plugins/polls.py index 68766bd..ac5ea57 100644 --- a/plugins/polls.py +++ b/plugins/polls.py @@ -27,7 +27,7 @@ from . import * pattern="poll ?(.*)", ) async def uri_poll(e): - if not e.sender._bot and e.is_private: + if not e.client._bot and e.is_private: return await eor(e, "`Use this in Group/Channel.`", time=15) match = e.pattern_match.group(1) if not match: diff --git a/plugins/stickertools.py b/plugins/stickertools.py index e624590..2988f12 100644 --- a/plugins/stickertools.py +++ b/plugins/stickertools.py @@ -446,7 +446,7 @@ async def ultdround(event): async def ultdestroy(event): ult = await event.get_reply_message() if not ( - ult and ult.media and "animated" in mediainfo(a.media) + ult and ult.media and "animated" in mediainfo(ult.media) ): return await eor(event, "`Reply to Animated Sticker only`") await event.client.download_media(ult, "ultroid.tgs") diff --git a/plugins/webshot.py b/plugins/webshot.py index a867ec5..c8b7674 100644 --- a/plugins/webshot.py +++ b/plugins/webshot.py @@ -14,34 +14,19 @@ """ import os -import requests from htmlwebshot import WebShot from . import * -@ultroid_cmd(pattern="webshot") +@ultroid_cmd(pattern="webshot ?(.*)") async def webss(event): xx = await eor(event, get_string("com_1")) - mssg = event.text.split(" ", maxsplit=2) - try: - xurl = mssg[1] - except IndexError: + xurl = e.pattern_match.group(1) + if not xurl: return await eor(xx, "`Give a URL please!`", time=5) - try: - requests.get(xurl) - except requests.ConnectionError: + elif not is_url_ok(xurl): return await eor(xx, "Invalid URL!", time=5) - except requests.exceptions.MissingSchema: - try: - xurl = "https://" + xurl - requests.get(xurl) - except requests.ConnectionError: - try: - xurl = "http://" + xurl - requests.get(xurl) - except requests.ConnectionError: - return await eor(xx, "Invalid URL!", time=5) shot = WebShot(quality=88, flags=["--enable-javascript", "--no-stop-slow-scripts"]) pic = await shot.create_pic_async(url=xurl) await xx.reply( diff --git a/requirements.txt b/requirements.txt index 6a2c9c3..4799590 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ https://github.com/New-dev0/Telethon/archive/Crunch.zip -py-Ultroid==2021.9.16 +py-Ultroid==2021.9.18 pytgcalls==3.0.0.dev19 diff --git a/vcbot/__init__.py b/vcbot/__init__.py index 614c217..bd762dd 100644 --- a/vcbot/__init__.py +++ b/vcbot/__init__.py @@ -31,6 +31,7 @@ from pyUltroid.functions.all import ( bash, downloader, get_user_id, + is_url_ok, get_videos_link, inline_mention, mediainfo, @@ -365,12 +366,15 @@ async def dl_playlist(chat, from_user, link): return song, thumb, title, vid1["link"], duration finally: for z in links[1:]: - search = VideosSearch(z, limit=1).result() - vid = search["result"][0] - duration = vid.get("duration") or "♾" - title = vid["title"] - thumb = f"https://i.ytimg.com/vi/{vid['id']}/hqdefault.jpg" - add_to_queue(chat, None, title, vid["link"], thumb, from_user, duration) + try: + search = VideosSearch(z, limit=1).result() + vid = search["result"][0] + duration = vid.get("duration") or "♾" + title = vid["title"] + thumb = f"https://i.ytimg.com/vi/{vid['id']}/hqdefault.jpg" + add_to_queue(chat, None, title, vid["link"], thumb, from_user, duration) + except Exception as er: + LOGS.exception(er) async def file_download(event, reply, fast_download=True): diff --git a/vcbot/auth.py b/vcbot/auth.py index c471c2a..a6009a3 100644 --- a/vcbot/auth.py +++ b/vcbot/auth.py @@ -71,7 +71,10 @@ async def listVc(e): text = "• Vc Auth Chats •\n\n" for on in chats.keys(): st = "Admins" if chats[on]["admins"] else "All" - title = (await e.client.get_entity(on)).title + try: + title = (await e.client.get_entity(on)).title + except ValueError: + title = "No Info" text += f"∆ {title} [ {on} ] : {st}" await eor(e, text, parse_mode="html") diff --git a/vcbot/radio.py b/vcbot/radio.py index 07037f9..a20eeb5 100644 --- a/vcbot/radio.py +++ b/vcbot/radio.py @@ -16,8 +16,6 @@ """ -import requests - from . import * @@ -37,9 +35,7 @@ async def radio_mirchi(e): else: song = e.text.split(maxsplit=1)[1] chat = e.chat_id - try: - requests.get(song) - except BaseException: + if not is_url_ok(song): return await eor(xx, f"`{song}`\n\nNot a playable link.🥱") ultSongs = Player(chat, e) if not ultSongs.group_call.is_connected: @@ -69,9 +65,7 @@ async def live_stream(e): else: song = e.text.split(maxsplit=1)[1] chat = e.chat_id - try: - requests.get(song) - except BaseException: + if not is_url_ok(song): return await eor(xx, f"`{song}`\n\nNot a playable link.🥱") is_live_vid = False if re.search("youtu", song): diff --git a/vcbot/videoplay.py b/vcbot/videoplay.py index 1e379eb..ca076cb 100644 --- a/vcbot/videoplay.py +++ b/vcbot/videoplay.py @@ -15,10 +15,6 @@ """ - -import requests -from requests.exceptions import MissingSchema - from . import * @@ -59,13 +55,7 @@ async def video_c(event): if reply and reply.media and mediainfo(reply.media).startswith("video"): song, thumb, title, link, duration = await file_download(xx, reply) else: - try: - requests.get(song) - is_link = True - except MissingSchema: - is_link = None - except BaseException: - is_link = False + is_link = is_url_ok(song) if is_link is False: return await eor(xx, f"`{song}`\n\nNot a playable link.🥱") if is_link is None: diff --git a/vcbot/ytplaylist.py b/vcbot/ytplaylist.py index a47ecce..7414b38 100644 --- a/vcbot/ytplaylist.py +++ b/vcbot/ytplaylist.py @@ -13,8 +13,6 @@ """ -import requests - from . import * @@ -36,9 +34,7 @@ async def live_stream(e): chat = e.chat_id if not (re.search("youtu", song) and re.search("playlist\\?list", song)): return await eor(xx, "Give only youtube playlist") - try: - requests.get(song) - except BaseException: + if not is_url_ok(song): return await eor(xx, f"`Only Youtube Playlist please.`") await xx.edit("`Keep patience... It'll take some time.`") file, thumb, title, link, duration = await dl_playlist(chat, html_mention(e), song)