From b46314af69e83cde4b5053714326f5d53da5460b Mon Sep 17 00:00:00 2001 From: David Schultz Date: Fri, 4 Jun 2021 11:38:49 -0500 Subject: [PATCH 1/4] bump feedparser to 6.0.2 --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 78e0b958..9d13bb9e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ beautifulsoup4 ==4.8.0 cryptography >=3.3.2 dataclasses ==0.6;python_version<'3.7' -dnspython ==1.16.0 -feedparser ==5.2.1 +dnspython ==2.0.0 +feedparser ==6.0.2 html5lib ==1.0.1 isodate ==0.6.0 lxml ==4.6.3 From 4a6037c77405f3584efadc10ae75826b6b9ac422 Mon Sep 17 00:00:00 2001 From: David Schultz Date: Thu, 22 Jul 2021 13:15:53 -0500 Subject: [PATCH 2/4] ignore.py: fix permissions --- src/core_modules/ignore.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core_modules/ignore.py b/src/core_modules/ignore.py index 4592ef6e..dd51a655 100644 --- a/src/core_modules/ignore.py +++ b/src/core_modules/ignore.py @@ -125,7 +125,7 @@ class Module(ModuleManager.BaseModule): @utils.hook("received.command.serverignore") @utils.kwarg("help", "Ignore a command on the current server") - @utils.kwarg("permissions", "serverignore") + @utils.kwarg("permission", "serverignore") @utils.spec("!wordlower") def server_ignore(self, event): command = event["spec"][0] @@ -141,7 +141,7 @@ class Module(ModuleManager.BaseModule): @utils.hook("received.command.serverunignore") @utils.kwarg("help", "Unignore a command on the current server") - @utils.kwarg("permissions", "serverunignore") + @utils.kwarg("permission", "serverunignore") @utils.spec("!wordlower") def server_unignore(self, event): command = event["spec"][0] @@ -154,4 +154,3 @@ class Module(ModuleManager.BaseModule): event["server"].del_setting(setting) event["stdout"].write("No longer ignoring '%s' for %s" % (command, str(event["server"]))) - From 904cb2d94cb7c7a7ebc5769b05cecbdbef32f6c7 Mon Sep 17 00:00:00 2001 From: David Schultz Date: Wed, 19 Jan 2022 21:32:50 -0600 Subject: [PATCH 3/4] git_webhooks/github.py: remove git url shortening --- modules/git_webhooks/github.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/git_webhooks/github.py b/modules/git_webhooks/github.py index 8bf61114..8ead7b9c 100644 --- a/modules/git_webhooks/github.py +++ b/modules/git_webhooks/github.py @@ -172,15 +172,10 @@ class GitHub(object): return list(zip(out, [None]*len(out))) def _short_url(self, url): - self.log.debug("git.io shortening: %s" % url) - try: - page = utils.http.request("https://git.io", method="POST", - post_data={"url": url}) - return page.headers["Location"] - except utils.http.HTTPTimeoutException: - self.log.warn( - "HTTPTimeoutException while waiting for github short URL", []) - return url + # TODO: find an alternative to git.io + # see https://github.com/jesopo/bitbot/issues/338 + # ~ examknow 1/19/2022 + return url def _iso8601(self, s): return utils.datetime.parse.iso8601(s) From 046aa1b2cf901c440aa37dcef874583d8bfa3452 Mon Sep 17 00:00:00 2001 From: David Schultz Date: Wed, 19 Jan 2022 21:33:45 -0600 Subject: [PATCH 4/4] github.py: remove git url shortening --- modules/git_webhooks/github.py | 79 +++++++++++++++------------------- modules/github.py | 12 ++---- 2 files changed, 39 insertions(+), 52 deletions(-) diff --git a/modules/git_webhooks/github.py b/modules/git_webhooks/github.py index 8ead7b9c..035e0809 100644 --- a/modules/git_webhooks/github.py +++ b/modules/git_webhooks/github.py @@ -5,6 +5,7 @@ COMMIT_URL = "https://github.com/%s/commit/%s" COMMIT_RANGE_URL = "https://github.com/%s/compare/%s...%s" CREATE_URL = "https://github.com/%s/tree/%s" +PR_URL = "https://github.com/%s/pull/%s" PR_COMMIT_RANGE_URL = "https://github.com/%s/pull/%s/files/%s..%s" PR_COMMIT_URL = "https://github.com/%s/pull/%s/commits/%s" @@ -77,19 +78,19 @@ COMMENT_ACTIONS = { } COMMENT_MAX = 100 -CHECK_RUN_CONCLUSION = { - "success": "passed", - "failure": "failed", - "neutral": "finished", - "cancelled": "was cancelled", - "timed_out": "timed out", - "action_required": "requires action" +CHECK_SUITE_CONCLUSION = { + "success": ("passed", colors.COLOR_POSITIVE), + "failure": ("failed", colors.COLOR_NEGATIVE), + "neutral": ("finished", colors.COLOR_NEUTRAL), + "cancelled": ("was cancelled", colors.COLOR_NEGATIVE), + "timed_out": ("timed out", colors.COLOR_NEGATIVE), + "action_required": ("requires action", colors.COLOR_NEUTRAL) } -CHECK_RUN_FAILURES = ["failure", "cancelled", "timed_out", "action_required"] class GitHub(object): - def __init__(self, log): + def __init__(self, log, exports): self.log = log + self.exports = exports def is_private(self, data, headers): if "repository" in data: @@ -125,6 +126,8 @@ class GitHub(object): category_action = None if "review" in data and "state" in data["review"]: category = "%s+%s" % (event, data["review"]["state"]) + elif "check_suite" in data and "conclusion" in data["check_suite"]: + category = "%s+%s" % (event, data["check_suite"]["conclusion"]) if action: if category: @@ -159,8 +162,8 @@ class GitHub(object): out = self.delete(full_name, data) elif event == "release": out = self.release(full_name, data) - elif event == "check_run": - out = self.check_run(data) + elif event == "check_suite": + out = self.check_suite(full_name, data) elif event == "fork": out = self.fork(full_name, data) elif event == "ping": @@ -267,7 +270,7 @@ class GitHub(object): colored_branch = utils.irc.color(branch, colors.COLOR_BRANCH) sender = utils.irc.bold(data["sender"]["login"]) - author = utils.irc.bold(data["sender"]["login"]) + author = utils.irc.bold(data["pull_request"]["user"]["login"]) number = utils.irc.color("#%s" % data["pull_request"]["number"], colors.COLOR_ID) identifier = "%s by %s" % (number, author) @@ -428,44 +431,32 @@ class GitHub(object): url = self._short_url(data["release"]["html_url"]) return ["%s %s a release%s - %s" % (author, action, name, url)] - def check_run(self, data): - name = data["check_run"]["name"] - commit = self._short_hash(data["check_run"]["head_sha"]) + def check_suite(self, full_name, data): + suite = data["check_suite"] + + commit = self._short_hash(suite["head_sha"]) commit = utils.irc.color(commit, utils.consts.LIGHTBLUE) + pr = "" url = "" - if data["check_run"]["details_url"]: - url = data["check_run"]["details_url"] - url = " - %s" % self.exports.get("shorturl-any")(url) + if suite["pull_requests"]: + pr_num = suite["pull_requests"][0]["number"] + pr = "/PR%s" % utils.irc.color("#%s" % pr_num, colors.COLOR_ID) + url = self._short_url(PR_URL % (full_name, pr_num)) + url = " - %s" % url - duration = "" - if data["check_run"]["completed_at"]: - started_at = self._iso8601(data["check_run"]["started_at"]) - completed_at = self._iso8601(data["check_run"]["completed_at"]) - if completed_at > started_at: - seconds = (completed_at-started_at).total_seconds() - duration = " in %s" % utils.datetime.format.to_pretty_time( - seconds) + name = suite["app"]["name"] + conclusion = suite["conclusion"] + conclusion, conclusion_color = CHECK_SUITE_CONCLUSION[conclusion] + conclusion = utils.irc.color(conclusion, conclusion_color) - status = data["check_run"]["status"] - status_str = "" - if status == "queued": - status_str = utils.irc.bold("queued") - elif status == "in_progress": - status_str = utils.irc.bold("started") - elif status == "completed": - conclusion = data["check_run"]["conclusion"] - conclusion_color = colors.COLOR_POSITIVE - if conclusion in CHECK_RUN_FAILURES: - conclusion_color = colors.COLOR_NEGATIVE - if conclusion == "neutral": - conclusion_color = colors.COLOR_NEUTRAL + created_at = self._iso8601(suite["created_at"]) + updated_at = self._iso8601(suite["updated_at"]) + seconds = (updated_at-created_at).total_seconds() + duration = utils.datetime.format.to_pretty_time(seconds) - status_str = utils.irc.color( - CHECK_RUN_CONCLUSION[conclusion], conclusion_color) - - return ["[build @%s] %s: %s%s%s" % ( - commit, name, status_str, duration, url)] + return ["[build @%s%s] %s: %s in %s%s" % ( + commit, pr, name, conclusion, duration, url)] def fork(self, full_name, data): forker = utils.irc.bold(data["sender"]["login"]) diff --git a/modules/github.py b/modules/github.py index b528ad2b..9393cd49 100644 --- a/modules/github.py +++ b/modules/github.py @@ -47,14 +47,10 @@ class Module(ModuleManager.BaseModule): return org, repo, number def _short_url(self, url): - try: - page = utils.http.request("https://git.io", method="POST", - post_data={"url": url}) - return page.headers["Location"] - except utils.http.HTTPTimeoutException: - self.log.warn( - "HTTPTimeoutException while waiting for github short URL", []) - return url + # TODO: find an alternative to git.io + # see https://github.com/jesopo/bitbot/issues/338 + # ~ examknow 1/19/2022 + return url def _change_count(self, n, symbol, color): return utils.irc.color("%s%d" % (symbol, n), color)+utils.irc.bold("")