diff --git a/.gitignore b/.gitignore index d24d014..ff85c50 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Byte-compiled / optimized / DLL files -__pycache__/ +**/__pycache__/ *.py[cod] *$py.class diff --git a/poetry.lock b/poetry.lock index 871e880..e786965 100644 --- a/poetry.lock +++ b/poetry.lock @@ -171,6 +171,7 @@ lxml = ["lxml"] [[package]] name = "black" version = "23.11.0" +version = "23.11.0" description = "The uncompromising code formatter." optional = false python-versions = ">=3.8" @@ -193,6 +194,24 @@ files = [ {file = "black-23.11.0-cp39-cp39-win_amd64.whl", hash = "sha256:421f3e44aa67138ab1b9bfbc22ee3780b22fa5b291e4db8ab7eee95200726b07"}, {file = "black-23.11.0-py3-none-any.whl", hash = "sha256:54caaa703227c6e0c87b76326d0862184729a69b73d3b7305b6288e1d830067e"}, {file = "black-23.11.0.tar.gz", hash = "sha256:4c68855825ff432d197229846f971bc4d6666ce90492e5b02013bcaca4d9ab05"}, + {file = "black-23.11.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dbea0bb8575c6b6303cc65017b46351dc5953eea5c0a59d7b7e3a2d2f433a911"}, + {file = "black-23.11.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:412f56bab20ac85927f3a959230331de5614aecda1ede14b373083f62ec24e6f"}, + {file = "black-23.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d136ef5b418c81660ad847efe0e55c58c8208b77a57a28a503a5f345ccf01394"}, + {file = "black-23.11.0-cp310-cp310-win_amd64.whl", hash = "sha256:6c1cac07e64433f646a9a838cdc00c9768b3c362805afc3fce341af0e6a9ae9f"}, + {file = "black-23.11.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cf57719e581cfd48c4efe28543fea3d139c6b6f1238b3f0102a9c73992cbb479"}, + {file = "black-23.11.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:698c1e0d5c43354ec5d6f4d914d0d553a9ada56c85415700b81dc90125aac244"}, + {file = "black-23.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:760415ccc20f9e8747084169110ef75d545f3b0932ee21368f63ac0fee86b221"}, + {file = "black-23.11.0-cp311-cp311-win_amd64.whl", hash = "sha256:58e5f4d08a205b11800332920e285bd25e1a75c54953e05502052738fe16b3b5"}, + {file = "black-23.11.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:45aa1d4675964946e53ab81aeec7a37613c1cb71647b5394779e6efb79d6d187"}, + {file = "black-23.11.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4c44b7211a3a0570cc097e81135faa5f261264f4dfaa22bd5ee2875a4e773bd6"}, + {file = "black-23.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2a9acad1451632021ee0d146c8765782a0c3846e0e0ea46659d7c4f89d9b212b"}, + {file = "black-23.11.0-cp38-cp38-win_amd64.whl", hash = "sha256:fc7f6a44d52747e65a02558e1d807c82df1d66ffa80a601862040a43ec2e3142"}, + {file = "black-23.11.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7f622b6822f02bfaf2a5cd31fdb7cd86fcf33dab6ced5185c35f5db98260b055"}, + {file = "black-23.11.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:250d7e60f323fcfc8ea6c800d5eba12f7967400eb6c2d21ae85ad31c204fb1f4"}, + {file = "black-23.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5133f5507007ba08d8b7b263c7aa0f931af5ba88a29beacc4b2dc23fcefe9c06"}, + {file = "black-23.11.0-cp39-cp39-win_amd64.whl", hash = "sha256:421f3e44aa67138ab1b9bfbc22ee3780b22fa5b291e4db8ab7eee95200726b07"}, + {file = "black-23.11.0-py3-none-any.whl", hash = "sha256:54caaa703227c6e0c87b76326d0862184729a69b73d3b7305b6288e1d830067e"}, + {file = "black-23.11.0.tar.gz", hash = "sha256:4c68855825ff432d197229846f971bc4d6666ce90492e5b02013bcaca4d9ab05"}, ] [package.dependencies] @@ -1027,6 +1046,8 @@ files = [ [[package]] name = "uwuipy" version = "0.1.7" +name = "uwuipy" +version = "0.1.7" description = "Allows the easy implementation of uwuifying words for applications like Discord bots and websites" optional = false python-versions = ">=3.10,<4.0" @@ -1034,6 +1055,11 @@ files = [ {file = "uwuipy-0.1.7-py3-none-any.whl", hash = "sha256:db26b361e4466c85ae06fe1a663ce77167e16993c9e848511cd49f74107ff1e8"}, {file = "uwuipy-0.1.7.tar.gz", hash = "sha256:94915fbb5f897ab9532d5d39e7e4b726fd8da8c3352efcfb1c1df98a5cf9ec04"}, ] +python-versions = ">=3.10,<4.0" +files = [ + {file = "uwuipy-0.1.7-py3-none-any.whl", hash = "sha256:db26b361e4466c85ae06fe1a663ce77167e16993c9e848511cd49f74107ff1e8"}, + {file = "uwuipy-0.1.7.tar.gz", hash = "sha256:94915fbb5f897ab9532d5d39e7e4b726fd8da8c3352efcfb1c1df98a5cf9ec04"}, +] [[package]] name = "websockets" diff --git a/pyproject.toml b/pyproject.toml index 8ca852e..1cda7f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ bs4 = "^0.0.1" uwuipy = "^0.1.7" [tool.poetry.group.dev.dependencies] -black = {version = "^23.9.1", allow-prereleases = true} +black = {version = "^23.11.0", allow-prereleases = true} [build-system] requires = ["poetry-core"] diff --git a/vyxalbot2/github/__init__.py b/vyxalbot2/github/__init__.py index 9f504fb..ccbc11f 100644 --- a/vyxalbot2/github/__init__.py +++ b/vyxalbot2/github/__init__.py @@ -191,6 +191,30 @@ async def onPushAction(self, event: GitHubEvent): if user == event.data["sender"]["login"]: user = formatUser(event.data["sender"]) yield f"{user} {verb}ed {count} commits ([s]({commits[0]['url']}) [e]({commits[-1]['url']})) to {formatRef(branch, event.data['repository'])} in {formatRepo(event.data['repository'])}: {commits[-1]['message'].splitlines()[0]}" + verb = "force-push" if event.data["forced"] else "push" + if len(event.data["commits"]) <= 5: + for commit in event.data["commits"]: + if not commit["distinct"]: + continue + if event.data["pusher"]["name"] == event.data["sender"]["login"]: + user = formatUser(event.data["sender"]) + else: + user = event.data["pusher"]["name"] + yield f"{user} {verb}ed a [commit]({commit['url']}) to {formatRef(branch, event.data['repository'])} in {formatRepo(event.data['repository'])}: {commit['message'].splitlines()[0]}" + else: + counter = Counter() + userCommits = defaultdict(lambda: []) + for commit in event.data["commits"]: + if not commit["distinct"]: + continue + name = event.data["pusher"]["name"] + counter[name] += 1 + userCommits[name].append(commit) + for user, count in counter.items(): + commits = userCommits[user] + if user == event.data["sender"]["login"]: + user = formatUser(event.data["sender"]) + yield f"{user} {verb}ed {count} commits ([s]({commits[0]['url']}) [e]({commits[-1]['url']})) to {formatRef(branch, event.data['repository'])} in {formatRepo(event.data['repository'])}: {commits[-1]['message'].splitlines()[0]}" @wrap async def onIssueAction(self, event: GitHubEvent):