diff --git a/lib/nntp/tiny/mbox.py b/lib/nntp/tiny/mbox.py index a4cdf62..99a2d8a 100644 --- a/lib/nntp/tiny/mbox.py +++ b/lib/nntp/tiny/mbox.py @@ -1,5 +1,6 @@ import re import enum +import dateparser class MBoxReaderError(Exception): pass @@ -87,7 +88,7 @@ class MBoxMessage(): match = re.match('^([^:]+): (.*)$', line) if match: - self.key = match[1] + self.key = match[1].lower() self.headers[self.key] = match[2].rstrip() elif self.state is MBoxMessageState.BODY: @@ -98,6 +99,12 @@ class MBoxMessage(): self.line = line + def header(self, key: str): + return self.headers[key.lower()] + + def date(self): + return dateparser.parse(self.headers['date']) + def is_first_line(self): return len(self.headers) == 1 and (self.body == '' or self.body is None)