Commits

Marcin Kasperski committed 95cd0c4

Parsing some notifications

Comments (0)

Files changed (2)

src/mekk/fics/parsing/info_parser.py

      """, re.VERBOSE),
      lambda m: PlayerName(m.group('who'))),
 
+
+    ("watched_user_connected",
+     re.compile(r"""
+     ^
+     Notification:
+     \s+
+     (?P<who>\S+)
+     \shas\s
+     arrived
+     \.
+     $
+     """, re.VERBOSE),
+     lambda m: PlayerName(m.group('who'))),
+
+    ("watched_user_disconnected",
+     re.compile(r"""
+     ^
+     Notification:
+     \s+
+     (?P<who>\S+)
+     \shas\s
+     departed
+     \.
+     $
+     """, re.VERBOSE),
+     lambda m: PlayerName(m.group('who'))),
+
+
     # **ANNOUNCEMENT** from relay: FICS is relaying the Swedish Championship. (...)
     ("announcement",
      re.compile(r'^\s*\*+ANNOUNCEMENT\*+\s+from\s+(?P<who>\S+):\s*(?P<text>.*)$'),

tests/test_parser.py

         self.failUnlessEqual(w, 'watched_user_disconnected')
         self.failUnlessEqual(d, PlayerName('Mekk'))
 
+    def test_arrival_nt(self):
+        w, d = info_parser.parse_fics_line(
+            'Notification: FiNLiP has arrived and isn\'t on your notify list.')
+        self.failUnlessEqual(w, 'watching_user_connected')
+        self.failUnlessEqual(d, PlayerName('Mekk'))
+
+    def test_departure_nt(self):
+        w, d = info_parser.parse_fics_line(
+            'Notification: FiNLiP has departed and isn\'t on your notify list.')
+        self.failUnlessEqual(w, 'watching_user_disconnected')
+        self.failUnlessEqual(d, PlayerName('Mekk'))
+
+# Notification: FiNLiP has arrived and isn't on your notify list.
+
+
     def test_auto_logout(self):
         raise SkipTest
         w, d = info_parser.parse_fics_line(
 #
 #
 
-# Notification: FiNLiP has arrived and isn't on your notify list.