Exemple #1
0
    def handle(self, msg):

        # is this a direct message?
        # ~> @adammck What is mudkips?
        match = self.DIRECT_MSG_RE.match(msg.text)
        if match is not None:
            models = utils.messagable_models()
            to_msg = find_objects(models, match.group(1))

            text = "%s: %s" % (
                msg.reporter or msg.connection,
                match.group(2))

            # send the message to each object returned
            # by the search. might be one reporter (via
            # their username), or 100 (via their location)
            for obj in to_msg:
                obj.__message__(self.router, text)

            if to_msg:
                msg.respond(
                    u"Your message was sent to: %s" %
                    (", ".join(map(unicode, to_msg))))

            return True
Exemple #2
0
    def handle(self, msg):
        match = self.FOLLOW_RE.match(msg.text)
        if match is not None:

            # fetch a list of objects (any model) that
            # match the query via the __search__ api
            to_follow = find_objects(
                followable_models(),
                match.group(1))

            # link this reporter to the "followers" reverse foreign key
            # of each object (whatever model it is -- they're all named
            # "followers"). this works with unidentified connections too,
            # even if that doesn't make much sense most of the time
            for obj in to_follow:
                obj.followers.get_or_create(**msg.persistance_dict)

            if to_follow:
                msg.respond(
                    u"You are now following: %s" %
                    (", ".join(map(unicode, to_follow))))

            # if we didn't understand _any_ of what the
            # caller asked us to follow, return an error
            else:
                msg.respond(u"Sorry, I couldn't understand what you want to follow")

            return True

        # is this an unfollow request?
        pass

        # is this a "who am i following?" request?
        pass
Exemple #3
0
    def handle(self, msg):

        # is this a direct message?
        # ~> @adammck What is mudkips?
        match = self.DIRECT_MSG_RE.match(msg.text)
        if match is not None:
            models = utils.messagable_models()
            to_msg = find_objects(match.group(1), models)

            text = "%s: %s" % (
                msg.reporter or msg.connection,
                match.group(2))

            # send the message to each object returned
            # by the search. might be one reporter (via
            # their username), or 100 (via their location)
            for obj in to_msg:
                try:
                    obj.__message__(self.router, text)

                # something went bang, but don't let that
                # prevent the other messages from being sent
                except:
                    self.log_last_exception(
                        "Message couldn't be sent to %s" %
                        obj)

            if to_msg:
                msg.respond(
                    u"Your message was sent to: %s." %
                    (", ".join(map(unicode, to_msg))))

            return True
    def handle(self, text):

        to_unfollow = find_objects(
            text, followable_models())

        for obj in to_unfollow:
            try:
                obj.followers.get(**self.msg.persistance_dict).delete()

            except obj.DoesNotExist:
                pass

        if to_unfollow:
            self.respond(
                "You are no longer following: %s" %
                (", ".join(map(unicode, to_unfollow))))

        else:
            self.respond("Sorry, I couldn't understand what you want to stop following.")
    def handle(self, text):

        # fetch a list of objects (any model) that
        # match the query via the __search__ api
        to_follow = find_objects(
            text, followable_models())

        # link this reporter to the "followers" reverse foreign key
        # of each object (whatever model it is -- they're all named
        # "followers"). this works with unidentified connections too,
        # even if that doesn't make much sense most of the time
        for obj in to_follow:
            obj.followers.get_or_create(
                **self.msg.persistance_dict)

        if to_follow:
            self.respond(
                "You are now following: %s" %
                (", ".join(map(unicode, to_follow))))

        # if we didn't understand _any_ of what the
        # caller asked us to follow, return an error
        else:
            self.respond("Sorry, I couldn't understand what you want to follow.")