예제 #1
0
async def _(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.edit("`Herhangi bir kullanıcı mesajına cevap verin.`")
        return
    reply_message = await event.get_reply_message()
    if not reply_message.text:
        await event.edit("`Mesaja cevap verin.`")
        return
    chat = "@QuotLyBot"
    sender = reply_message.sender
    if reply_message.sender.bot:
        await event.edit("`Botlara cevap veremezsiniz.`")
        return
    await event.edit("`Alıntı yapılıyor...`")

    async with bot.conversation(chat,
                                exclusive=False,
                                replies_are_responses=True) as conv:
        response = None
        try:
            msg = await reply_message.forward_to(chat)
            response = await conv.get_response(message=msg, timeout=5)
        except YouBlockedUserError:
            await event.edit(
                "`Lütfen @QuotLyBot engelini kaldırın ve tekrar deneyin`")
            return
        except Exception as e:
            print(e.__class__)

        if not response:
            await event.edit(
                f"`Botdan cevap alamadım! Bunun sebebi bulunduğun sohbete {chat} ekli olması olabilir.`"
            )
        elif response.text.startswith("Merhaba!"):
            await event.edit("`Gizlilik ayarları yüzenden alıntı yapamadım`")
        else:
            await event.delete()
            await response.forward_to(event.chat_id)
        await conv.mark_read()
        await conv.cancel_all()
예제 #2
0
async def _(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.edit("`Herhangi bir kullanıcı mesajına cevap verin.`")
        return
    reply_message = await event.get_reply_message()
    if not reply_message.text:
        await event.edit("`Mesaja cevap verin.`")
        return
    chat = "@SangMataInfo_bot"
    sender = reply_message.sender
    if reply_message.sender.bot:
        await event.edit("`Botlara cevap veremezsiniz.`")
        return
    await event.edit("`İşleniyor...`")
    async with bot.conversation(chat, exclusive=False) as conv:
        response = None
        try:
            msg = await reply_message.forward_to(chat)
            response = await conv.get_response(message=msg, timeout=5)
        except YouBlockedUserError:
            await event.edit(
                f"`Lütfen {chat} engelini kaldırın ve tekrar deneyin`")
            return
        except Exception as e:
            print(e.__class__)

        if not response:
            await event.edit("`Botdan cevap alamadım!`")
        elif response.text.startswith("Forward"):
            await event.edit("`Gizlilik ayarları yüzünden alıntı yapamadım`")
        else:
            await event.edit(response.text)
        sleep(1)
        await bot.send_read_acknowledge(chat, max_id=(response.id + 3))
        await conv.cancel_all()
예제 #3
0
async def dizla(args):
    """ .dızla komutu çıkartmaları başka paketten alır ya da yeni bir çıkartma oluşturur. """
    user = me
    if not user.username:
        user.username = user.first_name
    message = await args.get_reply_message()
    photo = None
    emojibypass = False
    is_anim = False
    emoji = None

    if message and message.media:
        if isinstance(message.media, MessageMediaPhoto):
            photo = BytesIO()
            photo = await bot.download_media(message.photo, photo)
        elif "image" in message.media.document.mime_type.split('/'):
            photo = BytesIO()
            await bot.download_file(message.media.document, photo)
            if (DocumentAttributeFilename(file_name='sticker.webp')
                    in message.media.document.attributes):
                emoji = message.media.document.attributes[1].alt
                emojibypass = True
        elif "tgsticker" in message.media.document.mime_type:
            await bot.download_file(message.media.document,
                                    'AnimatedSticker.tgs')

            attributes = message.media.document.attributes
            for attribute in attributes:
                if isinstance(attribute, DocumentAttributeSticker):
                    emoji = attribute.alt

            emojibypass = True
            is_anim = True
            photo = 1
        else:
            await args.edit("`Desteklenmeyen dosya!`")
            return
        await args.edit(f"`{choice(DIZCILIK_STR)}`")
    else:
        await args.edit("`Bunu dızlayamam...`")
        return

    if photo:
        splat = args.text.split()
        if not emojibypass:
            emoji = "🤔"
        pack = 1
        if len(splat) == 3:
            pack = splat[2]  # Kullanıcı ikisini de gönderebilir
            emoji = splat[1]
        elif len(splat) == 2:
            if splat[1].isnumeric():
                # Kullanıcı başka pakete eklemek istiyor.
                pack = int(splat[1])
            else:
                # Kullanıcı sadece özel emoji istedi, varsayılan pakete eklemek istiyor.
                emoji = splat[1]

        packname = f"a{user.id}_by_{user.username}_{pack}"
        packnick = f"@{user.username}'s UserBot pack {pack}"
        cmd = '/newpack'
        file = BytesIO()

        if not is_anim:
            image = await resize_photo(photo)
            file.name = "sticker.png"
            image.save(file, "PNG")
        else:
            packname += "_anim"
            packnick += " (Animasyonlu)"
            cmd = '/newanimated'

        response = urlopen(Request(f'http://t.me/addstickers/{packname}'))
        htmlstr = response.read().decode("utf8").split('\n')

        if "  A <strong>Telegram</strong> user has created the <strong>Sticker&nbsp;Set</strong>." not in htmlstr:
            async with bot.conversation('Stickers') as conv:
                await conv.send_message('/addsticker')
                await conv.get_response()
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await bot.send_read_acknowledge(conv.chat_id)
                await conv.send_message(packname)
                x = await conv.get_response()
                while "120" in x.text:
                    pack += 1
                    packname = f"a{user.id}_by_{user.username}_{pack}"
                    packnick = f"@{user.username}'s UserBot pack {pack}"
                    await args.edit("`Yetersiz paket alanından dolayı " +
                                    str(pack) + " numaralı pakete geçiliyor`")
                    await conv.send_message(packname)
                    x = await conv.get_response()
                    if x.text == "Geçersiz paket seçildi.":
                        await conv.send_message(cmd)
                        await conv.get_response()
                        # Kullanıcının sürekli bildirim almamasını sağlar.
                        await bot.send_read_acknowledge(conv.chat_id)
                        await conv.send_message(packnick)
                        await conv.get_response()
                        # Kullanıcının sürekli bildirim almamasını sağlar.
                        await bot.send_read_acknowledge(conv.chat_id)
                        if is_anim:
                            await conv.send_file('AnimatedSticker.tgs')
                            remove('AnimatedSticker.tgs')
                        else:
                            file.seek(0)
                            await conv.send_file(file, force_document=True)
                        await conv.get_response()
                        await conv.send_message(emoji)
                        # Kullanıcının sürekli bildirim almamasını sağlar.
                        await bot.send_read_acknowledge(conv.chat_id)
                        await conv.get_response()
                        await conv.send_message("/publish")
                        if is_anim:
                            await conv.get_response()
                            await conv.send_message(f"<{packnick}>")
                        # Kullanıcının sürekli bildirim almamasını sağlar.
                        await conv.get_response()
                        await bot.send_read_acknowledge(conv.chat_id)
                        await conv.send_message("/skip")
                        # Kullanıcının sürekli bildirim almamasını sağlar.
                        await bot.send_read_acknowledge(conv.chat_id)
                        await conv.get_response()
                        await conv.send_message(packname)
                        # Kullanıcının sürekli bildirim almamasını sağlar.
                        await bot.send_read_acknowledge(conv.chat_id)
                        await conv.get_response()
                        # Kullanıcının sürekli bildirim almamasını sağlar.
                        await bot.send_read_acknowledge(conv.chat_id)
                        await args.edit(f"`Çıkartma başka bir pakete eklendi.\
                            \nBu paket yeni oluşturuldu.\
                            \nYeni paket [burada](t.me/addstickers/{packname}) bulunabilir.",
                                        parse_mode='md')
                        return
                if is_anim:
                    await conv.send_file('AnimatedSticker.tgs')
                    remove('AnimatedSticker.tgs')
                else:
                    file.seek(0)
                    await conv.send_file(file, force_document=True)
                rsp = await conv.get_response()
                if "Sorry, the file type is invalid." in rsp.text:
                    await args.edit(
                        "`Çıkartma ekleme başarısız, ` @Stickers `botu ile elle eklemeyi deneyin.`"
                    )
                    return
                await conv.send_message(emoji)
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await bot.send_read_acknowledge(conv.chat_id)
                await conv.get_response()
                await conv.send_message('/done')
                await conv.get_response()
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await bot.send_read_acknowledge(conv.chat_id)
        else:
            await args.edit("`Yeni paket oluşturuluyor...`")
            async with bot.conversation('Stickers') as conv:
                await conv.send_message(cmd)
                await conv.get_response()
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await bot.send_read_acknowledge(conv.chat_id)
                await conv.send_message(packnick)
                await conv.get_response()
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await bot.send_read_acknowledge(conv.chat_id)
                if is_anim:
                    await conv.send_file('AnimatedSticker.tgs')
                    remove('AnimatedSticker.tgs')
                else:
                    file.seek(0)
                    await conv.send_file(file, force_document=True)
                rsp = await conv.get_response()
                if "Sorry, the file type is invalid." in rsp.text:
                    await args.edit(
                        "`Çıkartma ekleme başarısız, ` @Stickers `botu ile elle eklemeyi deneyin.`"
                    )
                    return
                await conv.send_message(emoji)
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await bot.send_read_acknowledge(conv.chat_id)
                await conv.get_response()
                await conv.send_message("/publish")
                if is_anim:
                    await conv.get_response()
                    await conv.send_message(f"<{packnick}>")
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await conv.get_response()
                await bot.send_read_acknowledge(conv.chat_id)
                await conv.send_message("/skip")
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await bot.send_read_acknowledge(conv.chat_id)
                await conv.get_response()
                await conv.send_message(packname)
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await bot.send_read_acknowledge(conv.chat_id)
                await conv.get_response()
                # Kullanıcının sürekli bildirim almamasını sağlar.
                await bot.send_read_acknowledge(conv.chat_id)

        await args.edit(f"`Çıkartma başarıyla pakete eklendi.`\
            \nPaket [şurada](t.me/addstickers/{packname}) bulunabilir.",
                        parse_mode='md')
예제 #4
0
async def _(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.edit(
            "`Kullanım: Bir fotoğrafa yanıt vererek .mem 'üst kısmın metni' ; 'alt kısmın metni'`"
        )
        return
    reply_message = await event.get_reply_message()
    if not reply_message.media:
        await event.edit("```Bir resme cevap verin.```")
        return
    chat = "@MemeAutobot"
    sender = reply_message.sender
    file_ext_ns_ion = "@sedenmemes.png"
    file = await bot.download_file(reply_message.media)
    uploaded_gif = None
    if reply_message.sender.bot:
        await event.edit("```Botlara cevap veremezsiniz.```")
        return
    else:
        await event.edit("`İşleniyor...`")

    async with bot.conversation("@MemeAutobot") as bot_conv:
        memeVar = extract_args(event)
        try:
            await silently_send_message(bot_conv, "/start")
            await asyncio.sleep(1)
            await silently_send_message(bot_conv, memeVar)
            await bot.send_file(chat, reply_message.media)
            response = await bot_conv.get_response()
        except YouBlockedUserError:
            await event.reply(
                "`Lütfen @MemeAutobot engelini kaldırın ve tekrar deneyin`")
            return
        if response.text.startswith("Forward"):
            await event.edit("`Gizlilik ayarları yüzenden alıntı yapamadım`")
        if "Okay..." in response.text:
            await event.edit(
                "`Bu bir resim değil bu yüzden işlem iptal ediliyor...`")
            thumb = None
            if os.path.exists(thumb_image_path):
                thumb = thumb_image_path
            input_str = memeVar
            if not os.path.isdir(TMP_DOWNLOAD_DIRECTORY):
                os.makedirs(TMP_DOWNLOAD_DIRECTORY)
            if event.reply_to_msg_id:
                file_name = "sedenmemes.png"
                reply_message = await event.get_reply_message()
                to_download_directory = TMP_DOWNLOAD_DIRECTORY
                downloaded_file_name = os.path.join(to_download_directory,
                                                    file_name)
                downloaded_file_name = await bot.download_media(
                    reply_message,
                    downloaded_file_name,
                )
                if os.path.exists(downloaded_file_name):
                    await bot.send_file(
                        chat,
                        downloaded_file_name,
                        force_document=False,
                        supports_streaming=False,
                        allow_cache=False,
                        thumb=thumb,
                    )
                    os.remove(downloaded_file_name)
                else:
                    await event.edit("Dosya bulunamadı {}".format(input_str))
            response = await bot_conv.get_response()
            the_download_directory = TMP_DOWNLOAD_DIRECTORY
            files_name = "sedenmemes.webp"
            download_file_name = os.path.join(the_download_directory,
                                              files_name)
            await bot.download_media(
                response.media,
                download_file_name,
            )
            requires_file_name = (
                TMP_DOWNLOAD_DIRECTORY +
                ('/' if TMP_DOWNLOAD_DIRECTORY[-1:] != '/' else '') +
                files_name)
            await bot.send_file(  # pylint:disable=E0602
                event.chat_id,
                requires_file_name,
                supports_streaming=False,
                caption="SedenBot: @NaytSeyd tarafından güçlendirildi.",
            )
            await event.delete()
            await bot.send_message(event.chat_id, "`İşlem başarılı!`")
        elif not is_message_image(reply_message):
            await event.edit(
                "`Geçersiz mesaj türü. Lütfen doğru mesaj türünü seçin.`")
            return
        else:
            await bot.send_file(event.chat_id, response.media)