X-Git-Url: http://git.veekun.com/zzz-dywypi.git/blobdiff_plain/1c8551edc2afecf3a4b1251a59bd25f09d4c1926..ecdc8e079fceb99e8cf70600f032b6095cfc2db5:/plugins/NetHack/plugin.py diff --git a/plugins/NetHack/plugin.py b/plugins/NetHack/plugin.py index 6560f80..f0926f5 100644 --- a/plugins/NetHack/plugin.py +++ b/plugins/NetHack/plugin.py @@ -119,7 +119,7 @@ def parse_livelog(line): data[key] = val return data - + def livelog_announcement(livelog): # achievement gained if 'achieve_diff' in livelog: @@ -162,8 +162,8 @@ def livelog_announcement(livelog): report_template = "{name} ({role} {race} {gender_delta} {align_delta}): " \ "{death} on {level_desc}. {points} points in {turns} turns, " \ - "wasting {realtime_pretty}. {dumplog}" - + "wasting {realtime_pretty}. " \ + "http://nethack.veekun.com/players/{name}/games/{endtime}" CONFIG_PLAYGROUND = '/opt/nethack.veekun.com/nethack/var' CONFIG_USERDATA_FILE = '/opt/nethack.veekun.com/dgldir/userdata' @@ -181,8 +181,12 @@ class NetHack(callbacks.Plugin): self.xlog.seek(0, os.SEEK_END) self.livelog.seek(0, os.SEEK_END) - # Remove the event first, in case this is a reload - schedule.removePeriodicEvent('nethack-log-ping') + # Remove the event first, in case this is a reload. This will fail if + # this is the first load, so throw it in a try + try: + schedule.removePeriodicEvent('nethack-log-ping') + except: + pass def callback(): self._checkLogs(irc) @@ -200,26 +204,7 @@ class NetHack(callbacks.Plugin): line = self.xlog.readline() if line: data = parse_xlog(line) - - # Find dumplog - dumplog_paths = glob( - os.path.join(CONFIG_USERDATA_FILE, - data['name'], - 'dumplog', - data['starttime']) - + '*' - ) - if dumplog_paths: - (_, dumplog_file) = os.path.split(dumplog_paths[0]) - dumplog_url = '{base}/{name}/dumplog/{file}'.format( - base=CONFIG_USERDATA_WEB, - name=data['name'], - file=dumplog_file, - ) - else: - dumplog_url = "Can't find dumplog :(" - - report = report_template.format(dumplog=dumplog_url, **data) + report = report_template.format(**data) msg = ircmsgs.privmsg(CONFIG_CHANNEL, report) irc.queueMsg(msg)