示例#1
0
    async def _github_pulls(self, ctx: commands.Context):
        """
        show pull requests
        """

        url = "{0}/pulls/".format(ctx.bot._settings.github)
        await ctx.send(format.wrap_url(url))
示例#2
0
    async def _github_issue_list(self, ctx: commands.Context):
        """
        list open issues
        """

        # https://developer.github.com/v3/issues/#list-issues-for-a-repository
        url = "repos/ShineyDev/sbt/issues"

        async with ctx.typing():
            try:
                issues = await self.request("GET", url)
            except (GitHubError) as e:
                await ctx.send("`{0}: {1}`".format(type(e).__name__, str(e)))
                return

        message = ""

        for (issue) in issues:
            if (issue.get("pull_request")):
                # not an issue, i will never understand why prs show as
                # issues ¯\_(ツ)_/¯
                continue
            elif (issue.get("state") == "closed"):
                continue

            url = format.wrap_url(issue.get("html_url"))
            message += "{0}\n".format(url)

        if (not message):
            await ctx.send("there are no open issues")
            return

        for (page) in format.pagify(message):
            if (page):
                await ctx.send(page)
示例#3
0
    async def _github(self, ctx: commands.Context):
        """
        display github link
        """

        url = "{0}/".format(ctx.bot._settings.github)
        await ctx.send(format.wrap_url(url))
示例#4
0
 async def on_message(self, message: discord.Message):
     if ((message.guild)
             and (message.guild.id == self.bot._settings.debugging_guild)):
         match = regex.Regex.ISSUE.search(message.content)
         if (match):
             url = "{0}/issues/{1}/".format(self.bot._settings.github,
                                            match.group("number"))
             await message.channel.send(format.wrap_url(url))
示例#5
0
    async def _github_issue(self, ctx: commands.Context,
                            id: typing.Optional[int]):
        """
        show a github issue
        """

        if (ctx.invoked_with == "issue"):
            if (not id):
                await ctx.bot.send_help(ctx)
                return

            url = "{0}/issues/{1}/".format(ctx.bot._settings.github, id)
            await ctx.send(format.wrap_url(url))
        else:
            if (checks.is_supervisor_check(ctx)):
                if (checks.is_debugging_check(ctx)):
                    # we don't want people to bypass checks ;(
                    await ctx.invoke(self._github_issue_list)
            else:
                url = "{0}/issues/".format(ctx.bot._settings.github)
                await ctx.send(format.wrap_url(url))
示例#6
0
文件: general.py 项目: PgBiel/sbt
    async def _google(self, ctx: commands.Context, *, query: str):
        """
        search google

        using this command in an nsfw-marked channel will disable the safe filter

        example:
            `>google weather in michigan` :: search google for "weather in michigan"
        """

        url = "https://www.google.com/search?q={}".format(
            urllib.parse.quote_plus(query))

        safe = False
        if (ctx.guild):
            if (not ctx.channel.is_nsfw()):
                safe = True

        try:
            search_ = search.Google(ctx.bot._settings.google_api_key,
                                    ctx.bot._settings.google_engine_id)
            results = await search_.search(query, safe=safe)
        except (search.NoResults) as e:
            await ctx.send("no results")
            return
        except (search.NoMoreRequests) as e:
            await ctx.send(format.wrap_url(url))
            return
        except (search.APIError) as e:
            await ctx.send("api error ;(")
            return

        footer = "safe={0} results={1} time={2}".format(
            "on" if safe else "off", results[0].results, results[0].time)

        menu = paginate.Menu(ctx)
        menu.appends(self._google_embedinator(ctx, url, footer, results[:9]))
        await menu.start()