maubot / github Goto Github PK
View Code? Open in Web Editor NEWA GitHub client and webhook receiver for maubot
License: GNU Affero General Public License v3.0
A GitHub client and webhook receiver for maubot
License: GNU Affero General Public License v3.0
I had to modify the URL sent to me to remove the public_repo permission. This is using the official bot @github:maunium.net.
16:42:27 ERROR client/@hs-github:kf8nh.com Failed to run handler
16:42:27 ERROR client/@hs-github:kf8nh.com Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/mautrix/client/syncer.py", line 236, in _catch_errors
await handler(data)
File "/opt/maubot/maubot/handlers/command.py", line 142, in __call__
ok, res = await self.__call_subcommand__(evt, call_args, remaining_val)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/maubot/maubot/handlers/command.py", line 163, in __call_subcommand__
return True, await subcommand(
^^^^^^^^^^^^^^^^^
File "/opt/maubot/maubot/handlers/command.py", line 142, in __call__
ok, res = await self.__call_subcommand__(evt, call_args, remaining_val)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/maubot/maubot/handlers/command.py", line 163, in __call_subcommand__
return True, await subcommand(
^^^^^^^^^^^^^^^^^
File "/opt/maubot/maubot/handlers/command.py", line 154, in __call__
return await self.__mb_func__(self.__bound_instance__, evt, **call_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/plugins/xyz.maubot.github-v0.1.2.mbp/github/commands.py", line 40, in wrapper
return await fn(self, evt, **kwargs, client=client)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/plugins/xyz.maubot.github-v0.1.2.mbp/github/commands.py", line 262, in webhook_create
await client.create_webhook(
File "/data/plugins/xyz.maubot.github-v0.1.2.mbp/github/api/client.py", line 188, in create_webhook
raise GitHubError(status=resp.status, **data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: github.api.client.GitHubError() got multiple values for keyword argument 'status'
So I know adding webhooks failed, but I don't get told why.
An SO search tells me that this means there's a collision between positional and keyword parameters. I don't think I know enough Python to fix this.
maubot is running in a Docker container which has Python 3.11.8 installed in it. The host is Ubuntu 22.04.3.
Currently the whole comment/issue body is left in the webhook message. At least the default settings should try to mirror the data on GitHub exactly, including deletions.
Otherwise clients won't render them
According to the GitHub Docs, GitHub Apps are preferrable to OAuth apps, as they provide, among other things, tighter authorization scopes (e.g. selecting which repos the App has access to, rather than all those the authorizing user has access to).
This document provides guidelines for how to migrate to Apps, in case that's what you decide to do.
Such as spamming star/unstar
When labelling multiple issues at once, bot show one issue being labelled multiple times.
An example:
GitHub
08:01 PM
[ajbura/cinny] ajbura added enhancement, enhancement, enhancement, enhancement, enhancement, enhancement, enhancement, enhancement and enhancement to issue #5: Being able to open images without having to open them in a new tab
The bot won't accept my repository name with a dot in it. Repositories without one works fine.
Example:
!github webhook add Garados007/MaxLib.WebServer
Output:
Usage: !webhook add <owner/repo>
hi, i see today an error after i updated maubot to version v0.3.1
is the github plugin broker in this maubot version?
[17:35:52](file:////opt/maubot/plugins/xyz.maubot.github-v0.1.1.mbp/github/webhook/aggregation.py:97)ERROR[instance/github.webhook](https://matrix.envs.net/_matrix/maubot/#/instance/github.webhook)Fatal error in aggregation handler
[17:35:52](file:////opt/maubot/plugins/xyz.maubot.github-v0.1.1.mbp/github/webhook/aggregation.py:97)ERROR[instance/github.webhook](https://matrix.envs.net/_matrix/maubot/#/instance/github.webhook)Traceback (most recent call last):
File "/opt/maubot/plugins/xyz.maubot.github-v0.1.1.mbp/github/webhook/aggregation.py", line 101, in _start
starter = self.aggregation_starters[self.event_type, self.event.action]
KeyError: (EventType.PUSH, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/maubot/plugins/xyz.maubot.github-v0.1.1.mbp/github/webhook/aggregation.py", line 95, in start
await self._start()
File "/opt/maubot/plugins/xyz.maubot.github-v0.1.1.mbp/github/webhook/aggregation.py", line 104, in _start
await self._send()
File "/opt/maubot/plugins/xyz.maubot.github-v0.1.1.mbp/github/webhook/aggregation.py", line 126, in _send
await self.handler.send_message(self.event_type, self.event, self.webhook_info.room_id,
File "/opt/maubot/plugins/xyz.maubot.github-v0.1.1.mbp/github/webhook/handler.py", line 132, in send_message
await self.bot.client.send_message(room_id, content)
File "/opt/maubot/lib/python3.9/site-packages/mautrix/client/encryption_manager.py", line 164, in send_message_event
return await super().send_message_event(room_id, event_type, content, **kwargs)
File "/opt/maubot/lib/python3.9/site-packages/mautrix/client/api/events.py", line 401, in send_message_event
resp = await self.api.request(
File "/opt/maubot/lib/python3.9/site-packages/mautrix/api.py", line 363, in request
content = json.dumps(content)
File "/usr/lib/python3.9/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.9/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.9/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.9/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type coroutine is not JSON serializable
Any chance of adding the ability to receive notifications from https://github.com/notifications as well?
1.invite the bot
2. login
3. apply <owner/repo> command. !gh webhook add owner/repo
4. apply test Issue on the repo, and wait for bot to respond. (it did not respond)
At first we tested it on an encrypted room, then later we created a temporary unencrypted room to see if anything gets fixed, it didn't fix anything.
This would be really helpful because dependabot tends to create extremely long pull requests.
Hi! I hope it's okay if I make a feature request here. If you can get me on the way of patching it myself (and validating), I'd be glad to.
Basically, I'd love to see this:
... result in reactions on GH. If I can read the code correctly, it only works on issues and issue comments at this moment.
I would patch it like this:
diff --git a/github/commands.py b/github/commands.py
index a62f915..bea95ef 100644
--- a/github/commands.py
+++ b/github/commands.py
@@ -161,6 +161,8 @@ class Commands:
subject_id = webhook_meta["issue"]["node_id"]
elif webhook_meta["event_type"] == "issue_comment" and webhook_meta["action"] == "created":
subject_id = webhook_meta["comment"]["node_id"]
+ elif webhook_meta["event_type"] == "pull_request" and webhook_meta["action"] == "created":
+ subject_id = webhook_meta["comment"]["node_id"]
else:
return
await client.mutate(query="addReaction(input: $input) { clientMutationId }",
... but it seems to me that webhook_meta
does not have "action"
as a field for PRs. I don't immediately get the code (it gets really abstract really fast), but I admit I haven't looked to deeply. If you give me some pointers, I'll patch something up tomorrow.
The README currently has instructions for adding a repo the user owns (!github webhook add <owner>/<repo>
) but not for a repo in an org.
How would you go about this? Thanks!
No releases appear to be available on this plugin. I can zip things up myself, but...
Another option would be to edit the original webhook message on Matrix. At least if the webhook was posted recently, editing would probably be the preferable UX
I was looking for a replacement for the github slack bot that works with Matrix and I have to say that this maubot plugin is just what I needed! Before trying this, I was using opsdroid. One of the features I was thinking of implementing is to convert github mentions into matrix mentions.
Will this be possible? I can work on it and create a PR. I was thinking that maybe someone will insight on the project could point me in the right direction where to start.
It would be great to support notifications generated by GitHub discussions for a connected repo.
It would be awesome to be able to filter on only certain branches in the config either per repository or globally. GitHub doesn't seem to allow configuring this, it's either all pushes or none for the webhook.
Use case; I want pushes as notifications for the main branch but not when building something in a branch to make a pull request.
The plugin can't load due to this exception being thrown. I'm using the official Docker container of maubot.
File "/data/plugins/xyz.maubot.github-v0.1.0.mbp/github/bot.py", line 41, in <module>
class GitHubBot(Plugin):
File "/data/plugins/xyz.maubot.github-v0.1.0.mbp/github/bot.py", line 109, in GitHubBot
async def raw_query(self, evt: MessageEvent, query: str, client: GitHubClient) -> None:
TypeError: 'staticmethod' object is not callable
Anyway to fix this? I have no idea how Python works :(
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.