Esempio n. 1
0
    def update(self):
        """
        This function initially gets called by Ohno.loop, and should not return 
        from that call untill the bot is in a state of needing an action (i.e.
        menus should be closed, no --More-- in topline, no "What do you want to
        wish for?" etc.
        """
        self.ohno.logger.framebuffer('Updating framebuffer..')

        messages = self._read_messages()
        
        if 'Discoveries' in messages:
            # We should only get this when there's no other messages.
            assert len(messages) == 1
            discoveries = self._parse_discoveries()
            for appearance, identity in discoveries:
                Discovery.fire(self.ohno, appearance, identity)

        if 'Things that are here:' in self.get_string():
            things = self._parse_things_that_are_here()
            FoundItems.fire(self.ohno, things)
            # Since we're not synchronized at this moment (there might be an
            # unparsed topline after calling _parse_things_that_are_here), we
            # must call _read_messages again.
            messages += self._read_messages(receive_first=False)

        self.ohno.logger.framebuffer('All messages: %r' % messages)

        for message in messages:
            if (message.startswith('Do you want your possessions ') or 
               message.startswith('Do you want to see what you had ') or
               message.startswith('You die.')):
                YouDie.fire(self.ohno, messages)
                assert False, "Some event should probably exit()"

            if message.startswith('Call a'):
                self.ohno.client.send('\n')
                return messages + self.update()

            if message.startswith('Hello stranger, who are you'):
                self.ohno.client.send('\n')
                return messages + self.update()

        return messages
Esempio n. 2
0
 def on_message(self, event):
     if event.msgtype == "you_see_here":
         thing = event.kwargs["item"]
         FoundItems.fire(self, [thing])