コード例 #1
0
    async def _search(self, ctx: commands.Context, tags: str, sort):
        res = Utils.search_by_query(tags, sort=sort)
        if res != []:
            msg = "Choose from `1-5`;\n"
            for i, dj in enumerate(res):
                if i < 5:
                    msg += f"{i+1}: {dj.title(Format.English)}\n"
            mes: discord.Message = await ctx.send(content=msg)
        else:
            await ctx.send('No results found!')
            return

        def check(inp: discord.Message):
            return inp.author == ctx.author

        try:
            msg: discord.Message = await self.bot.wait_for('message',
                                                           check=check,
                                                           timeout=30.0)
            djid = res[int(msg.content) - 1].id
            await self.nhentai(ctx, djid)
        except (ValueError, IndexError):
            await mes.delete()
            await ctx.send("Invalid input")
        except asyncio.TimeoutError:
            await mes.delete()
コード例 #2
0
ファイル: nsfw.py プロジェクト: maoouu/Mashiro.py
    async def getsauce(self, ctx, flag, *query):
        """ Fetches the first 25 nuke codes that match this query 

            [Sorting Flags]
            -a = Popular all-time 
            -y = Popular this year
            -w = Popular this week (default)
            -m = Popular this month
            -t = Popular today
            -r = Most Recent
        """
        category = {
            "-a": [Sort.Popular, "popular all-time"],
            "-y": [Sort.PopularYear, "popular this year"],
            "-w": [Sort.PopularWeek, "popular this week"],
            "-m": [Sort.PopularMonth, "popular this month"],
            "-t": [Sort.PopularToday, "popular today"],
            "-r": [Sort.Date, "most recent"]
        }
        default = [Sort.PopularWeek, "popular this week"]
        new_query = flag  # in case flag is a query
        flag = flag if flag in category else None
        try:
            sort_by = category.get(flag, default)
            if flag == None:
                new_query = new_query + " " + " ".join(query)
            else:
                new_query = " ".join(query)
            message = await ctx.send(f'Fetching *"{new_query}"*...')
            nukes = (str(doujin.id) for doujin in Utils.search_by_query(
                new_query, sort=sort_by[0]))
            await message.edit(content=f'Here you go ({sort_by[1]}): `{", ".join(nukes)}`')
        except HTTPError:
            await message.edit(content=f"Couldn't find the sauce you're looking for. 🤷‍♂️")
コード例 #3
0
ファイル: hentai.py プロジェクト: shamahdotdev/robo-hasbi
    async def search(self, ctx, *, query):
        async with ctx.typing():
            doujins = [doujin for doujin in Utils.search_by_query(query, sort=Sort.Popular)]
            shuffle(doujins)
            curr_index = 1
            max_index = len(doujins)
            embed, components = self.helpers.generate_list_hentai_embed(doujins[curr_index-1], curr_index, max_index)

            nhentai = await ctx.send(embed=embed, components=components)
        
        try:
            while True:
                btn = await nhentai.wait_for('button', self.bot, timeout=60)
                await btn.respond(ninja_mode=True)

                if btn.custom_id == 'hentai_first': curr_index = 1
                if btn.custom_id == 'hentai_prev': curr_index -= 1
                if btn.custom_id == 'hentai_next': curr_index += 1
                if btn.custom_id == 'hentai_last': curr_index = max_index

                embed, components = self.helpers.generate_list_hentai_embed(doujins[curr_index-1], curr_index, max_index)
                await nhentai.edit(embed=embed, components=components)
        except TimeoutError:
            _, components = self.helpers.generate_list_hentai_embed(doujins[curr_index-1], curr_index, max_index, disable_components=True)
            await nhentai.edit(components=components)
        except NotFound:
            pass
コード例 #4
0
 async def nh_search(self, ctx, *, query: str):
     """
     search keyword in NHentai
     """
     result = Utils.search_by_query(query)
     embed  = self.process_search_result(result)
     embed.set_footer(text="Search report from Speedwagon Foundation")  
     embed.timestamp = datetime.datetime.utcnow()
     msg = await ctx.send(embed=embed)
コード例 #5
0
    async def search(self, ctx: Context, *, query: str):
        """
        TODO: Make this function work
        :param ctx:
        :param query:
        :return:
        """
        result = Utils.search_by_query(query)
        embed  = self.process_search_result(result)
        msg = await ctx.send(embed=embed)

        def check(msg: discord.Message) -> bool:
            """
            Check if the function is
            :param msg:
            :return:
                        """
            if msg.author != ctx.author: return False
            content = msg.content
            try:
                n = int(content)
                if n < 1 or n > 10: return False

            except Exception:
                return content == 'x' or False
            else:
                return True

        try:
            response = await self.bot.wait_for('message',
                                               check=check,
                                               timeout=30)
        except asyncio.TimeoutError:
            await ctx.send(embed=WarningEmbed("OOPS! timeout"),
                           delete_after=10
            )
        else:
            await msg.delete()
            content = response.content
            if content == 'x':
                await msg.delete()
                await response.delete()
                return
            n = int(content)
            await response.delete()
            await ctx.send(
                embed=self.make_embed(result[n-1])
            )
コード例 #6
0
ファイル: aigis.py プロジェクト: eduardo-neves/aigis.py
async def nhr(message, *tags):
    if not tags:
        random = str(Utils.get_random_id())
        base_url = 'https://nhentai.net/g/'
        final_url = base_url + random + "/"
        await message.channel.send(final_url)
    else:
        print("Entered else statement")
        query_tags = ""
        fTags = ""
        n = 0
        language = "language:english"
        commandHelp = ""
        for tag in tags:
            if (tag == "-help") or (tag == "-h") or (tag
                                                     == "h") or (tag
                                                                 == "help"):
                commandHelp = "Use quaisquer combinação de tags. Ex: *%snhr yuri pantyhose*\nTambém pode usar - para remover uma tag. Ex: *%snhr glasses -netorare*" % (
                    prefix, prefix)
                await message.channel.send(commandHelp)
                break
            #enables multiple language support (to be defined in if statement)
            # if tag == "translated" or tag == "english":
            #     language = "language:" + tag
            # else:
            query_tags += tag + " "
            if query_tags != "":
                fTags = "tag:" + query_tags
        query = fTags + language
        doujins = Utils.search_by_query(query, sort=Sort.PopularToday)
        selected = randint(0, len(doujins))

        for doujin in doujins:
            if (commandHelp != ""):
                break
            if (n == selected):
                base_url = 'https://nhentai.net/g/'
                final_url = base_url + str(doujin.id) + "/"
                print(doujin.title(Format.Pretty))
                print(final_url)
                await message.channel.send(final_url)
            n += 1