gkrizek / ghi Goto Github PK
View Code? Open in Web Editor NEWGitHub IRC Notification Service
License: MIT License
GitHub IRC Notification Service
License: MIT License
2021-06-29 18:25:41 [ghi] IRC - Connecting to irc.libera.chat:6667 with nick nickname and channels: #channel
2021-06-29 18:25:42 [ghi] IRC - There was a problem sending messages to IRC
2021-06-29 18:25:42 [ghi] IRC - module 'base64' has no attribute 'encodestring'
2021-06-29 18:25:42 [ghi] Something went wrong while trying to notify IRC.
offending line: https://github.com/gkrizek/ghi/blob/master/ghi/irc.py#L87
can see that this fails in python 3.9.x
$ python3
Python 3.9.4 (default, Apr 9 2021, 01:15:05)
>>> blah = base64.encodestring("whatever".encode("UTF-8"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'base64' has no attribute 'encodestring'
https://docs.python.org/3.9/whatsnew/3.9.html
base64.encodestring() and base64.decodestring(), aliases deprecated since Python 3.1, have been removed: use
base64.encodebytes() and base64.decodebytes() instead. (Contributed by Victor Stinner in bpo-39351.)
changing encodestring to encodebytes resoles error and bot works again:
IRC - Connection Successful
Would be nice if this could also be configured to receive webhooks from Gitea/Forgejo instances like codeberg.org
As far as I know the hooks follow a Github like structure, so it should be relatively strait forward to add this.
Thanks!
I currently run two separate github event notification systems in parallel:
ghi
—for notifying IRC (webhook notification based)It would be nice to have this in one system, specified by one configuration file.
For comparison here was the patch to add "toot" support to bitcoinacks
: PierreRochard/bitcoin-acks@9f828d9
This could be a duplicate of #11 but there wasn't much information in that issue so I'm creating this one.
When authenticating with freenode, ghi waits for a message from the IRC server with the following pattern (r'(.*)AUTHENTICATE \+(.*)
but the server responds with an almost matching AUTHENTICATE :+
which is not matched and the authentication fails.
Making the match more permissive has solved the problem for me.
This would put the bot at more or less feature parity with the now discontinued "official" Github IRC bot.
ghi is not compatible with version 6 of PyYAML and throws the following exception when starting up: TypeError: load() missing 1 required positional argument: 'Loader'
Moving down to PyYAML version 5 fixed the issue for me.
I noticed none of the packages in the requirements-*.txt
files are pinned to specific versions. Perhaps they should be pinned to at least a major version.
Is it possible to set up ghi to watch an entire organization and notify about each commit happening in either of the projects belonging there?
A few days ago my instance of GHI got an invalid request, which did not come from github, for all intents or purposes it looks like a random scan for a XMLRPC vulnerability, but it managed to make the bot stop working
Jun 27 17:38:37 galatea python3[458]: POST /ui/h5-vsan/rest/proxy/service/invalidArgument/invalidArgument (XX.XX.XX.XX)
Jun 27 17:38:37 galatea python3[458]: Found configuration file at '/home/ghi/.ghi.yml'
Jun 27 17:38:38 galatea python3[458]: config = yaml.load(readFile(configFilePath))
Jun 27 17:38:38 galatea python3[458]: Exception in thread Thread-1:
Jun 27 17:38:38 galatea python3[458]: Traceback (most recent call last):
Jun 27 17:38:38 galatea python3[458]: File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
Jun 27 17:38:38 galatea python3[458]: self.run()
Jun 27 17:38:38 galatea python3[458]: File "/usr/lib/python3.8/threading.py", line 870, in run
Jun 27 17:38:38 galatea python3[458]: self._target(*self._args, **self._kwargs)
Jun 27 17:38:38 galatea python3[458]: File "ghi/ghi/server.py", line 86, in worker
Jun 27 17:38:38 galatea python3[458]: response = item(*args, **kwargs)
Jun 27 17:38:38 galatea python3[458]: File "ghi/ghi/server.py", line 44, in InvokeFunction
Jun 27 17:38:38 galatea python3[458]: return handler(event=payload, sysd=GetArgs()['log_mode'])
Jun 27 17:38:38 galatea python3[458]: File "ghi/index.py", line 54, in handler
Jun 27 17:38:38 galatea python3[458]: pool = getPool(githubPayload, configuration["pools"])
Jun 27 17:38:38 galatea python3[458]: File "ghi/github.py", line 23, in getPool
Jun 27 17:38:38 galatea python3[458]: repo = payload["repository"]["full_name"]
Jun 27 17:38:38 galatea python3[458]: KeyError: 'repository'
After this are no more reports of notifications at all, nor errors, although I'm sure github kept sending them. It's as if it became deaf. Likely, the exception brought it into an invalid state.
After restarting everything worked again.
After successfully delivering a first message to my IRC channel ghi is reporting an error:
2022-02-02 13:33:30 [ghi] waiting for messages...
2022-02-02 13:33:31 [ghi] waiting for messages...
2022-02-02 13:33:32 [ghi] waiting for messages...
2022-02-02 13:33:34 [ghi] waiting for messages...
2022-02-02 13:33:35 [ghi] waiting for messages...
2022-02-02 13:33:36 [ghi] waiting for messages...
2022-02-02 13:33:37 [ghi] waiting for messages...
2022-02-02 13:33:39 [ghi] waiting for messages...
2022-02-02 13:33:40 [ghi] waiting for messages...
2022-02-02 13:33:41 [ghi] waiting for messages...
2022-02-02 13:33:42 [ghi] waiting for messages...
2022-02-02 13:33:44 [ghi] waiting for messages...
2022-02-02 13:33:44 [ghi] IRC - There was a problem sending messages to IRC
2022-02-02 13:33:44 [ghi] IRC - Timeout sending messages to IRC.
2022-02-02 13:33:44 [ghi] Something went wrong while trying to notify IRC.
2022-02-02 13:33:44 [ghi]
2022-02-02 13:33:44 [ghi] Response:
2022-02-02 13:33:44 [ghi] {'statusCode': 500, 'body': '{"success": false, "message": "Something went wrong."}'}
2022-02-02 13:33:44 [ghi] Stop UUID: 4e46361f-b0d4-480e-b7e9-d2db060a9250
2022-02-02 13:33:44 [ghi]
It takes about 150 seconds to timeout and throw this message during which new messages will not be delivered although they appear to be delivered after this timeout.
This bug doesn't stop messages being delivered, it just fills the logs with errors and means two messages can't be delivered within 150 seconds of each other.
I suspect the problem might be similar to the cause of #16 where ghi is looking for a specific message and freenode has changed the format or content although I've not looked into it yet.
A possibly useful feature would be a matrix backend. This would both be useful to have merge notifications in matrix rooms, and (in combination with matrix-IRC bridge) to have a bot that sticks around persistently instead of leaving every time.
Sending to IRC fails with this message:
Feb 20 14:03:09 … python3[399]: IRC - Connecting to irc.libera.chat:6697 with nick bitcoin-git and channels: #bitcoin-commits,#bitcoin-core-dev
Feb 20 14:03:09 … python3[399]: IRC - There was a problem sending messages to IRC
Feb 20 14:03:09 … python3[399]: IRC - module 'base64' has no attribute 'encodestring'
According to upstream issue 39351, this function was deprecated since Python 3.1 in favor of base64.encodebytes
and decodebytes
.
The bot seems not joining I ran it. Payload is working fine and webhook as well.
Could file this one under user error as a quote makes a comment in the yaml file but it caught me out. Perhaps the documentation and the example config files could include channel names that start with a hash and are in quotes. This would give an example and maybe stop someone from having to check the logs to see why it can't talk to their IRC channel.
It works, but the message could be better. E.g. [bitcoin] laanwj deleted branch 0.17
Not sure if a secret is genuinely needed when parsing the webhook message but the documentation suggested secret should be optional.
Simplest fix could be a documentation change or if it's genuinely an option not to have, update the code reading in the config values to skip secret if the key is not present.
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.