Esempio n. 1
0
    def send(self, message, cls="message", instance="personal", user=None):
        """
        Send a zephyr.

        Arguments:
            message - The message content
            cls - the message class (defaults to "message")
            instance - the message instance (defaults to "personal")
            user - the destination user (None means everyone)

        >>> messenger = Messenger("ME", ":memory:")
        # Send a message to -c help -i linux
        >>> messenger.send("This is a really short message.", "help", "linux")
        # Send a message to bsw
        >>> messenger.send("This is a really short message.", "message", "personal", "bsw")
        """
        znotice = zephyr.ZNotice(
            cls=cls,
            instance=instance,
            recipient=user,
            message="%s\x00%s" % (preferences.getVariable("signature"), message))

        znotice.send()

        if user:
            self.store_znotice(znotice)

	return True
Esempio n. 2
0
    def starAndHide(self, classes):
        """
        Star and hide a given list of classes.
        """

        # XXX: This should be done with plugins and callbacks

        starred_classes = preferences.getVariable("starred-classes")
        hidden_classes = preferences.getVariable("hidden-classes")

        def process(item):
            item["starred"] = item["cls"] in starred_classes
            item["hidden"] = item["cls"] in hidden_classes
            return item

        classes = [process(c) for c in classes]
        classes.sort(key=lambda item: not item["starred"])
        return classes