Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/202237
Change subject: ircecho message beautification tweaks
......................................................................
ircecho message beautification tweaks
Add beautify_message() func and have both code paths that echo to IRC call it
to beautify message text.
Change-Id: I35d685e390b0818cd7f85cf4bb6916583a9c3356
---
M modules/ircecho/files/ircecho
1 file changed, 12 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/37/202237/1
diff --git a/modules/ircecho/files/ircecho b/modules/ircecho/files/ircecho
index 15c20a2..523a072 100755
--- a/modules/ircecho/files/ircecho
+++ b/modules/ircecho/files/ircecho
@@ -19,6 +19,16 @@
from ircbot import SingleServerIRCBot
+def beautify_message(m):
+ """Clean up formatting of alert messages."""
+ m = m.strip() # Strip trailing whitespace
+ m = re.sub(r'(\w+): \1:?', r'\1', m) # Dedupe severity
+ m = re.sub(r' {2,}', ' ', m) # Collapse whitespace
+ m = m.replace(': -', ':') # Combine separators
+ m = m.strip(':-') # Strip trailing separators
+ return m
+
+
class EchoNotifier(threading.Thread):
def __init__(self, notifier):
threading.Thread.__init__(self)
@@ -91,6 +101,7 @@
try:
s = raw_input()
# this throws an exception if not
connected.
+ s = beautify_message(s)
self.bot.connection.privmsg(self.chans,
s)
except EOFError:
# Once the input is finished, the bot
should exit
@@ -129,8 +140,7 @@
class EventHandler(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event):
s = reader.readfile(event.pathname)
- s = s.rstrip('\n')
- s = re.sub(r'(\w+: )\1', r'\1', s) # Dedupe severity
("CRITICAL: CRITICAL:")
+ s = beautify_message(s)
if s:
chans = reader.getchannels(event.pathname)
try:
--
To view, visit https://gerrit.wikimedia.org/r/202237
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I35d685e390b0818cd7f85cf4bb6916583a9c3356
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits