Browse Source

Log irc nick onto status page

This is useful to know who to follow up incidents or reports with.

Change-Id: I7620ba74c608f4078279bb1ba657aeb7a6d7fe55
changes/86/582186/1
Joshua Hesketh 3 years ago
parent
commit
4a179c0293
  1. 50
      statusbot/bot.py

50
statusbot/bot.py

@ -182,16 +182,16 @@ class ThanksPage(WikiPage):
class UpdateInterface(object):
def alert(self, msg=None):
def alert(self, msg=None, nick=None):
pass
def notice(self, msg=None):
def notice(self, msg=None, nick=None):
pass
def log(self, msg=None):
def log(self, msg=None, nick=None):
pass
def ok(self, msg=None):
def ok(self, msg=None, nick=None):
pass
@ -214,13 +214,13 @@ class Tweet(UpdateInterface):
def alert(self, msg=None):
self.update(msg)
def notice(self, msg=None):
def notice(self, msg=None, nick=None):
self.update(msg)
def log(self, msg=None):
def log(self, msg=None, nick=None):
pass
def ok(self, msg=None):
def ok(self, msg=None, nick=None):
if msg:
self.update(msg)
else:
@ -236,19 +236,19 @@ class StatusPage(WikiPage, UpdateInterface):
self.current_alert = None
self.items = []
def alert(self, msg):
self.update(set_alert=True, msg=msg)
def alert(self, msg, nick=None):
self.update(set_alert=True, msg=msg, nick=nick)
def notice(self, msg):
self.update(msg=msg)
def notice(self, msg, nick=None):
self.update(msg=msg, nick=nick)
def log(self, msg):
self.update(msg=msg)
def log(self, msg, nick=None):
self.update(msg=msg, nick=nick)
def ok(self, msg):
self.update(clear_alert=True, msg=msg)
def ok(self, msg, nick=None):
self.update(clear_alert=True, msg=msg, nick=nick)
def update(self, set_alert=None, clear_alert=None, msg=None):
def update(self, set_alert=None, clear_alert=None, msg=None, nick=None):
self.login()
self.loadItems()
if set_alert:
@ -256,7 +256,7 @@ class StatusPage(WikiPage, UpdateInterface):
if clear_alert:
self.setAlert(None)
if msg:
self.addItem(msg)
self.addItem(msg, nick)
self.saveItems()
def loadItems(self):
@ -279,8 +279,8 @@ class StatusPage(WikiPage, UpdateInterface):
text += '* %s\n' % item
self.save(text)
def addItem(self, item, ts=None):
text = '%s %s' % (self.timestamp(ts=ts), item)
def addItem(self, item, nick, ts=None):
text = '%s %s (reported by %s)' % (self.timestamp(ts=ts), item, nick)
self.items.insert(0, text)
def setAlert(self, current_alert):
@ -305,10 +305,10 @@ class AlertFile(UpdateInterface):
os.chmod(path, 0o644)
os.rename(path, self.path)
def alert(self, msg=None):
def alert(self, msg=None, nick=None):
self.write(msg)
def ok(self, msg=None):
def ok(self, msg=None, nick=None):
self.write(None)
@ -423,26 +423,26 @@ class StatusBot(irc.bot.SingleServerIRCBot):
self.send(channel, "%s: sending alert" % (nick,))
self.broadcast('NOTICE: ', text, set_topic=True)
for p in self.publishers:
p.alert(text)
p.alert(text, nick)
self.send(channel, "%s: finished sending alert" % (nick,))
elif command == 'notice':
self.log.info("Processing notice from %s: %s" % (nick, text))
self.send(channel, "%s: sending notice" % (nick,))
self.broadcast('NOTICE: ', text)
for p in self.publishers:
p.notice(text)
p.notice(text, nick)
self.send(channel, "%s: finished sending notice" % (nick,))
elif command == 'log':
self.log.info("Processing log from %s: %s" % (nick, text))
for p in self.publishers:
p.log(text)
p.log(text, nick)
self.send(channel, "%s: finished logging" % (nick,))
elif command == 'ok':
self.log.info("Processing ok from %s: %s" % (nick, text))
self.send(channel, "%s: sending ok" % (nick,))
self.broadcast('NOTICE: ', text, restore_topic=True)
for p in self.publishers:
p.ok(text)
p.ok(text, nick)
self.send(channel, "%s: finished sending ok" % (nick,))
else:
self.send(channel, "%s: unknown command" % (nick,))

Loading…
Cancel
Save