Example #1
0
 async def updatexxx(message):
     if not utils.get_arg(message):
         os.popen("git fetch")
         await message.edit("<i>Checking...</i>")
         await asyncio.sleep(1)
         updates = os.popen(
             "git log --pretty=format:'%s - %an (%cr)' --abbrev-commit"
             " --date=relative master..origin/master").readlines()
         if updates:
             ls = "<b>Updates:</b>\n\n"
             for i in updates:
                 ls += f"◍  <i>{i.capitalize()}</i>"
             await message.edit(
                 f"{ls}\n\n<b>Type</b> <i>.update now</i> <b>to update</b>")
         else:
             await message.edit("<i>Well, no updates yet</i>")
         return
     print(utils.get_arg(message))
     await message.edit("<i>Updating</i>")
     update = os.popen("git pull").read()
     if "up to date" not in update:
         await message.edit(f"<i>Succesfully Updated</i>")
         await asyncio.sleep(1.5)
         await Misc.restartxxx(message)
     else:
         await message.edit(f"<i>{update}</i>")
Example #2
0
    async def disapprovexxx(message):
        """Prevents that person to PM you, you can either reply to user,
type their username or use this in their chat"""
        id = None if not utils.get_arg(message) else (
            await message.client.get_entity(utils.get_arg(message))).id
        reply = None if not message.is_reply else (
            await message.get_reply_message()).sender_id
        chat = None if not hasattr(message.to_id,
                                   "user_id") else message.chat_id
        if not reply and not id and not chat:
            await message.edit("<b>No user found</b>")
            return
        pick = reply if not id and not chat else id or chat
        if pick == (await message.client.get_me()).id:
            await message.edit(
                "<b>Why would you wanna disapprove yourself?</b>")
            return
        if not await nicedb.check_approved(pick):
            await message.edit("<i>User is not approved</i>")
            return
        else:
            await nicedb.disapprove(pick)
            await message.edit(
                "<a href=tg://user?id={}>{}</a> <b>is disapproved to PM you now</b>"
                .format(pick, (await
                               message.client.get_entity(pick)).first_name))
Example #3
0
 async def kangxxx(message):
     """Kangs a sticker or photo into you pack"""
     reply = await message.get_reply_message()
     if not reply.photo and not reply.sticker:
         await message.edit("<i>Reply to an image or get out</i>")
         return
     img = await reply.download_media()
     await Stickers.resize(message, img)
     packid = await settings.check_pack()
     if not packid:
         msg = "<i>You have no sticker pack set, so I'm creating a new pack</i>"
         task = "/newpack"
         pn = pn = "NiceGrill" if not message.sender.username else message.sender.username.capitalize(
         )
         result = (
             "<i>Your new pack has been created.</i>\n"
             "<i>Click</i> <a href=https://t.me/addstickers/{}>Here</a> "
             "<i>to access it</i>")
         name, emoji, done, packid = False, False, False, False
         await Stickers.kang(message, msg, task, name, emoji, done, packid,
                             result)
     else:
         msg = random.choice(Stickers.STRINGS)
         task = "/addsticker"
         result = (
             "<i>Sticker kanged succesfully.</i>\n"
             "<i>Click</i> <a href=https://t.me/addstickers/{}>Here</a> "
             "<i>to access it</i>".format(packid))
         emoji = utils.get_arg(message) if utils.get_arg(message) else False
         name, done = True, True
         await Stickers.kang(message, msg, task, name, emoji, done, packid,
                             result)
Example #4
0
 async def codenamexxx(request):
     """ search for android codename """
     textx = await request.get_reply_message()
     brand = utils.get_arg(request).split()[0].lower()
     device = utils.get_arg(request).split()[1].lower()
     if brand and device:
         pass
     elif textx:
         brand = textx.text.split(' ')[0]
         device = ' '.join(textx.text.split(' ')[1:])
     else:
         await request.edit("<code>Usage: .codename <brand> <device></code>"
                            )
         return
     found = [
         i for i in get(DEVICES_DATA).json()
         if i["brand"].lower() == brand and device in i["name"].lower()
     ]
     if len(found) > 8:
         found = found[:8]
     if found:
         reply = f'Search results for {brand.capitalize()} {device.capitalize()}:\n\n'
         for item in found:
             brand = item['brand']
             name = item['name']
             codename = item['device']
             model = item['model']
             reply += f'{brand} {name}\n' \
                 f'<b>Codename</b>: <code>{codename}</code>\n' \
                 f'<b>Model</b>: {model}\n\n'
     else:
         reply = f"<code>Couldn't find {device} codename!</code>\n"
     await request.edit(reply)
Example #5
0
 async def getpastexxx(message):
     if message.is_reply:
         reply = await message.get_reply_message()
         link = False
         for entity in reply.entities:
             if isinstance(entity, MessageEntityUrl):
                 link = reply.message[entity.offset:entity.offset +
                                      entity.length]
         if not link:
             await message.edit("<i>You didn't specify a dogbin URL</i>")
             return
         await message.edit("<i>Fetching..</i>")
     elif utils.get_arg(message):
         link = utils.get_arg(message)
         await message.edit("<i>Fetching..</i>")
     else:
         await message.edit("<i>You didn't specify a dogbin URL</i>")
         return
     if not link.startswith(f"{URL}"):
         await message.edit("<i>Not a valid URL</i>")
         return
     if "raw" in link.split("/"):
         getpaste = get(link)
     else:
         link = link.split("/")
         link.insert(-1, "raw")
         print(link)
         link = "/".join(link)
         getpaste = get(link)
     await message.edit(getpaste.text)
Example #6
0
    async def purgemexxx(message):
        """Perfect tool(like you 🥰) for a spring cleaning\n
Purges the chat with a given message count or till the replied message but only your messages
        """
        client = message.client
        count = int(utils.get_arg(message)) + \
            1 if utils.get_arg(message).isdigit() else None
        msgs = []
        if not count and not message.is_reply:
            await message.edit("<b>Enter a number or reply to a message</b>")
            return
        elif not count and message.is_reply:
            count = (await message.get_reply_message()).id - 1
        async for msg in client.iter_messages(message.chat_id,
                                              from_user='******',
                                              limit=count,
                                              min_id=count):
            msgs.append(msg.id)
        await client.delete_messages(message.chat_id, msgs)
        success = (await client.send_message(
            message.chat_id,
            "<b>Purge has been successful. This message will disappear in 3 seconds.</b>"
        ))
        await asyncio.sleep(3)
        await client.delete_messages(message.chat_id, success.id)
Example #7
0
 async def setcityxxx(message):
     """Sets a default city so that you don't have to type it everytime"""
     if not utils.get_arg(message):
         await settings.delete("City")
         await message.edit("<b>Saved city name removed</b>")
         return
     await settings.delete("City")
     await settings.set_city(utils.get_arg(message))
     await message.edit("<b>Successfully saved</b>")
Example #8
0
 async def lmgtfyxxx(message):
     keyword = ((await message.get_reply_message()).message
                if not utils.get_arg(message) else utils.get_arg(message))
     if not keyword:
         await message.edit(
             "<i>You didn't specify a keyword. Reply to a message"
             " or enter a keyword</i>")
         return
     link = f"https://lmgtfy.com/?q={keyword.replace(' ', '+')}"
     reply_id = ((await message.get_reply_message()).id
                 if message.is_reply else None)
     await message.edit(link)
Example #9
0
 async def specsxxx(request):
     """ Mobile devices specifications """
     textx = await request.get_reply_message()
     brand = utils.get_arg(request).split(",")[0].lower()
     device = utils.get_arg(request).split(",")[1].lower()
     if brand and device:
         pass
     elif textx:
         brand = textx.text.split(',')[0]
         device = ' '.join(textx.text.split(',')[1])
     else:
         await request.edit("<code>Usage: .specs <brand> <device></code>")
         return
     all_brands = BeautifulSoup(
         get('https://www.devicespecifications.com/en/brand-more').content,
         'lxml').find('div', {
             'class': 'brand-listing-container-news'
         }).findAll('a')
     brand_page_url = None
     try:
         brand_page_url = [
             i['href'] for i in all_brands
             if brand == i.text.strip().lower()
         ][0]
     except IndexError:
         await request.edit(f'<code>{brand} is unknown brand!</code>')
     devices = BeautifulSoup(get(brand_page_url).content, 'lxml') \
         .findAll('div', {'class': 'model-listing-container-80'})
     device_page_url = None
     try:
         device_page_url = [
             i.a['href']
             for i in BeautifulSoup(str(devices), 'lxml').findAll('h3')
             if device in i.text.strip().lower()
         ]
     except IndexError:
         await request.edit(f"<code>can't find {device}!</code>")
     if len(device_page_url) > 2:
         device_page_url = device_page_url[:2]
     reply = ''
     for url in device_page_url:
         info = BeautifulSoup(get(url).content, 'lxml')
         reply = '\n<b>' + info.title.text.split(
             '-')[0].strip() + '</b>\n\n'
         info = info.find('div', {'id': 'model-brief-specifications'})
         specifications = re.findall(r'<b>.*?<br/>', str(info))
         for item in specifications:
             title = re.findall(r'<b>(.*?)</b>', item)[0].strip()
             data = re.findall(r'</b>: (.*?)<br/>', item)[0]\
                 .replace('<b>', '').replace('</b>', '').strip()
             reply += f'<b>{title}</b>: {data}\n'
     await request.edit(reply)
Example #10
0
 async def setgfolderxxx(message):
     """Specifies what folder your downloads go in in your drive"""
     gservice = GoogleDrive.get_service()
     gservice.auth()
     folder = gservice.list_folders_by_name(utils.get_arg(message))[0]["id"]
     if not folder:
         folder = gservice.create_folder(utils.get_arg(message))
         await message.edit(
             "<b>You dont have this folder in your drive so i created it for you</b>"
         )
     await settings.delete("GFolder")
     await settings.set_gfolder(folder)
     await message.edit("<b>Succesfully saved</b>")
Example #11
0
 async def promotexxx(message):
     await message.edit("<b>Promoting...</b>")
     chat = message.input_chat
     try:
         user = (
             (await message.client.get_entity(utils.get_arg(message))).id
             if not message.is_reply else
             (await message.get_reply_message()).sender.id)
     except ValueError:
         await message.edit("<b>No user found in that name</b>")
         return
     try:
         await message.client(EditAdminRequest(chat, user, PROMOTE, "Admin"))
         await message.edit("<b>Successfully promoted</b>")
     except TypeError:
         await message.edit("<b>Are you sure this is a genuine chat?</b>")
     except AdminsTooMuchError:
         await message.edit("<b>There are too many admins in this chat</b>")
     except UserPrivacyRestrictedError:
         await message.edit("<b>The user's privacy settings do not allow you to do this</b>")
     except UserNotMutualContactError:
         await message.edit("<b>The provided user is not a mutual contact</b>")
     except UserIdInvalidError:
         await message.edit("<b>Specified user is a no go</b>")
     except UserCreatorError:
         await message.edit("<b>Wtf, that is the chat owner..</b>")
     except RightForbiddenError:
         await message.edit(
             "<b>You either don't have enough permissions or there's something wrong with the admin rights</b>")
     except ChatAdminRequiredError:
         await message.edit("<b>Oh honey, I'm not admin enough to promote this user 🙄</b>")
Example #12
0
 async def pastexxx(message):
     msg = utils.get_arg(message)
     repmsg = await message.get_reply_message()
     if repmsg:
         await message.edit("<i>Pasting..</i>")
         if repmsg.document and repmsg.document.mime_type == "text/plain":
             doc = await repmsg.download_media()
             with open(doc, "r") as file:
                 context = file.read().encode()
             os.remove(doc)
         elif repmsg.message:
             context = repmsg.message.encode()
         else:
             await message.edit(
                 "<i>Input or reply to some text to paste</i>")
             return
         paste = post(f"{URL}documents", data=context).json()
     elif msg:
         await message.edit("<i>Pasting..</i>")
         paste = post(f"{URL}documents", data=msg.encode()).json()
     else:
         await message.edit("<i>Input or reply to some text to paste</i>")
         return
     if paste["key"]:
         await message.edit("<i>Your text pasted successfully.\n"
                            f"Here's the link:</i> {URL + paste['key']}")
     else:
         await message.edit("<i>Something went wrong</i>")
Example #13
0
 async def twrpxxx(request):
     """ get android device twrp """
     textx = await request.get_reply_message()
     device = utils.get_arg(request)
     if device:
         pass
     elif textx:
         device = textx.text.split(' ')[0]
     else:
         await request.edit("<code>Usage: .twrp <codename></code>")
         return
     url = get(f'https://dl.twrp.me/{device}/')
     if url.status_code == 404:
         reply = f"<code>Couldn't find twrp downloads for {device}!</code>\n"
         await request.edit(reply)
         return
     page = BeautifulSoup(url.content, 'lxml')
     download = page.find('table').find('tr').find('a')
     dl_link = f"https://dl.twrp.me{download['href']}"
     dl_file = download.text
     size = page.find("span", {"class": "filesize"}).text
     date = page.find("em").text.strip()
     reply = f'<b>Latest TWRP for {device}:</b>\n' \
         f'[{dl_file}]({dl_link}) - <i>{size}</i>\n' \
         f'<b>Updated:</b> <i>{date}</i>\n'
     await request.edit(reply)
Example #14
0
 async def langxxx(message):
     lang = utils.get_arg(message)
     if lang:
         TextToSpeech.TTS_LANG = lang
         await message.edit("<i>Dil ayarlandı</i>")
     else:
         await message.edit("<i>Dil belirle moron</i>")
Example #15
0
 async def evalxxx(message):
     """A nice tool (like you 🥰) to test python codes"""
     args = utils.get_arg(message).strip()
     caption = "<b>⬤ Evaluated expression:</b>\n<code>{}</code>\n\n<b>⬤ Result:</b>\n".format(
         args)
     preserve_stdout = sys.stdout
     sys.stdout = StringIO()
     try:
         res = str(await meval(args, globals(), **await Python.funcs(message)))
     except Exception:
         caption = "<b>⬤ Evaluation failed:</b>\n<code>{}</code>\n\n<b>⬤ Result:</b>\n".format(
             args)
         etype, value, tb = sys.exc_info()
         res = ''.join(traceback.format_exception(etype, value, None, 0))
         sys.stdout = preserve_stdout
     try:
         val = sys.stdout.getvalue()
     except AttributeError:
         val = None
     printed = f"<b>⬤ Printed Result:</b>\n<code>{html.escape(val) if val else 'None'}</code>"
     sys.stdout = preserve_stdout
     try:
         await message.edit(caption + f"<code>{html.escape(res)}</code>\n\n{printed}")
     except MessageTooLongError:
         res = textwrap.wrap(res, 4096-len(caption))
         await message.edit(caption + f"<code>{res[0]}</code>")
         for part in res[1::]:
             await asyncio.sleep(1)
             await message.reply(f"<code>{part}</code>")
Example #16
0
 async def devicexxx(request):
     """ get android device basic info from its codename """
     textx = await request.get_reply_message()
     device = utils.get_arg(request)
     if device:
         pass
     elif textx:
         device = textx.text
     else:
         await request.edit(
             "<code>Usage: .device <codename> / <model></code>")
         return
     found = [
         i for i in get(DEVICES_DATA).json()
         if i["device"] == device or i["model"] == device
     ]
     if found:
         reply = f'Search results for {device}:\n\n'
         for item in found:
             brand = item['brand']
             name = item['name']
             codename = item['device']
             model = item['model']
             reply += f'{brand} {name}\n' \
                 f'<b>Codename</b>: <code>{codename}</code>\n' \
                 f'<b>Model</b>: {model}\n\n'
     else:
         reply = f"<code>Couldn't find info about {device}!</code>\n"
     await request.edit(reply)
Example #17
0
 async def unmutexxx(message):
     await message.edit("<b>Unmuting...</b>")
     chat = message.input_chat
     try:
         user = (
             (await message.client.get_entity(utils.get_arg(message))).id
             if not message.is_reply else
             (await message.get_reply_message()).sender.id)
     except ValueError:
         await message.edit("<b>No user found in that name</b>")
         return
     if not await nicedb.check_user(user):
         await nicedb.add_user(user, False, False, False, message.chat_id)
     else:
         await nicedb.update_user({"User": user}, {"Mute": False})
     try:
         await message.client(EditBannedRequest(chat, user, UNMUTE))
         # add_unmuted(user)
         await message.edit("<b>Unmuted</b>")
     except TypeError:
         await message.edit("<b>You need to be in a chat to do this</b>")
         return
     except TypeError:
         await message.edit("<b>You need to be in a chat to do this</b>")
         return
     except UserAdminInvalidError:
         await message.edit("<b>You're either not an admin or that's more admin than you</b>")
     except UserIdInvalidError:
         await message.edit("<b>Specified user is a no go</b>")
     except ChatAdminRequiredError:
         await message.edit("<b>Oh honey, I'm not admin enough to unmute this user 🙄</b>")
Example #18
0
 async def unbanxxx(message):
     chat = message.input_chat
     try:
         user = ((await message.client.get_entity(
             utils.get_arg(message))).id if not message.is_reply else
                 (await message.get_reply_message()).sender.id)
     except ValueError:
         await message.edit("<b>No user found in that name</b>")
         return
     try:
         await message.client(EditBannedRequest(chat, user, UNBAN))
         await message.edit(
             "<b>Alright, fine..All is forgiven, unbanned..</b>")
     except TypeError:
         await message.edit("<b>You need to be in a chat to do this</b>")
         return
     except UserAdminInvalidError:
         await message.edit(
             "<b>You're either not an admin or that's more admin than you</b>"
         )
     except UserIdInvalidError:
         await message.edit("<b>Specified user is a no go</b>")
     except ChatAdminRequiredError:
         await message.edit(
             "<b>Oh honey, I'm not admin enough to unban this user 🙄</b>"
         )
Example #19
0
 async def kickxxx(message):
     chat = message.input_chat
     try:
         user = ((await message.client.get_entity(
             utils.get_arg(message))).id if not message.is_reply else
                 (await message.get_reply_message()).sender.id)
     except ValueError:
         await message.edit("<b>No user found in that name</b>")
         return
     try:
         await message.client(
             EditBannedRequest(
                 chat, user,
                 ChatBannedRights(until_date=None, view_messages=True)))
         await message.edit("<b>Kicked...</b>")
     except TypeError:
         await message.edit("<b>You need to be in a chat to do this</b>")
         return
     except UserAdminInvalidError:
         await message.edit(
             "<b>You're either not an admin or that's more admin than you</b>"
         )
     except UserIdInvalidError:
         await message.edit("<b>Specified user is a no go</b>")
     except ChatAdminRequiredError:
         await message.edit(
             "<b>Oh honey, I'm not admin enough to kick this user 🙄</b>")
Example #20
0
 async def gdrivexxx(message):
     """Uploads the replied media or input url to your gdrive with a progressbar"""
     gservice = GoogleDrive.get_service()
     gservice.auth()
     # await message.edit("<b>Check your terminal screen for authorization
     # link</b>")
     arg = utils.get_arg(message)
     if message.is_reply or arg.startswith("http") or arg.startswith("www"):
         file = (await dl.dlxxx(message)).split("/")
     elif "/" not in arg:
         file = arg.split("/")
     if await settings.check_gfolder():
         folder = await settings.check_gfolder()
     elif gservice.list_folders_by_name('Telegram'):
         folder = gservice.list_folders_by_name('Telegram')[0]["id"]
     else:
         folder = gservice.create_folder('Telegram')
     await message.edit("<i>Uploading to GDrive</i>")
     try:
         up = gservice.upload_file(file[-1], "/".join(file), folder)
     except MemoryError:
         await message.edit("<b>Your drive is full</b>")
         return
     except NameError:
         await message.edit("<b>This file type is not supported</b>")
         return
     except FileNotFoundError:
         await message.edit("<b>This file doesn't exist</b>")
         return
     await message.edit(
         f"<i>{file[-1]}</i> <b>uploaded to your GDrive folder. </b>"
         f"<a href={gservice.anyone_permission(up)}>Click Here</a> <b>to access it</b>"
     )
     os.remove("/".join(file))
Example #21
0
 async def helpxxx(message):
     funcs = {}
     for cls in mods:
         for func in mods[cls]:
             funcs.update(mods[cls])
     help = " ‎\n•{}•".format("<b>Help</b>".center(85))
     name = utils.get_arg(message)
     if name and (name in funcs or name in classinfo):
         for cmd, value in funcs.items():
             if name == cmd:
                 templ = (
                     "{}\n\n<b>Here's the help for</b> <i>{}</i> <b>command:</b>\n\n"
                     .format(help, cmd))
                 await message.edit(
                     templ + funcs[cmd].__doc__) if value.__doc__ else await message.edit(
                     "<b>No help found for that command</b>")
                 return
         for cls in classinfo:
             if name == cls:
                 templ = (
                     "{}\n\n<b>Here's the commands in</b> <i>{}</i> <b>module:</b>\n\n"
                     .format(help, cls))
                 await message.edit(
                     templ + ", ".join(classinfo[cls]))
                 return
     elif name:
         await message.edit("<b>There's nothing found under that name</b>")
         return
     for cls in classinfo:
         help += "\n\n<b>⬤ {}:</b>\n<i>".format(cls)
         help += ", ".join(classinfo[cls]) + "</i>"
     await message.edit(help)
Example #22
0
 async def clearxxx(message):
     args = utils.get_arg(message)
     chatid = message.chat_id
     if not await nicedb.check_one("Notes", chatid, args):
         await message.edit("<b>No notes found in that name</b>")
         return
     await nicedb.delete_one("Notes", chatid, args)
     await message.edit("<b>Note deleted successfully</b>")
Example #23
0
    async def execxxx(message):
        """A nice tool (like you 🥰) to test python codes
There's no output on this one tho"""
        args = utils.get_arg(message).strip()
        try:
            await meval(args, globals(), **await Python.funcs(message))
        except Exception as e:
            Python.logger.error(e)
Example #24
0
 async def weatherxxx(message):
     """Shows the weather of specified city"""
     if not await settings.check_city() and not utils.get_arg(message):
         await message.edit("<b>Enter a city name first</b>")
         return
     city = await settings.check_city(
     ) if not utils.get_arg(message) else utils.get_arg(message)
     weather = wtr.find(city)
     await message.edit(
         f"<b>City:</b> <i>{weather['weather']['city']}</i>\n"
         f"<b>Temperature:</b> <i>{round(weather['weather']['temp'])}°C</i>\n"
         f"<b>Pressure:</b> <i>{weather['weather']['pressure']} hPa</i>\n"
         f"<b>Humidity:</b> <i>{weather['weather']['humidity']}%</i>\n"
         f"<b>Latency:</b> <i>{weather['weather']['lat']}</i>\n"
         f"<b>Status:</b> <i>{weather['main']}</i>\n"
         f"<b>Description:</b> <i>{weather['description'].capitalize()}</i>\n"
         f"<b>Wind Speed:</b> <i>{weather['wind']['speed']} m/s</i>\n")
Example #25
0
 async def quotefxxx(message):
     """Converts the replied message into an independent sticker"""
     reply = message
     user = await message.client.get_entity(
         utils.get_arg(message).split(",")[0])
     reply.text = utils.get_arg(message).split(",")[1].strip()
     await message.delete()
     msg = reply.text
     repliedreply = await reply.get_reply_message()
     res, canvas = await Quote.process(msg, user, message.client, reply)
     if not res:
         return
     canvas.save('.tmp/sticker.webp')
     await message.respond(file=".tmp/sticker.webp")
     os.remove('.tmp/sticker.webp')
     await message.respond(file=".tmp/sticker.webp")
     os.remove('.tmp/sticker.webp')
Example #26
0
 async def afkxxx(message):
     """AFK means Away from Keyboard ya dummy.. duh!"""
     msg = utils.get_arg(message)
     current = str(datetime.now())
     if not msg:
         msg = "No Reason"
     await nicedb.set_afk(msg, current)
     await message.edit("<b>I'm going AFK</b>")
Example #27
0
 async def pinxxx(message):
     reply = await message.get_reply_message()
     loud = True if utils.get_arg(message) == "loud" else False
     if not reply:
         await message.edit("<b>Reply to a message first.</b>")
         return
     await message.client.pin_message(
         message.input_chat, reply.id, notify=loud)
     await message.edit("<b>Pinned succesfully.</b>")
Example #28
0
 async def ytsxxx(video_q):
     """ For .yt command, do a YouTube search from Telegram. """
     query = utils.get_arg(video_q)
     if not query:
          await video_q.edit("<i>Enter a search query.</i>")
     results = json.loads(YoutubeSearch(str(query), max_results=8).to_json())
     text = ""
     for i in results["videos"]:
            text += f"<b>◍ {i['title']}</b>\nhttps://www.youtube.com{i['link']}\n\n"
     await video_q.edit(text)
Example #29
0
 async def unblockxxx(message):
     """Simply unblocks the person..duh!!"""
     id = None if not utils.get_arg(message) else (
         await message.client.get_entity(utils.get_arg(message))).id
     reply = None if not message.is_reply else (
         await message.get_reply_message()).sender_id
     chat = None if not hasattr(message.to_id,
                                "user_id") else message.chat_id
     if not reply and not id and not chat:
         await message.edit("<i>No user found</i>")
         return
     pick = reply or id or chat
     if pick == (await message.client.get_me()).id:
         await message.edit("<i>Why would you wanna unblock yourself?</i>")
         return
     await message.client(functions.contacts.UnblockRequest(id=pick))
     await message.edit(
         "<a href=tg://user?id={}>{}</a> <i>has been unblocked</i>".format(
             pick, (await message.client.get_entity(pick)).first_name))
Example #30
0
 async def setpathxxx(message):
     """Sets a download path, make sure to add / in the end"""
     pathname = utils.get_arg(message)
     if not os.path.exists(pathname):
         os.mkdir(pathname, 0o755)
     await settings.delete("Path")
     if await settings.set_path(pathname):
         await message.edit("<b>Successfully set.</b>")
     else:
         await message.edit("<b>Something went wrong.</b>")