Ejemplo n.º 1
0
    def on_command(self, msg, stdin, stdout):
        query = " ".join(msg["args"][1:])
        if not query:
            query = stdin.read().strip()

        if query:
            mid = self._search_mid(query)
            if mid:
                topic = self._topic(mid)
                short_text, long_text = self._look_for_text(topic)
                if short_text and long_text:
                    url = sprunge(long_text)
                    print("{} {}".format(short_text, url), file=stdout)
                else:
                    raise StopCommand("There isn't much information about this.")
            else:
                raise StopCommand("I don't know what you're on about.")
        else:
            raise StopCommandWithHelp(self)
Ejemplo n.º 2
0
    def on_command(self, msg, stdin, stdout):
        query = " ".join(msg["args"][1:])
        if not query:
            query = stdin.read().strip()

        if query:
            mid = self._search_mid(query)
            if mid:
                topic = self._topic(mid)
                short_text, long_text = self._look_for_text(topic)
                if short_text and long_text:
                    url = sprunge(long_text)
                    print("{} {}".format(short_text, url), file=stdout)
                else:
                    raise StopCommand(
                        "There isn't much information about this.")
            else:
                raise StopCommand("I don't know what you're on about.")
        else:
            raise StopCommandWithHelp(self)
Ejemplo n.º 3
0
 def on_command(self, msg, stdin, stdout):
     contents = stdin.read().strip()
     if contents:
         print(sprunge(contents), file=stdout)
     else:
         raise StopCommand("Expected input on stdin.")