Ejemplo n.º 1
0
    async def show(self, ctx, *args):
        """
        show image
          /show 123 - show #123 image
          /show 123 4567 - show #123 and #4567 images
        """

        bnny_ids = bu.getArgs(args)

        if len(bnny_ids) < 1:
            if ctx.prefix == bu.PREFIX[0]:
                await ctx.reply(bu.SHOW_USAGE)
            return
        else:
            for bnny_id in bnny_ids:
                # if not bnny_id.isdecimal():
                #     if ctx.prefix == bu.PREFIX[0]:
                #         await ctx.reply(
                #             bu.errorNaN(bnny_id) + "\n" + bu.SHOW_USAGE)
                #     return
                if bu.isInvalid(bnny_id):
                    if ctx.prefix == bu.PREFIX[0]:
                        await ctx.reply(
                            bu.errorInvalid(bnny_id) + "\n" + bu.SHOW_USAGE)
                    return

        for bnny_id in bnny_ids:
            embed = discord.Embed(
                title=bu.getTitle(bnny_id)
            )
            embed.set_image(
                url="attachment://bunny_{}.png".format(bnny_id))

            await ctx.reply(embed=embed, file=fetch(bnny_id))
Ejemplo n.º 2
0
    async def url(self, ctx, *args):
        """
        return URL
          /url 123 - return #123 URL
          /url 123 4567 - return #123 and #4567 URL
        """

        bnny_ids = bu.getArgs(args)

        if len(bnny_ids) < 1:
            if ctx.prefix == bu.PREFIX[0]:
                await ctx.reply(bu.URL_USAGE)
            return
        else:
            for bnny_id in bnny_ids:
                # if not bnny_id.isdecimal():
                #     if ctx.prefix == bu.PREFIX[0]:
                #         await ctx.reply(
                #             bu.errorNaN(bnny_id) +
                #             "\n" + bu.URL_USAGE
                #         )
                #     return
                if bu.isInvalid(bnny_id):
                    if ctx.prefix == bu.PREFIX[0]:
                        await ctx.reply(
                            bu.errorInvalid(bnny_id) + "\n" + bu.URL_USAGE)
                    return

        text = ""
        for bnny_id in bnny_ids:
            text += bu.urlMsg(bnny_id)
            text += "\n"

        await ctx.reply(text)
Ejemplo n.º 3
0
def url(update, context):
    bnny_ids = bu.getArgs(context.args)

    prefix = update.message.text[0]

    if len(bnny_ids) < 1:
        if prefix == bu.PREFIX[0]:
            update.message.reply_markdown_v2(bu.URL_USAGE)
        return
    else:
        for bnny_id in bnny_ids:
            # if not bnny_id.isdecimal():
            #     if prefix == bu.PREFIX[0]:
            #         update.message.reply_markdown_v2(
            #             bu.errorNaN(bu.md_escape(bnny_id))
            #             + "\n" + bu.URL_USAGE
            #         )
            #     return
            if bu.isInvalid(bnny_id):
                if prefix == bu.PREFIX[0]:
                    update.message.reply_markdown_v2(
                        bu.errorInvalid(bnny_id) +
                        "\n" + bu.URL_USAGE
                    )
                return

    text = ""
    for bnny_id in bnny_ids:
        text += bu.urlMsg(bnny_id)
        text += "\n"

    update.message.reply_text(text)
Ejemplo n.º 4
0
    async def info(self, ctx, *args):
        """
        show info and image
          /info 123 - show #123 info
          /info 123 4567 - show #123 and #4567 info
        """

        id_list = args

        if len(id_list) < 1:
            if ctx.prefix == bu.PREFIX[0]:
                await ctx.reply(bu.SHOW_USAGE)
            return
        else:
            for bnny_id in id_list:
                if not bnny_id.isdecimal():
                    if ctx.prefix == bu.PREFIX[0]:
                        await ctx.reply(
                            bu.errorNaN(bnny_id) + "\n" + bu.SHOW_USAGE)
                    return
                if bu.isInvalid(int(bnny_id)):
                    if ctx.prefix == bu.PREFIX[0]:
                        await ctx.reply(
                            bu.errorInvalid(bnny_id) + "\n" + bu.SHOW_USAGE)
                    return

        for bnny_id in id_list:
            embed = discord.Embed(title=bu.getTitle(bnny_id),
                                  description=bu.getInfoContent(bnny_id))
            embed.set_image(url="attachment://bunny_{}.png".format(bnny_id))

            await ctx.reply(embed=embed, file=fetch(bnny_id))
Ejemplo n.º 5
0
    async def url(self, ctx, *args):
        """
        return URL
          /url 123 - return #123 URL
          /url 123 4567 - return #123 and #4567 URL
        """

        id_list = args

        if len(id_list) < 1:
            if ctx.prefix == bu.PREFIX[0]:
                await ctx.reply(bu.URL_USAGE)
            return
        else:
            for bnny_id in id_list:
                if not bnny_id.isdecimal():
                    if ctx.prefix == bu.PREFIX[0]:
                        await ctx.reply(
                            bu.errorNaN(bnny_id) + "\n" + bu.URL_USAGE)
                    return
                if bu.isInvalid(int(bnny_id)):
                    if ctx.prefix == bu.PREFIX[0]:
                        await ctx.reply(
                            bu.errorInvalid(bnny_id) + "\n" + bu.URL_USAGE)
                    return

        text = ""
        for bnny_id in id_list:
            text += bu.urlMsg(bnny_id)
            text += "\n"

        await ctx.reply(text)
Ejemplo n.º 6
0
def info(update, context):
    bnny_ids = bu.getArgs(context.args)

    prefix = update.message.text[0]
    isGroup = len(bnny_ids) > 1

    if len(bnny_ids) < 1:
        if prefix == bu.PREFIX[0]:
            update.message.reply_markdown_v2(bu.INFO_USAGE)
        return
    else:
        for bnny_id in bnny_ids:
            # if not bnny_id.isdecimal():
            #     if prefix == bu.PREFIX[0]:
            #         update.message.reply_markdown_v2(
            #             bu.errorNaN(bu.md_escape(bnny_id))
            #             + "\n" + bu.INFO_USAGE)
            #     return
            if bu.isInvalid(bnny_id):
                if prefix == bu.PREFIX[0]:
                    update.message.reply_markdown_v2(
                        bu.errorInvalid(bnny_id)
                        + "\n" + bu.INFO_USAGE)
                return

    media_group_wrapper = [list()]

    for bnny_id in bnny_ids:
        media = InputMediaPhoto(
            media=fetch(bnny_id),
            caption=bu.getTitle(bnny_id, "*") + "\n" +
            bu.getInfoContent(bnny_id, "*", 2, isGroup=isGroup),
            parse_mode="MarkdownV2"
        )

        if len(media_group_wrapper[-1]) >= 10:
            media_group_wrapper.append(list())
        media_group_wrapper[-1].append(media)
        # update.message.reply_photo(
        #     photo=fetch(bnny_id),
        #     caption=bu.getTitle(bnny_id, "*")+"\n" +
        #     bu.getInfoContent(bnny_id, "*", 2),
        #     parse_mode="MarkdownV2")

    for media_group in media_group_wrapper:
        update.message.reply_media_group(media_group)