+ def chat_core(speaker, chan):
+ try: pa = self._pl[speaker]
+ except KeyError: return 'mystery'
+ if pa.v is not self._v: return 'elsewhere'
+ pa.last_chat_time = timestamp
+ pa.last_chat_chan = chan
+ self.force_redisplay()
+ return 'here'
+
+ def chat(chan):
+ speaker = m.group(1)
+ dm = chat_core(speaker, chan)
+ return d('chat %s %s' % (chan, dm))
+
+ def chat_metacmd(chan):
+ (cmdr, metacmd) = m.groups()
+ metacmd = regexp.sub('\\s+', ' ', metacmd).strip()
+ m2 = regexp.match(
+ '/([ad]) (?:([A-Za-z ]+)\\s*:)?([A-Za-z ]+)$',
+ metacmd)
+ if not m2: return chat(chan)
+
+ (cmd, vn, targets) = m2.groups()
+ dml = ['cmd', chan, cmd]
+
+ if cmd == 'a': each = self._onboard_event
+ else: each = disembark
+
+ if cmdr == self._myself.name:
+ dml.append('self')
+ how = 'manual: /%s' % cmd
+ else:
+ dml.append('other')
+ how = '/%s %s' % (cmd,cmdr)
+
+ v = None
+ if vn is not None and len(vn.split(' ')) == 2:
+ v = self._update_vessel_lookup(
+ vn.title(), timestamp, dml)
+ elif self._v is None:
+ dml.append('no-current')
+ elif vn is None:
+ dml.append('current')
+ v = self._v
+ elif regexp.match('(?:.* )?%s$' % vn.title(),
+ self._vessel):
+ dml.append('match')
+ v = self._v
+ else:
+ dml.append('unk-abbrev')
+
+ if v is not None:
+ targets = targets.strip().split(' ')
+ dml.append(`len(targets)`)
+ for target in targets:
+ each(v, timestamp, target.title(), how)
+
+ dm = ' '.join(dml)
+ chat_core(cmdr, 'cmd '+chan)
+ return d(dm)