diff --git a/rezoirclogs/templates/macros.jinja2 b/rezoirclogs/templates/macros.jinja2 index 4d6972b..cb91b99 100644 --- a/rezoirclogs/templates/macros.jinja2 +++ b/rezoirclogs/templates/macros.jinja2 @@ -5,7 +5,9 @@ * {{ line.user | colored}} {{ line.message | urlize}} {%- elif line.type == 'status' -%} -!- {{ line.user | colored }} {{ line.message }} + {%- elif line.type == 'service' -%} + -{{ line.user | colored }}- {{ line.message }} {%- else -%} {{ line }} {%- endif -%} -{%- endmacro %} \ No newline at end of file +{%- endmacro %} diff --git a/rezoirclogs/tests/test_utils.py b/rezoirclogs/tests/test_utils.py index 229a58b..0c6330e 100644 --- a/rezoirclogs/tests/test_utils.py +++ b/rezoirclogs/tests/test_utils.py @@ -79,6 +79,25 @@ def test_status_empty(self): self.assertEqual(m.type, "status") self.assertEqual(m.message, "") + def test_service(self): + lines = [("01:53 -ChanServ(services@services.rezosup.org)- Informations pour le canal #linux:", "service", "Informations pour le canal #linux:", 'ChanServ(services@services.rezosup.org)', '01:53'), + ("01:53:09 -ChanServ(services@services.rezosup.org)- Informations pour le canal #linux:", "service", "Informations pour le canal #linux:", 'ChanServ(services@services.rezosup.org)', '01:53:09')] + for line, expected_type, expected_message, expected_nick, expected_time in lines: + m = self._get_FUT(line) + self.assertEqual(m.type, expected_type) + self.assertEqual(m.message, expected_message) + self.assertEqual(m.user, expected_nick) + self.assertEqual(m.time, expected_time) + self.assertEqual(str(m), line) + + def test_service_empty(self): + lines = ["12:11 -ChanServ(services@services.rezosup.org)-", + "12:11:10 -ChanServ(services@services.rezosup.org)-"] + for line in lines: + m = self._get_FUT(line) + self.assertEqual(m.type, "service") + self.assertEqual(m.message, "") + def test_unrecognized(self): m = self._get_FUT("Ceci n'est pas une ligne de log") self.assertEqual(m.type, "unrecognized") diff --git a/rezoirclogs/utils.py b/rezoirclogs/utils.py index 20e8b10..5802a91 100644 --- a/rezoirclogs/utils.py +++ b/rezoirclogs/utils.py @@ -42,6 +42,7 @@ def __new__(cls, value): (re.compile(r"(\d\d:\d\d(?::\d\d)??) <%s> ?(.*)" % _nick_regex), 'normal'), (re.compile(r"(\d\d:\d\d(?::\d\d)??) *\* %s ?(.*)" % _nick_regex), 'me'), (re.compile(r"(\d\d:\d\d(?::\d\d)??) -!- %s ?(.*)" % _nick_regex), 'status'), + (re.compile(r"(\d\d:\d\d(?::\d\d)??) -(.+)?- ?(.*)"), 'service'), ] def populate(self):