コード例 #1
0
ファイル: notify.py プロジェクト: StephenMeansMe/tekka
    def action_cb(self, time, server, from_str, target, action):
        nick = from_str.split("!")[0]
        own_nick = self.get_nick(server)

        if own_nick:
            own_nick = own_nick.lower()

        if not own_nick:
            return
        elif own_nick == nick.lower():
            return

        def in_notify():
            self.notify(target, "%s %s" % (nick, self.escape(action)))

        if own_nick == target.lower():
            self.notify(nick, self.escape(action))
        elif self.has_highlight(action, own_nick):
            in_notify()
        elif self.notify_target(server, target):
            self.notify("%s:%s:%s" % (server, target, nick),
                        self.escape(action))
        else:
            for word in config.get_list("chatting", "highlight_words", []):
                if self.has_highlight(action, word):
                    in_notify()
                    break
コード例 #2
0
ファイル: notify.py プロジェクト: sushi-irc/tekka
	def action_cb (self, time, server, from_str, target, action):
		nick = from_str.split("!")[0]
		own_nick = self.get_nick(server)

		if own_nick:
			own_nick = own_nick.lower()

		if not own_nick:
			return
		elif own_nick == nick.lower():
			return

		def in_notify():
			self.notify(target, "%s %s" % (nick, self.escape(action)))

		if own_nick == target.lower():
			self.notify(nick, self.escape(action))
		elif self.has_highlight(action, own_nick):
			in_notify()
		elif self.notify_target(server, target):
			self.notify("%s:%s:%s" % (server, target, nick),
						self.escape(action))
		else:
			for word in config.get_list("chatting","highlight_words",[]):
				if self.has_highlight(action, word):
					in_notify()
					break
コード例 #3
0
ファイル: signal_handler.py プロジェクト: sushi-irc/tekka
def _hide_output(tab, what, own=False):
    """ Returns bool.
		Check if the message type determined by "what"
		shall be hidden or not.
		tab should be a TekkaServer, -Channel or -Query
	"""
    if type(tab) == gui.tabs.TekkaChannel:
        cat = "channel_%s_%s" % (tab.server.name.lower(), tab.name.lower())
    elif type(tab) == gui.tabs.TekkaQuery:
        cat = "query_%s_%s" % (tab.server.name.lower(), tab.name.lower())
    else:
        return False

    hide = what in config.get_list(cat, "hide", [])
    hideOwn = what in config.get_list(cat, "hide_own", [])

    return (hide and not own) or (own and hideOwn) or (hide and own and not hideOwn)
コード例 #4
0
def _hide_output(tab, what, own=False):
    """ Returns bool.
		Check if the message type determined by "what"
		shall be hidden or not.
		tab should be a TekkaServer, -Channel or -Query
	"""
    if type(tab) == gui.tabs.TekkaChannel:
        cat = "channel_%s_%s" % (tab.server.name.lower(), tab.name.lower())
    elif type(tab) == gui.tabs.TekkaQuery:
        cat = "query_%s_%s" % (tab.server.name.lower(), tab.name.lower())
    else:
        return False

    hide = what in config.get_list(cat, "hide", [])
    hideOwn = what in config.get_list(cat, "hide_own", [])

    return ((hide and not own) or (own and hideOwn)
            or (hide and own and not hideOwn))
コード例 #5
0
ファイル: signal_handler.py プロジェクト: sushi-irc/tekka
def isHighlighted(server_tab, text):
    def has_highlight(text, needle):
        punctuation = string.punctuation + " \n\t"
        needle = needle.lower()
        ln = len(needle)
        for line in text.split("\n"):
            line = line.lower()
            i = line.find(needle)
            if i >= 0:
                if line[i - 1 : i] in punctuation and line[ln + i : ln + i + 1] in punctuation:
                    return True
        return False

    highlightwords = config.get_list("chatting", "highlight_words", [])
    highlightwords.append(server_tab.nick)

    for word in highlightwords:
        if has_highlight(text, word):
            return True
    return False
コード例 #6
0
def isHighlighted(server_tab, text):
    def has_highlight(text, needle):
        punctuation = string.punctuation + " \n\t"
        needle = needle.lower()
        ln = len(needle)
        for line in text.split("\n"):
            line = line.lower()
            i = line.find(needle)
            if i >= 0:
                if (line[i - 1:i] in punctuation
                        and line[ln + i:ln + i + 1] in punctuation):
                    return True
        return False

    highlightwords = config.get_list("chatting", "highlight_words", [])
    highlightwords.append(server_tab.nick)

    for word in highlightwords:
        if has_highlight(text, word):
            return True
    return False