chiark / gitweb /
Add a cmd to add "applied" jobbers
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 16 Jan 2010 15:15:14 +0000 (15:15 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 16 Jan 2010 18:53:40 +0000 (18:53 +0000)
yoweb-scrape

index 49418a8..3ef8760 100755 (executable)
@@ -543,8 +543,7 @@ class ChatLogTracker:
                v['#lastinfo'] = timestamp
                self.force_redisplay()
 
-       def _onboard_event(self,v,timestamp,pirate,event,
-                       jobber=None,timeout=None):
+       def _onboard_event(self,v,timestamp,pirate,event,jobber=None):
                pa = self._pl.get(pirate, None)
                if pa is not None and pa.v is v:
                        pa.last_time = timestamp
@@ -556,6 +555,9 @@ class ChatLogTracker:
                        self._pl[pirate] = pa
                        if v is not None: v[pirate] = pa
                pa.jobber = jobber
+
+               if jobber is None: timeout = None
+               else: timeout = getattr(opts, 'timeout_'+jobber)
                if timeout is None: pa.expires = None
                else: pa.expires = timestamp + timeout
                self._vessel_updated(v, timestamp)
@@ -722,8 +724,7 @@ class ChatLogTracker:
                        return self._onboard_event(
                                None, timestamp, pirate,
                                ("jobber %s" % jobber),
-                               jobber=jobber,
-                               timeout=getattr(opts, 'timeout_'+jobber)
+                               jobber=jobber
                                )
 
                def disembark(v, timestamp, pirate, event):
@@ -784,15 +785,17 @@ class ChatLogTracker:
                        (cmdr, metacmd) = m.groups()
                        metacmd = regexp.sub('\\s+', ' ', metacmd).strip()
                        m2 = regexp.match(
-                               '/([ad]) (?:([A-Za-z* ]+)\\s*:)?([A-Za-z ]+)$',
-                               metacmd)
+                           '/([adj]) (?:([A-Za-z* ]+)\\s*:)?([A-Za-z ]+)$',
+                           metacmd)
                        if not m2: return chat(chan)
 
                        (cmd, pattern, targets) = m2.groups()
                        dml = ['cmd', chan, cmd]
 
                        if cmd == 'a': each = self._onboard_event
-                       else: each = disembark
+                       elif cmd == 'd': each = disembark
+                       else: each = lambda v,ts,tt,h: self._onboard_event(
+                                       None,ts,tt,h, jobber='applied')
 
                        if cmdr == self._myself.name:
                                dml.append('self')
@@ -870,7 +873,7 @@ class ChatLogTracker:
                        disembark(self._v, timestamp, pirate, 'left crew')
                        return d('left crew')
 
-               m = rm('\w+ has applied for the posted job\.')
+               m = rm('(\w+) has applied for the posted job\.')
                if m: return jb(m.group(1), 'applied')
 
                pirate= rm_crew("(\\w+) has been invited to job for '(.*)'\\.")