Ejemplo n.º 1
0
async def add_sticker_to_pack(
        bot: TelegramClient) -> Tuple[StickerSet, InputDocument]:
    global sticker_pack
    animated = current_vote['animated']
    if animated:
        file = await bot.upload_file(current_vote['filepath'])
        mime = 'application/x-tgsticker'
    else:
        img = Image.open(current_vote['filepath'])
        w, h = img.size
        if w > h:
            img = img.resize((512, int(h * (512 / w))), Image.ANTIALIAS)
        else:
            img = img.resize((int((w * (512 / h))), 512), Image.ANTIALIAS)
        dat = BytesIO()
        img.save(dat, format='PNG')
        file = await bot.upload_file(dat.getvalue())
        mime = 'image/png'
    os.remove(current_vote['filepath'])
    file = InputMediaUploadedDocument(file, mime, [])
    document = await bot(UploadMediaRequest(InputPeerSelf(), file))
    document = utils.get_input_document(document)
    item = InputStickerSetItem(document=document, emoji=current_vote['emoji'])
    pack: Optional[StickerSet] = None
    added = False
    # TODO add support for animated stickers
    if not sticker_pack:
        added, pack = await create_sticker_pack(bot, item)
    if not added:
        pack = await bot(
            AddStickerToSetRequest(stickerset=sticker_pack, sticker=item))
    return pack, utils.get_input_document(pack.documents[-1])
Ejemplo n.º 2
0
    async def _handle_matrix_file(self, sender_id: TelegramID,
                                  event_id: EventID, space: TelegramID,
                                  client: 'MautrixTelegramClient',
                                  content: MediaMessageEventContent,
                                  reply_to: TelegramID) -> None:
        file = await self.main_intent.download_media(content.url)

        mime = content.info.mimetype

        w, h = content.info.width, content.info.height

        if content.msgtype == MessageType.STICKER:
            if mime != "image/gif":
                mime, file, w, h = util.convert_image(file,
                                                      source_mime=mime,
                                                      target_type="webp")
            else:
                # Remove sticker description
                content[
                    "net.maunium.telegram.internal.filename"] = "sticker.gif"
                content.body = ""

        file_name = self._get_file_meta(
            content["net.maunium.telegram.internal.filename"], mime)
        attributes = [DocumentAttributeFilename(file_name=file_name)]
        if w and h:
            attributes.append(DocumentAttributeImageSize(w, h))

        caption = content.body if content.body.lower() != file_name.lower(
        ) else None

        media = await client.upload_file_direct(
            file,
            mime,
            attributes,
            file_name,
            max_image_size=config["bridge.image_as_file_size"] * 1000**2)
        async with self.send_lock(sender_id):
            if await self._matrix_document_edit(client, content, space,
                                                caption, media, event_id):
                return
            try:
                response = await client.send_media(self.peer,
                                                   media,
                                                   reply_to=reply_to,
                                                   caption=caption)
            except (PhotoInvalidDimensionsError, PhotoSaveFileInvalidError,
                    PhotoExtInvalidError):
                media = InputMediaUploadedDocument(file=media.file,
                                                   mime_type=mime,
                                                   attributes=attributes)
                response = await client.send_media(self.peer,
                                                   media,
                                                   reply_to=reply_to,
                                                   caption=caption)
            self._add_telegram_message_to_db(event_id, space, 0, response)
Ejemplo n.º 3
0
def upload(tc, sets, subscribe=False):
    """Talk to Stickers bot and create the sets."""
    if not sets:
        print(ERROR_NO_SET_UPLOAD)
        return

    from functools import partial
    from telethon.tl.functions.messages import SendMessageRequest, SendMediaRequest, InstallStickerSetRequest
    from telethon.tl.types import InputMediaUploadedDocument, DocumentAttributeFilename, InputStickerSetShortName
    from telethon.tl.types.messages import StickerSetInstallResultSuccess

    _stickerbot = tc.get_input_entity('stickers')

    send_bot_cmd = partial(_send_bot_cmd, tc, _stickerbot)
    upload_file = partial(_upload_file, tc)

    # TODO: check if set already created (by anyone), ask to subscribe if set exists
    send_bot_cmd(SendMessageRequest, message='/cancel')
    send_bot_cmd(SendMessageRequest, message='/start')

    for _set in sets:
        set_title, set_short_name, stickers = _set

        send_bot_cmd(SendMessageRequest, message='/newpack')
        send_bot_cmd(SendMessageRequest, message=set_title)
        for index, (sticker_image, emojis) in enumerate(stickers):
            uploaded_file = upload_file(sticker_image)
            uploaded_doc = InputMediaUploadedDocument(
                file=uploaded_file,
                mime_type='image/png',
                attributes=[DocumentAttributeFilename(uploaded_file.name)])
            send_bot_cmd(SendMediaRequest, media=uploaded_doc, message='')
            send_bot_cmd(SendMessageRequest, message=emojis)
            print(NOTICE_UPLOADED % {
                'fn': uploaded_file.name,
                'cur': index + 1,
                'total': len(stickers)
            })
        send_bot_cmd(SendMessageRequest, message='/publish')
        send_bot_cmd(SendMessageRequest, message=set_short_name)
        print(NOTICE_SET_AVAILABLE % {
            'title': set_title,
            'short_name': set_short_name
        })

        if subscribe:
            result = tc.invoke(
                InstallStickerSetRequest(
                    InputStickerSetShortName(short_name=set_short_name),
                    archived=False))
            if isinstance(result, StickerSetInstallResultSuccess):
                print(NOTICE_SET_SUBSCRIBED % set_title)
Ejemplo n.º 4
0
    async def upload_file_direct(self, file: bytes, mime_type: str = None,
                                 attributes: List[TypeDocumentAttribute] = None,
                                 file_name: str = None, max_image_size: float = 10 * 1000 ** 2,
                                 ) -> Union[InputMediaUploadedDocument, InputMediaUploadedPhoto]:
        file_handle = await super().upload_file(file, file_name=file_name, use_cache=False)

        if (mime_type == "image/png" or mime_type == "image/jpeg") and len(file) < max_image_size:
            return InputMediaUploadedPhoto(file_handle)
        else:
            attributes = attributes or []
            attr_dict = {type(attr): attr for attr in attributes}

            return InputMediaUploadedDocument(
                file=file_handle,
                mime_type=mime_type or "application/octet-stream",
                attributes=list(attr_dict.values()))
Ejemplo n.º 5
0
    def send_document_file(self, input_file, input_peer, caption=''):
        """Sends a previously uploaded input_file
           (which should be a document) to an input_peer"""

        # Determine mime-type and attributes
        # Take the first element by using [0] since it returns a tuple
        mime_type = guess_type(input_file.name)[0]
        attributes = [
            DocumentAttributeFilename(input_file.name)
            # TODO If the input file is an audio, find out:
            # Performer and song title and add DocumentAttributeAudio
        ]
        # Ensure we have a mime type, any; but it cannot be None
        # «The "octet-stream" subtype is used to indicate that a body contains arbitrary binary data.»
        if not mime_type:
            mime_type = 'application/octet-stream'
        self.send_media_file(InputMediaUploadedDocument(file=input_file,
                                                        mime_type=mime_type,
                                                        attributes=attributes,
                                                        caption=caption), input_peer)
Ejemplo n.º 6
0
def send_file(client, entity, file, dur, title, artist, caption):
  file_hash = hash(file)
  if file_hash in client._upload_cache: file_handle = client._upload_cache[file_hash]
  else: client._upload_cache[file_hash] = file_handle = client.upload_file(file)
  attr_dict = {
    DocumentAttributeFilename:
    DocumentAttributeFilename(caption),
    DocumentAttributeAudio:
    DocumentAttributeAudio(int(dur), title=title, performer=artist)
  }
  media = InputMediaUploadedDocument(
    file=file_handle,
    mime_type='audio/mpeg',
    attributes=list(attr_dict.values()),
    caption=''
  )
  client(SendMediaRequest(
    peer=client.get_input_entity(entity),
    media=media,
    reply_to_msg_id=None
  ))
Ejemplo n.º 7
0
    def _do_uploads(self, subscribe):
        """Talk to Stickers bot and create the sets."""
        self._sticker_bot_cmd(SendMessageRequest, message='/cancel')
        self._sticker_bot_cmd(SendMessageRequest, message='/start')

        for _set in self._stickersets:
            set_title, set_short_name, stickers = _set

            self._sticker_bot_cmd(SendMessageRequest, message='/newpack')
            self._sticker_bot_cmd(SendMessageRequest, message=set_title)
            for index, (sticker_image, emojis) in enumerate(stickers):
                uploaded_file = self._do_upload_file(sticker_image)
                uploaded_doc = InputMediaUploadedDocument(
                    file=uploaded_file,
                    mime_type='image/png',
                    attributes=[DocumentAttributeFilename(uploaded_file.name)],
                    caption='')
                self._sticker_bot_cmd(SendMediaRequest, media=uploaded_doc)
                self._sticker_bot_cmd(SendMessageRequest, message=emojis)
                print(
                    NOTICE_UPLOADED % {
                        'fn': uploaded_file.name,
                        'cur': index + 1,
                        'total': len(stickers)
                    })
            self._sticker_bot_cmd(SendMessageRequest, message='/publish')
            self._sticker_bot_cmd(SendMessageRequest, message=set_short_name)
            print(NOTICE_SET_AVAILABLE % {
                'title': set_title,
                'short_name': set_short_name
            })

            if subscribe:
                result = self._TC.invoke(
                    InstallStickerSetRequest(
                        InputStickerSetShortName(short_name=set_short_name),
                        archived=False))
                if type(result) == StickerSetInstallResultSuccess:
                    print(NOTICE_SET_SUBSCRIBED % set_title)
Ejemplo n.º 8
0
async def _(event):
    if event.fwd_from:
        return
    if not event.is_reply:
        await event.edit("Reply to a photo to add to my personal sticker pack."
                         )
        return
    reply_message = await event.get_reply_message()
    sticker_emoji = "🔥"
    input_str = event.pattern_match.group(1)
    if input_str:
        sticker_emoji = input_str
    if not is_message_image(reply_message):
        await event.edit("Invalid message type")
        return
    me = borg.me
    userid = event.from_id
    packname = f"@Deadpool003 @OnlyMoviesLovers"
    packshortname = f"Uni_Borg_{userid}"  # format: Uni_Borg_userid

    await event.edit("Stealing this sticker. Please Wait!")

    async with borg.conversation("@Stickers") as bot_conv:
        now = datetime.datetime.now()
        dt = now + datetime.timedelta(minutes=1)
        file = await borg.download_file(reply_message.media)
        with BytesIO(file) as mem_file, BytesIO() as sticker:
            resize_image(mem_file, sticker)
            sticker.seek(0)
            uploaded_sticker = await borg.upload_file(
                sticker, file_name="@UniBorg_Sticker.png")
            if not await stickerset_exists(bot_conv, packshortname):
                await silently_send_message(bot_conv, "/cancel")
                response = await silently_send_message(bot_conv, "/newpack")
                if response.text != "Yay! A new stickers pack. How are we going to call it? Please choose a name for your pack.":
                    await event.edit(
                        f"**FAILED**! @Stickers replied: {response.text}")
                    return
                response = await silently_send_message(bot_conv, packname)
                if not response.text.startswith("Alright!"):
                    await event.edit(
                        f"**FAILED**! @Stickers replied: {response.text}")
                    return
                await bot_conv.send_file(InputMediaUploadedDocument(
                    file=uploaded_sticker,
                    mime_type='image/png',
                    attributes=[
                        DocumentAttributeFilename("@UniBorg_Sticker.png")
                    ]),
                                         force_document=True)
                await bot_conv.get_response()
                await silently_send_message(bot_conv, sticker_emoji)
                await silently_send_message(bot_conv, "/publish")
                await silently_send_message(bot_conv, "/skip")
                response = await silently_send_message(bot_conv, packshortname)
                if response.text == "Sorry, this short name is already taken.":
                    await event.edit(
                        f"**FAILED**! @Stickers replied: {response.text}")
                    return
            else:
                await silently_send_message(bot_conv, "/cancel")
                await silently_send_message(bot_conv, "/addsticker")
                await silently_send_message(bot_conv, packshortname)
                await bot_conv.send_file(InputMediaUploadedDocument(
                    file=uploaded_sticker,
                    mime_type='image/png',
                    attributes=[
                        DocumentAttributeFilename("@UniBorg_Sticker.png")
                    ]),
                                         force_document=True)
                response = await bot_conv.get_response()
                await silently_send_message(bot_conv, response)
                await silently_send_message(bot_conv, sticker_emoji)
                await silently_send_message(bot_conv, "/done")

    await event.edit(
        f"sticker stolen! Your pack can be found [here](t.me/addstickers/{packshortname})"
    )
Ejemplo n.º 9
0
    async def _handle_matrix_file(
            self,
            sender_id: TelegramID,
            event_id: EventID,
            space: TelegramID,
            client: 'MautrixTelegramClient',
            content: MediaMessageEventContent,
            reply_to: TelegramID,
            caption: TextMessageEventContent = None) -> None:
        mime = content.info.mimetype
        w, h = content.info.width, content.info.height
        file_name = content["net.maunium.telegram.internal.filename"]
        max_image_size = config["bridge.image_as_file_size"] * 1000**2

        if config["bridge.parallel_file_transfer"] and content.url:
            file_handle, file_size = await parallel_transfer_to_telegram(
                client, self.main_intent, content.url, sender_id)
        else:
            if content.file:
                if not decrypt_attachment:
                    self.log.warning(
                        f"Can't bridge encrypted media event {event_id}:"
                        " matrix-nio not installed")
                    return
                file = await self.main_intent.download_media(content.file.url)
                file = decrypt_attachment(file, content.file.key.key,
                                          content.file.hashes.get("sha256"),
                                          content.file.iv)
            else:
                file = await self.main_intent.download_media(content.url)

            if content.msgtype == MessageType.STICKER:
                if mime != "image/gif":
                    mime, file, w, h = util.convert_image(file,
                                                          source_mime=mime,
                                                          target_type="webp")
                else:
                    # Remove sticker description
                    file_name = "sticker.gif"

            file_handle = await client.upload_file(file)
            file_size = len(file)

        file_handle.name = file_name

        attributes = [DocumentAttributeFilename(file_name=file_name)]
        if w and h:
            attributes.append(DocumentAttributeImageSize(w, h))

        if (mime == "image/png"
                or mime == "image/jpeg") and file_size < max_image_size:
            media = InputMediaUploadedPhoto(file_handle)
        else:
            media = InputMediaUploadedDocument(file=file_handle,
                                               attributes=attributes,
                                               mime_type=mime
                                               or "application/octet-stream")

        caption, entities = self._matrix_event_to_entities(
            caption) if caption else (None, None)

        async with self.send_lock(sender_id):
            if await self._matrix_document_edit(client, content, space,
                                                caption, media, event_id):
                return
            try:
                response = await client.send_media(self.peer,
                                                   media,
                                                   reply_to=reply_to,
                                                   caption=caption,
                                                   entities=entities)
            except (PhotoInvalidDimensionsError, PhotoSaveFileInvalidError,
                    PhotoExtInvalidError):
                media = InputMediaUploadedDocument(file=media.file,
                                                   mime_type=mime,
                                                   attributes=attributes)
                response = await client.send_media(self.peer,
                                                   media,
                                                   reply_to=reply_to,
                                                   caption=caption,
                                                   entities=entities)
            self._add_telegram_message_to_db(event_id, space, 0, response)
        await self._send_delivery_receipt(event_id)
Ejemplo n.º 10
0
async def _(event):
    if event.fwd_from:
        return
    if not event.is_reply:
        await event.edit("Reply to a photo to add to my personal sticker pack."
                         )
        return
    reply_message = await event.get_reply_message()
    sticker_emoji = "🔥"
    input_str = event.pattern_match.group(1)
    if input_str:
        sticker_emoji = input_str
    if not is_message_image(reply_message):
        await event.edit("Invalid message type")
        return
    me = borg.me
    userid = event.from_id
    packname = f"{userid}'s @pornBorg Pack"
    packshortname = f"Uni_Borg_{userid}"  # format: Uni_Borg_userid

    await event.edit("Stealing this ani sticker. Please Wait!")

    async with borg.conversation("@Stickers") as bot_conv:
        now = datetime.datetime.now()
        dt = now + datetime.timedelta(minutes=1)
        file = await borg.download_file(reply_message.media.documents.attribute
                                        )
        with BytesIO(file) as mem_file, BytesIO() as sticker:
            resize_image(mem_file, sticker)
            sticker.seek(0)
            uploaded_sticker = await borg.upload_file(
                sticker, file_name="@UniBorg_Sticker.tgs")
            if not await stickerset_exists(bot_conv, packshortname):
                await silently_send_message(bot_conv, "/cancel")
                response = await silently_send_message(bot_conv,
                                                       "/newanimated")
                if response.text != "Yay! A new pack of animated stickers. If you're new to animated stickers, please see these guidelines before you proceed.\n\nWhen ready to upload, tell me the name of your pack.":
                    await event.edit(
                        f"**FAILED**! @Stickers replied: {response.text}")
                    return
                response = await silently_send_message(bot_conv, packname)
                if not response.text.startswith("Alright!"):
                    await event.edit(
                        f"**FAILED**! @Stickers replied: {response.text}")
                    return
                await bot_conv.send_file(InputMediaUploadedDocument(
                    file=uploaded_sticker,
                    mime_type='image/png',
                    attributes=[
                        DocumentAttributeFilename("@UniBorg_Sticker.tgs")
                    ]),
                                         force_document=True)
                await bot_conv.get_response()
                await silently_send_message(bot_conv, sticker_emoji)
                await silently_send_message(bot_conv, "/publish")
                await silently_send_message(bot_conv, "/skip")
                response = await silently_send_message(bot_conv, packshortname)
                if response.text == "Sorry, this short name is already taken.":
                    await event.edit(
                        f"**FAILED**! @Stickers replied: {response.text}")
                    return
            else:
                await silently_send_message(bot_conv, "/cancel")
                await silently_send_message(bot_conv, "/addsticker")
                await silently_send_message(bot_conv, packshortname)
                await bot_conv.send_file(InputMediaUploadedDocument(
                    file=uploaded_sticker,
                    mime_type='image/png',
                    attributes=[
                        DocumentAttributeFilename("@UniBorg_Sticker.tgs")
                    ]),
                                         force_document=True)
                response = await bot_conv.get_response()
                await silently_send_message(bot_conv, response)
                await silently_send_message(bot_conv, sticker_emoji)
                await silently_send_message(bot_conv, "/done")

    await event.edit(
        f"▕╮╭┻┻╮╭┻┻╮╭▕╮╲\n▕╯┃╭╮┃┃╭╮┃╰▕╯╭▏\n▕╭┻┻┻┛┗┻┻┛   ▕  ╰▏\n▕╰━━━┓┈┈┈╭╮▕╭╮▏\n▕╭╮╰┳┳┳┳╯╰╯▕╰╯▏\n▕╰╯┈┗┛┗┛┈╭╮▕╮┈▏\n\n[sticker looted!\n\n This Sticker is now stored to your database...](t.me/addstickers/{packshortname})"
    )
Ejemplo n.º 11
0
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    reply_message = await event.get_reply_message()
    if reply_message is None:
        await event.edit("reply to a media to use the `nfc` operation.\nInspired by @FileConverterBot")
        return
    await event.edit("trying to download media file, to my local")
    try:
        start = datetime.now()
        c_time = time.time()
        downloaded_file_name = await borg.download_media(
            reply_message,
            Config.TMP_DOWNLOAD_DIRECTORY,
            progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
                slitu.progress(d, t, event, c_time, "trying to download")
            )
        )
    except Exception as e:  # pylint:disable=C0103,W0703
        await event.edit(str(e))
    else:
        end = datetime.now()
        ms = (end - start).seconds
        await event.edit("Downloaded to `{}` in {} seconds.".format(downloaded_file_name, ms))
        new_required_file_name = ""
        new_required_file_caption = ""
        command_to_run = []
        voice_note = False
        supports_streaming = False
        if input_str == "voice":
            new_required_file_caption = "NLFC_" + str(round(time.time())) + ".opus"
            new_required_file_name = Config.TMP_DOWNLOAD_DIRECTORY + "/" + new_required_file_caption
            command_to_run = [
                "ffmpeg",
                "-i",
                downloaded_file_name,
                "-map",
                "0:a",
                "-codec:a",
                "libopus",
                "-b:a",
                "100k",
                "-vbr",
                "on",
                new_required_file_name
            ]
            voice_note = True
            supports_streaming = True
        elif input_str == "mp3":
            new_required_file_caption = "NLFC_" + str(round(time.time())) + ".mp3"
            new_required_file_name = Config.TMP_DOWNLOAD_DIRECTORY + "/" + new_required_file_caption
            command_to_run = [
                "ffmpeg",
                "-i",
                downloaded_file_name,
                "-vn",
                new_required_file_name
            ]
            voice_note = False
            supports_streaming = True
        else:
            await event.edit("not supported")
            os.remove(downloaded_file_name)
            return
        logger.info(command_to_run)
        t_response, e_response = await slitu.run_command(command_to_run)
        os.remove(downloaded_file_name)
        if os.path.exists(new_required_file_name):
            end_two = datetime.now()
            force_document = False
            file_handle = await event.client.upload_file(
                new_required_file_name,
                progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
                    slitu.progress(d, t, event, c_time, "trying to upload")
                )
            )
            attributes, mime_type = get_attributes(
                new_required_file_name,
                mime_type=None,
                attributes=[],
                force_document=force_document,
                voice_note=voice_note,
                video_note=False,
                supports_streaming=supports_streaming,
                thumb=None
            )
            os.remove(new_required_file_name)
            attributes = [DocumentAttributeAudio(
                duration=attributes[-1].duration,
                voice=voice_note,
                title=Config.NFC_TITLE,
                performer=Config.NFC_PERFORMER,
                waveform=attributes[-1].waveform
            )]
            media = InputMediaUploadedDocument(
                file=file_handle,
                mime_type=mime_type,
                attributes=attributes,
                thumb=None,
                force_file=force_document
            )
            await event.reply(
                file=media
            )
            ms_two = (end_two - end).seconds
            await event.edit(f"converted in {ms_two} seconds")
Ejemplo n.º 12
0
async def kang(event):
    """
    <b>param:</b> <code>emoji</code>
    <b>return:</b> <i>Sticker Pack link including the kanged sticker</i>
    """
    if not event.is_reply:
        await event.edit("There's no image given for me to kang!")
        return
    rep_msg = await event.get_reply_message()
    file = rep_msg.photo or rep_msg.document

    if has_image(file):
        st_emoji = event.args.emoji or "🤔"
        if st_emoji not in (list(emoji.EMOJI_UNICODE.values())):
            await event.edit("Not a valid emoji!")
            return

        user = await event.get_sender()
        packname = user.username or user.first_name + "'s sticker pack!"
        packshort = "tg_companion_" + str(user.id)
        await event.edit("Processing sticker! Please wait...")
        async with event.client.conversation('Stickers') as conv:
            until_time = (datetime.datetime.now() +
                          datetime.timedelta(minutes=1)).timestamp()
            await event.client(
                UpdateNotifySettingsRequest(peer="Stickers",
                                            settings=InputPeerNotifySettings(
                                                show_previews=False,
                                                mute_until=until_time)))

            try:
                await conv.send_message("/cancel")
            except YouBlockedUserError:
                await event.reply(
                    "You blocked the sticker bot. Please unblock it and try again"
                )
                return

            file = await event.client.download_file(file)
            with BytesIO(file) as mem_file, BytesIO() as sticker:
                resize_image(mem_file, (512, 512), sticker)
                sticker.seek(0)
                uploaded_sticker = await event.client.upload_file(
                    sticker, file_name="sticker.png")

            try:
                await event.client(
                    GetStickerSetRequest(InputStickerSetShortName(packname)))
                new_pack = False
            except StickersetInvalidError:
                new_pack = True

            if new_pack is False:
                await conv.send_message("/newpack")
                response = await conv.get_response()
                if not response.text.startswith("Yay!"):
                    await event.edit(response.text)
                    return

                await conv.send_message(packname)
                response = await conv.get_response()
                if not response.text.startswith("Alright!"):
                    await event.edit(response.text)
                    return

                await conv.send_file(InputMediaUploadedDocument(
                    file=uploaded_sticker,
                    mime_type='image/png',
                    attributes=[DocumentAttributeFilename("sticker.png")]),
                                     force_document=True)
                await conv.send_message(st_emoji)
                await conv.send_message("/publish")
                await conv.send_message("/skip")
                await conv.send_message(packshort)
                response = conv.get_response()
            else:
                await conv.send_message("/addsticker")
                await conv.send_message(packshort)
                await conv.send_file(InputMediaUploadedDocument(
                    file=uploaded_sticker,
                    mime_type='image/png',
                    attributes=[DocumentAttributeFilename("sticker.png")]),
                                     force_document=True)
                await conv.send_message(st_emoji)
                await conv.send_message("/done")
        await event.edit(
            "Sticker added! Your pack can be found [here](https://t.me/addstickers/{})"
            .format(packshort))
    else:
        await event.edit("Not a valid media entity!")