yoweb-scrape
- do right thing when chat log timestamp goes backwards:
- assume it's the next day (will go wrong when
- clocks go wrong - oh well)
parse officer chat for
/off /a [<ship>:] <pirate>...
/off /d [<ship>:] <pirate>...
m = rm('=+ (\\d+)/(\\d+)/(\\d+) =+$')
if m:
- self._date = m.groups()
+ self._date = [int(x) for x in m.groups()]
+ self._previous_timestamp = None
return d('date '+`self._date`)
if self._date is None:
if not m:
return d('no timestamp')
- time_tuple = [int(x) for x in self._date + m.groups()]
- time_tuple += (-1,-1,-1)
- timestamp = time.mktime(time_tuple)
+ while True:
+ time_tuple = (self._date +
+ [int(x) for x in m.groups()] +
+ [-1,-1,-1])
+ timestamp = time.mktime(time_tuple)
+ if timestamp >= self._previous_timestamp: break
+ self._date[2] += 1
+ self._debug_line_disposition(timestamp,'',
+ 'new date '+`self._date`)
+
+ self._previous_timestamp = timestamp
+
l = l[l.find(' ')+1:]
def ob_x(who,event):
* I haven't decided on a final copyright licence. You may treat this
version as GPLv3.
+ * The program will become confused when the clocks change,
+ particularly when they go backwards. This is due to the chat log
+ containing timestamps in local time without a timezone. If this
+ bothers you, make everything be in UTC. If it does get confused,
+ you can fix it by logging off and logging on again (perhaps waiting
+ until after the duplicated hour has passed) as that writes a new
+ date record to the log and starts a new series of timestamps.
+
Ian.