예제 #1
0
파일: cog.py 프로젝트: avimetry/avimetry
 async def blacklist(self, ctx: Context):
     """
     Show blacklisted users on the bot.
     """
     blacklist_ids = list(ctx.cache.blacklist.keys())
     source = BlacklistedPageSource(ctx, blacklist_ids)
     pages = Paginator(source, ctx=ctx, delete_message_after=True)
     await pages.start()
예제 #2
0
def api_get_users():
    page = ctx.request.query_string.get('page')
    count = ctx.request.query_string.get('count')
    if page:
        users = session.query(User).all()
        p = Paginator(page=int(page), object_=users, count=int(count or 10))
        return dict(users=translate_time([user.as_dict() for user in  p.object_list]),
                    pagenums=p.pagenums)
    return dict()
예제 #3
0
 async def python(self, ctx: Context, query):
     """
     Get the docs for the latest Python version
     """
     q = await self.scraper.search(query, page="https://docs.python.org/3/")
     menu = Paginator(RTFMPageSource(ctx, q[:79], "Python"),
                      ctx=ctx,
                      remove_view_after=True)
     await menu.start()
예제 #4
0
파일: cog.py 프로젝트: avimetry/avimetry
 async def allcommands(self, ctx: Context):
     """
     A list of all commands.
     """
     menu = Paginator(
         AllCommandsPageSource(list(self.bot.commands), ctx),
         ctx=ctx,
         remove_view_after=True,
     )
     await menu.start()
예제 #5
0
 async def wavelink(self, ctx: Context, query):
     """
     Get the docs for the Wavelink library
     """
     q = await self.scraper.search(
         query, page="https://wavelink.readthedocs.io/en/latest/")
     menu = Paginator(RTFMPageSource(ctx, q[:79], "Wavelink"),
                      ctx=ctx,
                      remove_view_after=True)
     await menu.start()
예제 #6
0
 async def obsidian(self, ctx: Context, query):
     """
     Get the docs for the Obsidian.py library
     """
     q = await self.scraper.search(
         query, page="https://obsidianpy.readthedocs.io/en/latest/")
     menu = Paginator(RTFMPageSource(ctx, q[:79], "Obsidian"),
                      ctx=ctx,
                      remove_view_after=True)
     await menu.start()
예제 #7
0
 async def rtfm(self, ctx: Context, query):
     """
     Get the docs for the discord.py library.
     """
     q = await self.scraper.search(
         query, page="https://discordpy.readthedocs.io/en/stable/")
     menu = Paginator(RTFMPageSource(ctx, q[:79], "Discord.py"),
                      ctx=ctx,
                      remove_view_after=True)
     await menu.start()
예제 #8
0
파일: views.py 프로젝트: dishults/camagru
 def get(self, request, form=None):
     number = int(request.GET.get('page', 1))
     if not hasattr(self, 'paginated'):
         queryset = self.model.objects.all()
         self.paginated = Paginator(queryset, self.paginate_by)
     context = {
         'form': form or self.form_class(),
         'page_obj': self.paginated.page(number),
     }
     return render(request, self.template_name, context)
예제 #9
0
 async def custom(self, ctx: Context, doc_url, query):
     """
     Search any Sphinx docs.
     """
     try:
         q = await self.scraper.search(query, page=doc_url)
     except Exception as e:
         return await ctx.send(e)
     menu = Paginator(RTFMPageSource(ctx, q[:79], "Custom Docs"),
                      ctx=ctx,
                      remove_view_after=True)
     await menu.start()
예제 #10
0
    async def gist_read(self, ctx, *, gist_id: str):
        try:
            gist = await self.bot.gist.fetch_gist(gist_id)
        except asyncgist.NotFound:
            return await ctx.send("Gist was not found.")
        from core.context import AutoPageSource

        pag = commands.Paginator()
        for i in gist.files[0].content.split("\n"):
            pag.add_line(i.replace("`", "\u200b`"))
        source = AutoPageSource(pag)
        pages = Paginator(source, ctx=ctx, delete_message_after=True)
        await pages.start()
예제 #11
0
파일: cog.py 프로젝트: avimetry/avimetry
 async def fixed(self, ctx: Context):
     """
     Shows all fixed errors.
     """
     errors = await self.bot.pool.fetch("SELECT * FROM command_errors WHERE fixed = True")
     if not errors:
         embed = discord.Embed(title="Errors", description="No fixed errors have been found.")
         return await ctx.send(embed=embed)
     menu = Paginator(
         ErrorSource(ctx, errors, title="Fixed errors", per_page=4),
         ctx=ctx,
         delete_message_after=True,
     )
     return await menu.start()
예제 #12
0
    async def show_entries(self, ctx, params):
        entries = await self.get_entries(ctx, 'search', params)

        search_type = params['type']
        if not entries:
            return await ctx.send(f'No {search_type}s found.')

        base = globals().get(f'{search_type.upper()}_BASE')
        links = [base + entry['id'][f'{search_type}Id'] for entry in entries]

        try:
            paginator = Paginator(ctx, entries=links)
            await paginator.paginate()
        except Exception as e:
            await ctx.send(e)
예제 #13
0
def search():
    query = request.args.get("q")
    if query is None:
        return render_template("index.html")

    try:
        page = int(request.args.get("p", 1))
    except (TypeError, ValueError):
        page = 1

    searcher = Searcher()
    results = searcher.search_page(query, page)
    paginator = Paginator(results)
    return render_template("index.html",
                           results=results,
                           paginator=paginator,
                           q=query)
예제 #14
0
def getblog():
    page = ctx.request.query_string.get('page')    # 此处修改了框架的query_string:返回{'a'='1','b'='balbal'}
    count = ctx.request.query_string.get('count')
    cat = ctx.request.query_string.get('cat')
    if page:
        if cat == 'all' or cat is None:
            blogs = session.query(Blog).order_by(Blog.created_at.desc()).all()
        else:
            blogs = session.query(Blog).filter(Blog.category == cat).order_by(Blog.created_at.desc()).all()
        p = Paginator(int(page), blogs, count=int(count or 6))
        categories = session.query(Category).all()
        catobject = session.query(Category).filter(Category.id == cat).first()
        return dict(blogs=translate_time([blog.as_dict() for blog in p.object_list]),
                    hasnext=p.hasnext,
                    hasprevious=p.hasprevious,
                    pagenums=p.pagenums,
                    currentcat=catobject.id if catobject else None,
                    categories=[cat.as_dict() for cat in categories])
    return dict()
예제 #15
0
파일: cog.py 프로젝트: avimetry/avimetry
    async def queue(self, ctx: Context):
        """Display the players queued songs."""
        player: Player = ctx.voice_client

        if not player:
            return

        if player.queue.size == 0:
            return await ctx.send(
                f"The queue is empty. Use {ctx.prefix}play to add some songs!")

        entries = []
        for index, track in enumerate(player.queue._queue):
            if isinstance(track, wavelink.PartialTrack):
                entries.append(f"`{index + 1})` {track.title}")
            else:
                entries.append(f"`{index + 1})` [{track.title}]({track.url})")

        pages = PaginatorSource(entries=entries, ctx=ctx)
        paginator = Paginator(source=pages,
                              timeout=120,
                              ctx=ctx,
                              disable_view_after=True)
        await paginator.start()
예제 #16
0
파일: cog.py 프로젝트: avimetry/avimetry
 async def guilds(self, ctx: Context):
     source = GuildPageSource(ctx, guilds=self.bot.guilds)
     pages = Paginator(source, ctx=ctx, disable_view_after=True)
     await pages.start()