~dricottone/huttese-apk

44ba1a81e93fe1d2b84c3fb2622a9a4fac3ae894 — Drew DeVault 4 years ago 3bdbd41
alertmanager-irc-relay: add PRIVMSG patch
A sr.ht/alertmanager-irc-relay/0001-Add-option-to-use-PRIVMSG-instead-of-NOTICE.patch => sr.ht/alertmanager-irc-relay/0001-Add-option-to-use-PRIVMSG-instead-of-NOTICE.patch +68 -0
@@ 0,0 1,68 @@
From e2858e45608b14723624658b3dbbd54464deef66 Mon Sep 17 00:00:00 2001
From: Drew DeVault <sir@cmpwn.com>
Date: Mon, 6 Jan 2020 10:38:31 -0500
Subject: [PATCH] Add option to use PRIVMSG instead of NOTICE

This is desirable in some situations.
---
 config.go | 2 ++
 irc.go    | 9 ++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/config.go b/config.go
index f0897e1..6bffa81 100644
--- a/config.go
+++ b/config.go
@@ -41,6 +41,7 @@ type Config struct {
 	IRCChannels    []IRCChannel `yaml:"irc_channels"`
 	NoticeTemplate string       `yaml:"notice_template"`
 	NoticeOnce     bool         `yaml:"notice_once_per_alert_group"`
+	UsePrivmsg     bool         `yaml:"use_privmsg"`
 }
 
 func LoadConfig(configFile string) (*Config, error) {
@@ -55,6 +56,7 @@ func LoadConfig(configFile string) (*Config, error) {
 		IRCUseSSL:   true,
 		IRCChannels: []IRCChannel{IRCChannel{Name: "#airtest"}},
 		NoticeOnce:  false,
+		UsePrivmsg:  false,
 	}
 
 	if configFile != "" {
diff --git a/irc.go b/irc.go
index ee27006..ea395a4 100644
--- a/irc.go
+++ b/irc.go
@@ -64,6 +64,8 @@ type IRCNotifier struct {
 
 	NickservDelayWait time.Duration
 	BackoffCounter    Delayer
+
+	usePrivmsg bool
 }
 
 func NewIRCNotifier(config *Config, alertNotices chan AlertNotice) (*IRCNotifier, error) {
@@ -96,6 +98,7 @@ func NewIRCNotifier(config *Config, alertNotices chan AlertNotice) (*IRCNotifier
 		JoinedChannels:    make(map[string]ChannelState),
 		NickservDelayWait: nickservWaitSecs * time.Second,
 		BackoffCounter:    backoffCounter,
+		usePrivmsg:        config.UsePrivmsg,
 	}
 
 	notifier.Client.HandleFunc(irc.CONNECTED,
@@ -196,7 +199,11 @@ func (notifier *IRCNotifier) MaybeSendAlertNotice(alertNotice *AlertNotice) {
 		return
 	}
 	notifier.JoinChannel(&IRCChannel{Name: alertNotice.Channel})
-	notifier.Client.Notice(alertNotice.Channel, alertNotice.Alert)
+	if notifier.usePrivmsg {
+		notifier.Client.Privmsg(alertNotice.Channel, alertNotice.Alert)
+	} else {
+		notifier.Client.Notice(alertNotice.Channel, alertNotice.Alert)
+	}
 }
 
 func (notifier *IRCNotifier) Run() {
-- 
2.24.1


M sr.ht/alertmanager-irc-relay/APKBUILD => sr.ht/alertmanager-irc-relay/APKBUILD +4 -2
@@ 2,7 2,7 @@
pkgname=alertmanager-irc-relay
pkgver=20200105
_commit=aebe137d2e9545de98da1959b3036d5a612c8df3
pkgrel=1
pkgrel=2
pkgdesc="Prometheus Alertmanager IRC relay"
url="https://github.com/google/alertmanager-irc-relay"
arch="all"


@@ 14,6 14,7 @@ source="
	alertmanager-irc-relay.confd
	alertmanager-irc-relay.initd
	alertmanager-irc-relay.yml
	0001-Add-option-to-use-PRIVMSG-instead-of-NOTICE.patch
"
subpackages="$pkgname-openrc"
builddir="$srcdir/$pkgname-$_commit"


@@ 52,4 53,5 @@ package() {
sha512sums="bb1ecac858cee6403d591a3e600138a12549adcd27f1d3c6136966f163bef9cac697019af0fcd859bc2fd7c6b3ca7bef444d1566559203f7561408fbdd3eeee9  alertmanager-irc-relay-20200105.tar.gz
43707b80d9baeab8a50ef2489f3bbc61b154b18e2d4ef8be6c7392a8afa27c1884c5f6f121b41fb5095f8cf9d957f4eda98f4fa197774f86a95d3bd930593b1b  alertmanager-irc-relay.confd
4458cea59f5059921da7d609b562e9a74f20f472c320dbaa5382e733cfb18f2d2bc71655f2c574403f1a5047074b1a62e82969eea348e939fbf485bd9e3877c4  alertmanager-irc-relay.initd
646f9241087dd5c595f198b829109c975fb0c637026d59a6a271ae04fe0285744bc527797b171ad3840c543801ebeaad15925f906247de0cf2c86af96b57d9fa  alertmanager-irc-relay.yml"
646f9241087dd5c595f198b829109c975fb0c637026d59a6a271ae04fe0285744bc527797b171ad3840c543801ebeaad15925f906247de0cf2c86af96b57d9fa  alertmanager-irc-relay.yml
3b2bdd3a5b6b10848bd725648e4f7b1bdbc5c5ad1364bc5c2210953ad75f7cf1b6bd040581f07a2b3bc86783e05645b62471d6847e6597a5865ac8f588c44cbb  0001-Add-option-to-use-PRIVMSG-instead-of-NOTICE.patch"