diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-11-22T18·14-0500 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-11-22T18·57+0000 |
commit | 1e43982c925a5845cef1cf996aef6301e8b37493 (patch) | |
tree | 1bbc01b95242497d415c51620be1f3ee4bcb2bc4 /web/panettone/src/irc.lisp | |
parent | 7dcd518c35e77a10cd4434d1e2dc3abf8d182f22 (diff) |
feat(panettone): Bring back + fix irccat issue creation announcement r/1896
This reverts commit e1067b1497b3dea0c37ae51bba21f42f1e7d35b5. The original issue here was misusing ISSUE-ID instead of ID, but also the associated username for the message should've been CN instead of DN Change-Id: I1629c0cb7597ff2ee2867f27870378eecdafe126 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2125 Tested-by: BuildkiteCI Reviewed-by: eta <eta@theta.eu.org>
Diffstat (limited to 'web/panettone/src/irc.lisp')
-rw-r--r-- | web/panettone/src/irc.lisp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/web/panettone/src/irc.lisp b/web/panettone/src/irc.lisp new file mode 100644 index 000000000000..c94b0d2f4bea --- /dev/null +++ b/web/panettone/src/irc.lisp @@ -0,0 +1,26 @@ +;;;; Using irccat to send IRC notifications + +(in-package :panettone.irc) + +(defun get-irccat-config () + "Reads the IRCCATHOST and IRCCATPORT environment variables, and returns them +as two values" + (destructuring-bind (host port) + (mapcar #'uiop:getenvp '("IRCCATHOST" "IRCCATPORT")) + (if (and host port) + (values host (parse-integer port)) + (values "localhost" 4722)))) + +(defun send-irc-notification (body &key channel) + "Sends BODY to the IRC channel CHANNEL (starting with #), +if an IRCCat server is configured (using the IRCCATHOST and IRCCATPORT +environment variables). +May signal a condition if sending fails." + (multiple-value-bind (irchost ircport) (get-irccat-config) + (when irchost + (let ((socket (socket-connect irchost ircport))) + (unwind-protect + (progn + (format (socket-stream socket) "~@[~A ~]~A~%" channel body) + (finish-output (socket-stream socket))) + (ignore-errors (socket-close socket))))))) |