Beispiel #1
0
def queryNotice_cb(time, server, from_str, message):
    """
		A user sends a notice directly to the maki user.
	"""
    nick = parse_from(from_str)[0]

    (server_tab, tab) = gui.tabs.search_tabs(server, nick)

    if tab:
        if tab.name != nick:
            # correct notation of tab name
            tab.name = nick

    if tab:
        tab.write(
            time,
            "-<font foreground='%s' weight='bold'>%s</font>- "
            "<font foreground='%s'>%s</font>"
            % (color.get_nick_color(nick), markup.escape(nick), color.get_text_color(nick), markup.escape(message)),
        )
    else:
        server_tab.current_write(
            time,
            "-<font foreground='%s' weight='bold'>%s</font>- "
            "<font foreground='%s'>%s</font>"
            % (color.get_nick_color(nick), markup.escape(nick), color.get_text_color(nick), markup.escape(message)),
        )
Beispiel #2
0
def ownNotice_cb(time, server, target, message):
    """
		if query channel with ``target`` exists, print
		the notice there, else print it on the current
		channel of the network which is identified by
		`server`
	"""
    server_tab, tab = gui.tabs.search_tabs(server, target)
    ownNickColor = color.get_color_by_key("own_nick")
    ownNick = server_tab.nick

    if tab:
        tab.write(
            time,
            "&gt;<font foreground='%s' weight='bold'>%s</font>&lt; "
            "<font foreground='%s'>%s</font>"
            % (
                color.get_nick_color(target),
                markup.escape(target),
                color.get_text_color(target),
                markup.escape(message),
            ),
        )
    else:
        server_tab.current_write(
            time,
            "&gt;<font foreground='%s' weight='bold'>%s</font>&lt; "
            "<font foreground='%s'>%s</font>"
            % (
                color.get_nick_color(target),
                markup.escape(target),
                color.get_text_color(target),
                markup.escape(message),
            ),
        )
Beispiel #3
0
def userCTCP_cb(time, server, from_str, target, message):
    """
		A user sends a CTCP request to target.
		I don't know a case in which target is not a channel
		and not queried.
	"""
    nick = parse_from(from_str)[0]
    (server_tab, target_tab) = gui.tabs.search_tabs(server, target)

    if nick.lower() == server_tab.nick.lower():
        # we wrote us
        ownCTCP_cb(time, server, target, message)

    elif target.lower() == server_tab.nick.lower():
        # someone wrote us, put in into a query
        queryCTCP_cb(time, server, from_str, message)

    else:
        # normal ctcp
        headline = _("CTCP from %(nick)s to Channel:") % {
            "nick": markup.escape(nick)
        }

        target_tab.write(
            time, "<font foreground='#00DD33'>%s</font> %s" %
            (headline, markup.escape(message)))
Beispiel #4
0
def userNotice_cb(time, server, from_str, target, message):
    """ An incoming notice """
    nick = parse_from(from_str)[0]
    (server_tab, target_tab) = gui.tabs.search_tabs(server, target)

    if nick.lower() == server_tab.nick.lower():
        # we wrote that notice
        ownNotice_cb(time, server, target, message)
        return

    elif target.lower() == server_tab.nick.lower():
        # it's supposed to be a private (query) message
        queryNotice_cb(time, server, from_str, message)
        return

    message = "-<font foreground='%s' weight='bold'>%s</font>- " "<font foreground='%s'>%s</font>" % (
        color.get_nick_color(nick),
        markup.escape(nick),
        color.get_text_color(nick),
        markup.escape(message),
    )

    if target_tab == None:
        # global notice
        server_tab.current_write(time, message)
    else:
        # channel/query notice
        target_tab.write(time, message)
Beispiel #5
0
def queryNotice_cb(time, server, from_str, message):
    """
		A user sends a notice directly to the maki user.
	"""
    nick = parse_from(from_str)[0]

    (server_tab, tab) = gui.tabs.search_tabs(server, nick)

    if tab:
        if tab.name != nick:
            # correct notation of tab name
            tab.name = nick

    if tab:
        tab.write(
            time, "-<font foreground='%s' weight='bold'>%s</font>- "
            "<font foreground='%s'>%s</font>" %
            (color.get_nick_color(nick), markup.escape(nick),
             color.get_text_color(nick), markup.escape(message)))
    else:
        server_tab.current_write(
            time, "-<font foreground='%s' weight='bold'>%s</font>- "
            "<font foreground='%s'>%s</font>" %
            (color.get_nick_color(nick), markup.escape(nick),
             color.get_text_color(nick), markup.escape(message)))
Beispiel #6
0
def ownCTCP_cb(time, server, target, message):
    """
		The maki user sends a CTCP request to
		a channel or user (target).
	"""
    server_tab, tab = gui.tabs.search_tabs(server, target)

    if tab:
        # valid query/channel found, print it there

        nickColor = color.get_color_by_key("own_nick")
        textColor = color.get_color_by_key("own_text")

        tab.write(
            time, "&lt;CTCP:<font foreground='%s' weight='bold'>%s</font>&gt; "
            "<font foreground='%s'>%s</font>" %
            (nickColor, server_tab.nick, textColor, markup.escape(message)))

    else:
        server_tab.write(
            time,
            _("CTCP request from you to %(target)s: %(message)s") % {
                "target": markup.escape(target),
                "message": markup.escape(message)
            })
Beispiel #7
0
def userNotice_cb(time, server, from_str, target, message):
    """ An incoming notice """
    nick = parse_from(from_str)[0]
    (server_tab, target_tab) = gui.tabs.search_tabs(server, target)

    if nick.lower() == server_tab.nick.lower():
        # we wrote that notice
        ownNotice_cb(time, server, target, message)
        return

    elif target.lower() == server_tab.nick.lower():
        # it's supposed to be a private (query) message
        queryNotice_cb(time, server, from_str, message)
        return

    message = "-<font foreground='%s' weight='bold'>%s</font>- "\
        "<font foreground='%s'>%s</font>" % (
       color.get_nick_color(nick),
       markup.escape(nick),
       color.get_text_color(nick),
       markup.escape(message))

    if target_tab == None:
        # global notice
        server_tab.current_write(time, message)
    else:
        # channel/query notice
        target_tab.write(time, message)
Beispiel #8
0
def ownCTCP_cb(time, server, target, message):
    """
		The maki user sends a CTCP request to
		a channel or user (target).
	"""
    server_tab, tab = gui.tabs.search_tabs(server, target)

    if tab:
        # valid query/channel found, print it there

        nickColor = color.get_color_by_key("own_nick")
        textColor = color.get_color_by_key("own_text")

        tab.write(
            time,
            "&lt;CTCP:<font foreground='%s' weight='bold'>%s</font>&gt; "
            "<font foreground='%s'>%s</font>" % (nickColor, server_tab.nick, textColor, markup.escape(message)),
        )

    else:
        server_tab.write(
            time,
            _("CTCP request from you to %(target)s: %(message)s")
            % {"target": markup.escape(target), "message": markup.escape(message)},
        )
Beispiel #9
0
def userNick_cb(time, server, from_str, newNick):
    """
	A user (or the maki user) changed it's nick.
	If a query window for this nick on this server
	exists, it's name would be changed.
	"""
    nick = parse_from(from_str)[0]

    # find a query
    server_tab, tab = gui.tabs.search_tabs(server, nick)

    # rename query if found
    if tab and tab.is_query():
        tab.name = newNick

    own = False

    # we changed the nick
    if not nick or nick == server_tab.nick:
        message = _(u"• You are now known as %(newnick)s.")
        server_tab.nick = newNick
        own = True

    # someone else did
    else:
        message = _(u"• %(nick)s is now known as %(newnick)s.")

    # iterate over all channels and look if the nick is
    # present there. If true so rename him in nicklist cache.
    for tab in gui.tabs.get_all_tabs(servers=[server])[1:]:

        if not nick or newNick == server_tab.nick:
            # notification, print everytime
            doPrint = True
        else:
            doPrint = _show_output_exclusive(server_tab, tab, "nick", own)

        if tab.is_channel():
            if (nick in tab.nickList.get_nicks()):
                tab.nickList.modify_nick(nick, newNick)
            else:
                continue

        if tab.is_query() and tab.name != newNick:
            # ignore not associated queries
            continue

        nickString = "<font foreground='%s' weight='bold'>%s</font>" % (
            action_nick_color(nick), markup.escape(nick))

        newNickString = "<font foreground='%s' weight='bold'>%s</font>" % (
            action_nick_color(newNick), markup.escape(newNick))

        if doPrint:
            tab.write(time, message % {
                "nick": nickString,
                "newnick": newNickString
            }, gui.tabs.ACTION)
Beispiel #10
0
def userPart_cb(timestamp, server, from_str, channel, reason):
    """
	A user parted the channel.

	If we are the user who parted, mark the channel
	as parted (joined=False)
	"""
    nick = parse_from(from_str)[0]

    stab, tab = gui.tabs.search_tabs(server, channel)

    if not tab:
        # tab was closed
        return

    channelString = markup.escape(channel)
    reasonString = markup.escape(reason)

    if nick == stab.nick:
        # we parted

        tab.joined = False

        if _show_output_exclusive(stab, tab, "part", own=True):

            if reason:
                message = _(u"« You have left %(channel)s (%(reason)s).")
            else:
                message = _(u"« You have left %(channel)s.")

            tab.write(timestamp, message % {"channel": channelString, "reason": reasonString}, gui.tabs.ACTION)

    else:  # another user parted

        tab.nickList.remove_nick(nick)

        if tab.is_active():
            gui.mgmt.set_user_count(len(tab.nickList), tab.nickList.get_operator_count())

        if _show_output_exclusive(stab, tab, "part", False):

            nickString = "<font foreground='%s' weight='bold'>" "%s</font>" % (
                color.get_nick_color(nick),
                markup.escape(nick),
            )

            if reason:
                message = _(u"« %(nick)s has left %(channel)s " "(%(reason)s).")
            else:
                message = _(u"« %(nick)s has left %(channel)s.")

            tab.write(
                timestamp,
                message % {"nick": nickString, "channel": channelString, "reason": reasonString},
                gui.tabs.ACTION,
            )
Beispiel #11
0
def userKick_cb(time, server, from_str, channel, who, reason):
    """
		signal emitted if a user got kicked.
		If the kicked user is ourself mark the channel as
		joined=False
	"""
    nick = parse_from(from_str)[0]
    server_tab, tab = gui.tabs.search_tabs(server, channel)

    if not tab:
        logging.debug("userKick: channel '%s' does not exist." % (channel))
        return

    channelString = markup.escape(channel)

    nickString = "<font foreground='%s' weight='bold'>%s</font>" % (
        action_nick_color(nick), markup.escape(nick))

    reasonString = markup.escape(reason)

    if who == server_tab.nick:
        tab.joined = False

        if _show_output_exclusive(server_tab, tab, "kick", own=True):

            message = _(
                u"« You have been kicked from %(channel)s "
                u"by %(nick)s (%(reason)s)." % {
                    "channel": channelString,
                    "nick": nickString,
                    "reason": reasonString
                })

            tab.write(time, message, gui.tabs.HIGHACTION)

    else:
        tab.nickList.remove_nick(who)

        if tab.is_active():
            gui.mgmt.set_user_count(len(tab.nickList),
                                    tab.nickList.get_operator_count())

        if _show_output_exclusive(server_tab, tab, "kick"):

            whoString = "<font foreground='%s' weight='bold'>%s</font>" % (
                color.get_nick_color(who), markup.escape(who))

            message = _(u"« %(who)s was kicked from %(channel)s by "
                        u"%(nick)s (%(reason)s).") % {
                            "who": whoString,
                            "channel": channelString,
                            "nick": nickString,
                            "reason": reasonString
                        }

            tab.write(time, message, gui.tabs.ACTION)
Beispiel #12
0
def userKick_cb(time, server, from_str, channel, who, reason):
    """
		signal emitted if a user got kicked.
		If the kicked user is ourself mark the channel as
		joined=False
	"""
    nick = parse_from(from_str)[0]
    server_tab, tab = gui.tabs.search_tabs(server, channel)

    if not tab:
        logging.debug("userKick: channel '%s' does not exist." % (channel))
        return

    channelString = markup.escape(channel)

    nickString = "<font foreground='%s' weight='bold'>%s</font>" % (action_nick_color(nick), markup.escape(nick))

    reasonString = markup.escape(reason)

    if who == server_tab.nick:
        tab.joined = False

        if _show_output_exclusive(server_tab, tab, "kick", own=True):

            message = _(
                u"« You have been kicked from %(channel)s "
                u"by %(nick)s (%(reason)s)." % {"channel": channelString, "nick": nickString, "reason": reasonString}
            )

            tab.write(time, message, gui.tabs.HIGHACTION)

    else:
        tab.nickList.remove_nick(who)

        if tab.is_active():
            gui.mgmt.set_user_count(len(tab.nickList), tab.nickList.get_operator_count())

        if _show_output_exclusive(server_tab, tab, "kick"):

            whoString = "<font foreground='%s' weight='bold'>%s</font>" % (
                color.get_nick_color(who),
                markup.escape(who),
            )

            message = _(u"« %(who)s was kicked from %(channel)s by " u"%(nick)s (%(reason)s).") % {
                "who": whoString,
                "channel": channelString,
                "nick": nickString,
                "reason": reasonString,
            }

            tab.write(time, message, gui.tabs.ACTION)
Beispiel #13
0
	def whois_cb(time, server, nick, message):
		""" message = "" => end of whois """

		server_tab = gui.tabs.search_tab(server)

		if message:
			server_tab.write(time,
				_(u"[%(nick)s] %(message)s") % {
					"nick": markup.escape(nick),
					"message": markup.escape(message) })
		else:
			server_tab.write(time,
				_(u"[%(nick)s] End of whois.") % {
					"nick": markup.escape(nick) })
Beispiel #14
0
def userAction_cb(time, server, from_str, channel, action):
    """ normal action """

    nick = parse_from(from_str)[0]
    (server_tab, channel_tab) = gui.tabs.search_tabs(server, channel)

    if nick.lower() == server_tab.nick.lower():
        ownAction_cb(time, server, channel, action)
        return

    elif channel.lower() == server_tab.nick.lower():
        actionQuery_cb(time, server, from_str, action)
        return

    action = markup.escape(action)

    if isHighlighted(server_tab, action):
        type = gui.tabs.HIGHACTION
        actionString = action
        gui.mgmt.set_urgent(True)

    else:
        type = gui.tabs.ACTION
        actionString = "<font foreground='%s'>%s</font>" % (color.get_text_color(nick), action)

    channel_tab.write(
        time,
        "<font foreground='%s' weight='bold'>%s</font> %s" % (color.get_nick_color(nick), nick, actionString),
        type,
        group_string=nick,
    )
Beispiel #15
0
def channelTopic_cb(time, server, from_str, channel, topic):
    """
		The topic was set on server "server" in channel "channel" by
		user "nick" to "topic".
		Apply this!
	"""
    nick = parse_from(from_str)[0]
    serverTab, channelTab = gui.tabs.search_tabs(server, channel)

    if not channelTab:
        raise Exception("Channel %s does not exist but "
                        "emits topic signal." % channel)

    channelTab.topic = topic
    channelTab.topicsetter = nick

    if channelTab == gui.tabs.get_current_tab():
        gui.mgmt.set_topic(markup.markup_escape(topic))

    if not nick:
        # just reporting the topic.
        _report_topic(time, server, channel, topic)

    else:
        if nick == serverTab.nick:
            message = _(u"• You changed the topic to %(topic)s.")
        else:
            message = _(u"• %(nick)s changed the topic to %(topic)s.")

        channelTab.write(
            time, message % {
                "nick": nick,
                "topic": markup.escape(topic)
            }, gui.tabs.ACTION)
Beispiel #16
0
def noSuch(time, server, target, type):
    """ Signal is emitted if maki can't find the target on the server. """

    (server_tab, tab) = gui.tabs.search_tabs(server, target)

    if type == "nick":
        error = _(u"• %(target)s: No such nick/channel.") % {"target": markup.escape(target)}
    elif type == "server":
        error = _(u"• %(target)s: No such server.") % {"target": markup.escape(target)}
    elif type == "channel":
        error = _(u"• %(target)s: No such channel.") % {"target": markup.escape(target)}

    if tab:
        tab.write(time, error)
    else:
        server_tab.write(time, error)
Beispiel #17
0
def channelTopic_cb(time, server, from_str, channel, topic):
    """
		The topic was set on server "server" in channel "channel" by
		user "nick" to "topic".
		Apply this!
	"""
    nick = parse_from(from_str)[0]
    serverTab, channelTab = gui.tabs.search_tabs(server, channel)

    if not channelTab:
        raise Exception("Channel %s does not exist but " "emits topic signal." % channel)

    channelTab.topic = topic
    channelTab.topicsetter = nick

    if channelTab == gui.tabs.get_current_tab():
        gui.mgmt.set_topic(markup.markup_escape(topic))

    if not nick:
        # just reporting the topic.
        _report_topic(time, server, channel, topic)

    else:
        if nick == serverTab.nick:
            message = _(u"• You changed the topic to %(topic)s.")
        else:
            message = _(u"• %(nick)s changed the topic to %(topic)s.")

        channelTab.write(time, message % {"nick": nick, "topic": markup.escape(topic)}, gui.tabs.ACTION)
Beispiel #18
0
def serverMOTD_cb(time, server, message, first_time={}):
    """ Server is sending a MOTD.
		Channes are joined 3s after the end of the
		MOTD so at the end of the MOTD, make sure
		that the prefixes and chantypes are read
		correctly.
	"""
    if not first_time.has_key(server):
        tab = gui.tabs.search_tab(server)

        if not tab:
            tab = _setup_server(server)
        else:
            tab.update()

        gui.status.unset("connecting")
        tab.connected = True
        first_time[server] = tab

    if not message:
        # get the prefixes for the server to make
        # sure they are correct
        tab = first_time[server]
        tab.support_prefix = sushi.support_prefix(server)
        tab.support_chantypes = sushi.support_chantypes(server)
        del first_time[server]

    else:
        first_time[server].write(time, markup.escape(message), no_general_output=True)
Beispiel #19
0
def userAwayMessage_cb(timestamp, server, nick, message):
    """
		The user is away and the server gives us the message he left
		for us to see why he is away and probably when he's back again.
	"""
    tab = gui.tabs.get_current_tab()

    # XXX:  you can still write /msg <nick> and get an away message
    # XXX:: in the query window. This would be a more complex fix.
    try:
        tab.printed_away_message
    except AttributeError:
        print_it = True
    else:
        print_it = not tab.printed_away_message

    if print_it:
        tab.write(
            timestamp,
            _(u"• %(nick)s is away (%(message)s).") % {"nick": nick, "message": markup.escape(message)},
            gui.tabs.ACTION,
        )

        if tab and tab.name == nick:
            tab.printed_away_message = True
Beispiel #20
0
def userAwayMessage_cb(timestamp, server, nick, message):
    """
		The user is away and the server gives us the message he left
		for us to see why he is away and probably when he's back again.
	"""
    tab = gui.tabs.get_current_tab()

    # XXX:  you can still write /msg <nick> and get an away message
    # XXX:: in the query window. This would be a more complex fix.
    try:
        tab.printed_away_message
    except AttributeError:
        print_it = True
    else:
        print_it = not tab.printed_away_message

    if print_it:
        tab.write(
            timestamp,
            _(u"• %(nick)s is away (%(message)s).") % {
                "nick": nick,
                "message": markup.escape(message)
            }, gui.tabs.ACTION)

        if tab and tab.name == nick:
            tab.printed_away_message = True
Beispiel #21
0
def userAction_cb(time, server, from_str, channel, action):
    """ normal action """

    nick = parse_from(from_str)[0]
    (server_tab, channel_tab) = gui.tabs.search_tabs(server, channel)

    if nick.lower() == server_tab.nick.lower():
        ownAction_cb(time, server, channel, action)
        return

    elif channel.lower() == server_tab.nick.lower():
        actionQuery_cb(time, server, from_str, action)
        return

    action = markup.escape(action)

    if isHighlighted(server_tab, action):
        type = gui.tabs.HIGHACTION
        actionString = action
        gui.mgmt.set_urgent(True)

    else:
        type = gui.tabs.ACTION
        actionString = "<font foreground='%s'>%s</font>" % (
            color.get_text_color(nick), action)

    channel_tab.write(time,
                      "<font foreground='%s' weight='bold'>%s</font> %s" %
                      (color.get_nick_color(nick), nick, actionString),
                      type,
                      group_string=nick)
Beispiel #22
0
def serverMOTD_cb(time, server, message, first_time={}):
    """ Server is sending a MOTD.
		Channes are joined 3s after the end of the
		MOTD so at the end of the MOTD, make sure
		that the prefixes and chantypes are read
		correctly.
	"""
    if not first_time.has_key(server):
        tab = gui.tabs.search_tab(server)

        if not tab:
            tab = _setup_server(server)
        else:
            tab.update()

        gui.status.unset("connecting")
        tab.connected = True
        first_time[server] = tab

    if not message:
        # get the prefixes for the server to make
        # sure they are correct
        tab = first_time[server]
        tab.support_prefix = sushi.support_prefix(server)
        tab.support_chantypes = sushi.support_chantypes(server)
        del first_time[server]

    else:
        first_time[server].write(time,
                                 markup.escape(message),
                                 no_general_output=True)
Beispiel #23
0
def userMessage_cb(timestamp, server, from_str, channel, message):
    """
		PRIVMSGs are coming in here.
	"""
    nick = parse_from(from_str)[0]
    (server_tab, channel_tab) = gui.tabs.search_tabs(server, channel)

    if server_tab == None:
        return  # happens if the target server does not exist

    if nick.lower() == server_tab.nick.lower():
        ownMessage_cb(timestamp, server, channel, message)
        return

    elif channel.lower() == server_tab.nick.lower():
        userQuery_cb(timestamp, server, from_str, message)
        return

    message = markup.escape(message)

    if isHighlighted(server_tab, message):
        # set mode to highlight and disable setting
        # of text color for the main message (would
        # override channelPrint() highlight color)

        type = gui.tabs.HIGHMESSAGE
        messageString = message
        gui.mgmt.set_urgent(True)
    else:
        # no highlight, normal message type and
        # text color is allowed.

        type = gui.tabs.MESSAGE
        messageString = "<font foreground='%s'>%s</font>" % (
            color.get_text_color(nick), message)

    channel_tab.write(
        timestamp,
        "&lt;%s<font foreground='%s' weight='bold'>%s</font>&gt; %s" % (
            _getPrefix(server, channel, nick),
            color.get_nick_color(nick),
            markup.escape(nick),
            messageString,
        ),
        type,
        group_string=nick)
Beispiel #24
0
	def channelList_cb(time, server, channel, users, topic):
		""" Signal for /list command.
			Prints content of the listing.
		"""

		self = code.init_function_attrs(channelList_cb,
			_text=[],
			_line=0,
			_tab=gui.tabs.search_tab(server))

		def print_listing():
			self._tab.write_raw("<br/>".join(self._text))

			self._text = []
			self._line = 0
			return False

		if not channel and not topic and users == -1:
			# listing ended, reset variables

			def print_end():
				self._tab.write(time, "End of list.")
				return False

			if self._line > 0:
				# print rest
				gobject.idle_add(print_listing)

			gobject.idle_add(print_end)

			code.reset_function_attrs(channelList_cb)

			signals.disconnect_signal("list", channelList_cb)

		else:
			self._text.append(("• <b>%s</b><br/>\t%d "+_("User")+"<br/>"+
								"\t"+_("Topic")+": \"%s\"") % (
									markup.escape(channel),
									users,
									markup.escape(topic)))
			self._line += 1

			if self._line == 10:

				gobject.idle_add(print_listing)
Beispiel #25
0
def channelBanlist_cb(time, server, channel, mask, who, when):
    """
		ban list signal.
	"""
    self = code.init_function_attrs(channelBanlist_cb,
                                    tab=gui.tabs.search_tab(server, channel))

    if not mask and not who and when == -1:
        self.tab.write(time, "End of banlist.", gui.tabs.ACTION)
        code.reset_function_attrs(channelBanlist_cb)

    else:
        timestring = mtime.strftime("%Y-%m-%d %H:%M:%S", mtime.localtime(when))

        self.tab.write(
            time, "%s by %s on %s" % (markup.escape(mask), markup.escape(who),
                                      markup.escape(timestring)),
            gui.tabs.ACTION)
Beispiel #26
0
def channelBanlist_cb(time, server, channel, mask, who, when):
    """
		ban list signal.
	"""
    self = code.init_function_attrs(channelBanlist_cb, tab=gui.tabs.search_tab(server, channel))

    if not mask and not who and when == -1:
        self.tab.write(time, "End of banlist.", gui.tabs.ACTION)
        code.reset_function_attrs(channelBanlist_cb)

    else:
        timestring = mtime.strftime("%Y-%m-%d %H:%M:%S", mtime.localtime(when))

        self.tab.write(
            time,
            "%s by %s on %s" % (markup.escape(mask), markup.escape(who), markup.escape(timestring)),
            gui.tabs.ACTION,
        )
Beispiel #27
0
def userNick_cb(time, server, from_str, newNick):
    """
	A user (or the maki user) changed it's nick.
	If a query window for this nick on this server
	exists, it's name would be changed.
	"""
    nick = parse_from(from_str)[0]

    # find a query
    server_tab, tab = gui.tabs.search_tabs(server, nick)

    # rename query if found
    if tab and tab.is_query():
        tab.name = newNick

    own = False

    # we changed the nick
    if not nick or nick == server_tab.nick:
        message = _(u"• You are now known as %(newnick)s.")
        server_tab.nick = newNick
        own = True

        # someone else did
    else:
        message = _(u"• %(nick)s is now known as %(newnick)s.")

        # iterate over all channels and look if the nick is
        # present there. If true so rename him in nicklist cache.
    for tab in gui.tabs.get_all_tabs(servers=[server])[1:]:

        if not nick or newNick == server_tab.nick:
            # notification, print everytime
            doPrint = True
        else:
            doPrint = _show_output_exclusive(server_tab, tab, "nick", own)

        if tab.is_channel():
            if nick in tab.nickList.get_nicks():
                tab.nickList.modify_nick(nick, newNick)
            else:
                continue

        if tab.is_query() and tab.name != newNick:
            # ignore not associated queries
            continue

        nickString = "<font foreground='%s' weight='bold'>%s</font>" % (action_nick_color(nick), markup.escape(nick))

        newNickString = "<font foreground='%s' weight='bold'>%s</font>" % (
            action_nick_color(newNick),
            markup.escape(newNick),
        )

        if doPrint:
            tab.write(time, message % {"nick": nickString, "newnick": newNickString}, gui.tabs.ACTION)
Beispiel #28
0
def actionQuery_cb(time, server, from_str, action):
    """ action in a query """

    nick = parse_from(from_str)[0]

    tab = _createTab(server, nick)

    tab.write(time, "%s %s" % (nick, markup.escape(action)), group_string=nick)

    gui.mgmt.set_urgent(True)
Beispiel #29
0
def actionQuery_cb(time, server, from_str, action):
    """ action in a query """

    nick = parse_from(from_str)[0]

    tab = _createTab(server, nick)

    tab.write(time, "%s %s" % (nick, markup.escape(action)), group_string=nick)

    gui.mgmt.set_urgent(True)
Beispiel #30
0
def userMessage_cb(timestamp, server, from_str, channel, message):
    """
		PRIVMSGs are coming in here.
	"""
    nick = parse_from(from_str)[0]
    (server_tab, channel_tab) = gui.tabs.search_tabs(server, channel)

    if server_tab == None:
        return  # happens if the target server does not exist

    if nick.lower() == server_tab.nick.lower():
        ownMessage_cb(timestamp, server, channel, message)
        return

    elif channel.lower() == server_tab.nick.lower():
        userQuery_cb(timestamp, server, from_str, message)
        return

    message = markup.escape(message)

    if isHighlighted(server_tab, message):
        # set mode to highlight and disable setting
        # of text color for the main message (would
        # override channelPrint() highlight color)

        type = gui.tabs.HIGHMESSAGE
        messageString = message
        gui.mgmt.set_urgent(True)
    else:
        # no highlight, normal message type and
        # text color is allowed.

        type = gui.tabs.MESSAGE
        messageString = "<font foreground='%s'>%s</font>" % (color.get_text_color(nick), message)

    channel_tab.write(
        timestamp,
        "&lt;%s<font foreground='%s' weight='bold'>%s</font>&gt; %s"
        % (_getPrefix(server, channel, nick), color.get_nick_color(nick), markup.escape(nick), messageString),
        type,
        group_string=nick,
    )
Beispiel #31
0
def _report_topic(time, server, channel, topic):
    message = _(u"• Topic for %(channel)s: %(topic)s") % {
        "channel": channel,
        "topic": markup.escape(topic)
    }

    tab = gui.tabs.search_tab(server, channel)

    if not tab:
        raise Exception, "%s:%s not found." % (server, channel)

    tab.write(time, message, gui.tabs.ACTION, no_general_output=True)
Beispiel #32
0
def queryCTCP_cb(time, server, from_str, message):
    """
		A user sends us a CTCP request over a query.

		If no query window is open, send it to the server tab.
	"""
    nick = parse_from(from_str)[0]
    (server_tab, tab) = gui.tabs.search_tabs(server, nick)

    if tab:
        tab.write(
            time, "&lt;CTCP:<font foreground='%s' weight='bold'>%s"
            "</font>&gt; <font foreground='%s'>%s</font>" %
            (color.get_nick_color(nick), markup.escape(nick),
             color.get_text_color(nick), markup.escape(message)))
    else:
        server_tab.current_write(
            time, "&lt;CTCP:<font foreground='%s' weight='bold'>%s"
            "</font>&gt; <font foreground='%s'>%s</font>" %
            (color.get_nick_color(nick), markup.escape(nick),
             color.get_text_color(nick), markup.escape(message)))
Beispiel #33
0
def noSuch(time, server, target, type):
    """ Signal is emitted if maki can't find the target on the server. """

    (server_tab, tab) = gui.tabs.search_tabs(server, target)

    if type == "nick":
        error = _(u"• %(target)s: No such nick/channel.") % {
            "target": markup.escape(target)
        }
    elif type == "server":
        error = _(u"• %(target)s: No such server.") % {
            "target": markup.escape(target)
        }
    elif type == "channel":
        error = _(u"• %(target)s: No such channel.") % {
            "target": markup.escape(target)
        }

    if tab:
        tab.write(time, error)
    else:
        server_tab.write(time, error)
Beispiel #34
0
def ownAction_cb(time, server, channel, action):

    tab = _createTab(server, channel)
    nick = gui.tabs.search_tab(server).nick

    nickColor = color.get_color_by_key("own_nick")
    textColor = color.get_color_by_key("own_text")

    tab.write(time,
              "<font foreground='%s' weight='bold'>%s</font> "
              "<font foreground='%s'>%s</font>" %
              (nickColor, nick, textColor, markup.escape(action)),
              group_string=nick)
Beispiel #35
0
def userQuery_cb(timestamp, server, from_str, message):
    """
		A user writes to us in a query.
	"""
    nick = parse_from(from_str)[0]

    tab = _createTab(server, nick)

    if isHighlighted(tab.server, message):
        mtype = gui.tabs.HIGHMESSAGE
    else:
        mtype = gui.tabs.MESSAGE

    tab.write(timestamp,
              "&lt;<font foreground='%s' weight='bold'>%s</font>&gt; %s" %
              (color.get_nick_color(nick), markup.escape(nick),
               markup.escape(message)),
              mtype,
              group_string=nick)

    # queries are important
    gui.mgmt.set_urgent(True)
Beispiel #36
0
def ownMessage_cb(timestamp, server, channel, message):
    """
		The maki user wrote something on a channel or a query
	"""
    tab = _createTab(server, channel)
    nick = gui.tabs.search_tab(server).nick

    tab.write(
        timestamp,
        "&lt;%s<font foreground='%s' weight='bold'>%s</font>&gt;"
        " <font foreground='%s'>%s</font>" %
        (_getPrefix(server, channel, nick), color.get_color_by_key("own_nick"),
         nick, color.get_color_by_key("own_text"), markup.escape(message)),
        group_string=nick)
Beispiel #37
0
def userQuery_cb(timestamp, server, from_str, message):
    """
		A user writes to us in a query.
	"""
    nick = parse_from(from_str)[0]

    tab = _createTab(server, nick)

    if isHighlighted(tab.server, message):
        mtype = gui.tabs.HIGHMESSAGE
    else:
        mtype = gui.tabs.MESSAGE

    tab.write(
        timestamp,
        "&lt;<font foreground='%s' weight='bold'>%s</font>&gt; %s"
        % (color.get_nick_color(nick), markup.escape(nick), markup.escape(message)),
        mtype,
        group_string=nick,
    )

    # queries are important
    gui.mgmt.set_urgent(True)
Beispiel #38
0
def queryCTCP_cb(time, server, from_str, message):
    """
		A user sends us a CTCP request over a query.

		If no query window is open, send it to the server tab.
	"""
    nick = parse_from(from_str)[0]
    (server_tab, tab) = gui.tabs.search_tabs(server, nick)

    if tab:
        tab.write(
            time,
            "&lt;CTCP:<font foreground='%s' weight='bold'>%s"
            "</font>&gt; <font foreground='%s'>%s</font>"
            % (color.get_nick_color(nick), markup.escape(nick), color.get_text_color(nick), markup.escape(message)),
        )
    else:
        server_tab.current_write(
            time,
            "&lt;CTCP:<font foreground='%s' weight='bold'>%s"
            "</font>&gt; <font foreground='%s'>%s</font>"
            % (color.get_nick_color(nick), markup.escape(nick), color.get_text_color(nick), markup.escape(message)),
        )
Beispiel #39
0
def ownAction_cb(time, server, channel, action):

    tab = _createTab(server, channel)
    nick = gui.tabs.search_tab(server).nick

    nickColor = color.get_color_by_key("own_nick")
    textColor = color.get_color_by_key("own_text")

    tab.write(
        time,
        "<font foreground='%s' weight='bold'>%s</font> "
        "<font foreground='%s'>%s</font>" % (nickColor, nick, textColor, markup.escape(action)),
        group_string=nick,
    )
Beispiel #40
0
def ownNotice_cb(time, server, target, message):
    """
		if query channel with ``target`` exists, print
		the notice there, else print it on the current
		channel of the network which is identified by
		`server`
	"""
    server_tab, tab = gui.tabs.search_tabs(server, target)
    ownNickColor = color.get_color_by_key("own_nick")
    ownNick = server_tab.nick

    if tab:
        tab.write(
            time, "&gt;<font foreground='%s' weight='bold'>%s</font>&lt; "
            "<font foreground='%s'>%s</font>" %
            (color.get_nick_color(target), markup.escape(target),
             color.get_text_color(target), markup.escape(message)))
    else:
        server_tab.current_write(
            time, "&gt;<font foreground='%s' weight='bold'>%s</font>&lt; "
            "<font foreground='%s'>%s</font>" %
            (color.get_nick_color(target), markup.escape(target),
             color.get_text_color(target), markup.escape(message)))
Beispiel #41
0
def ownMessage_cb(timestamp, server, channel, message):
    """
		The maki user wrote something on a channel or a query
	"""
    tab = _createTab(server, channel)
    nick = gui.tabs.search_tab(server).nick

    tab.write(
        timestamp,
        "&lt;%s<font foreground='%s' weight='bold'>%s</font>&gt;"
        " <font foreground='%s'>%s</font>"
        % (
            _getPrefix(server, channel, nick),
            color.get_color_by_key("own_nick"),
            nick,
            color.get_color_by_key("own_text"),
            markup.escape(message),
        ),
        group_string=nick,
    )
Beispiel #42
0
def userCTCP_cb(time, server, from_str, target, message):
    """
		A user sends a CTCP request to target.
		I don't know a case in which target is not a channel
		and not queried.
	"""
    nick = parse_from(from_str)[0]
    (server_tab, target_tab) = gui.tabs.search_tabs(server, target)

    if nick.lower() == server_tab.nick.lower():
        # we wrote us
        ownCTCP_cb(time, server, target, message)

    elif target.lower() == server_tab.nick.lower():
        # someone wrote us, put in into a query
        queryCTCP_cb(time, server, from_str, message)

    else:
        # normal ctcp
        headline = _("CTCP from %(nick)s to Channel:") % {"nick": markup.escape(nick)}

        target_tab.write(time, "<font foreground='#00DD33'>%s</font> %s" % (headline, markup.escape(message)))
Beispiel #43
0
def userQuit_cb(time, server, from_str, reason):
    """
	The user identified by nick quit on the server "server" with
	the reason "reason". "reason" can be empty ("").
	If we are the user all channels were set to joined=False and
	the server's connected-flag is set to False (as well as the
	connect-flags of the childs).

	If another user quits on all channels on which the user was on
	a message is generated.
	"""
    server_tab = gui.tabs.search_tab(server)
    nick = parse_from(from_str)[0]

    if not server_tab:
        # tab was closed before
        return

    if nick == server_tab.nick:
        # set the connected flag to False for the server

        server_tab.connected = False

        hideServerPrint = _hide_output(server_tab, "quit", own=True)

        # walk through all channels and set joined = False on them
        channels = gui.tabs.get_all_tabs(servers=[server])[1:]

        if reason:
            message = _(u"« You have quit (%(reason)s).")
        else:
            message = _(u"« You have quit.")

            # deactivate channels/queries
        for channelTab in channels:

            hideChannelPrint = _hide_output(channelTab, "quit", own=True)

            if channelTab.is_channel():
                channelTab.joined = False

            channelTab.connected = False

            if not (hideServerPrint or hideChannelPrint):
                channelTab.write(time, message % {"reason": reason}, gui.tabs.ACTION)

    else:  # another user quit the network

        hideServerPrint = _hide_output(server_tab, "quit")

        if reason:
            message = _(u"« %(nick)s has quit (%(reason)s).")
        else:
            message = _(u"« %(nick)s has quit.")

        nickString = "<font foreground='%s' weight='bold'>" "%s</font>" % (action_nick_color(nick), markup.escape(nick))

        reasonString = markup.escape(reason)

        message = message % {"nick": nickString, "reason": reasonString}

        channels = gui.tabs.get_all_tabs(servers=[server])[1:]

        if not channels:
            logging.debug("No channels but quit reported.. Hum wtf? o.0")
            return

            # print in all channels where nick joined a message
        for channelTab in channels:

            hideChannelPrint = _hide_output(channelTab, "quit")

            if channelTab.is_query():
                # on query with `nick` only print quitmessage

                if not (hideChannelPrint or hideServerPrint) and channelTab.name.lower() == nick.lower():
                    channelTab.write(time, message, gui.tabs.ACTION)

                    # skip nickList modification for queries
                continue

                # search for the nick in the channel
                # and print the quit message if the
                # nick was found.
            nickList = channelTab.nickList
            nicks = nickList.get_nicks() or []

            if nick in nicks:
                nickList.remove_nick(nick)

                if channelTab.is_active():
                    # update gui display for usercount
                    gui.mgmt.set_user_count(len(nickList), nickList.get_operator_count())

                if not (hideServerPrint or hideChannelPrint):
                    channelTab.write(time, message, gui.tabs.ACTION)
Beispiel #44
0
def userPart_cb(timestamp, server, from_str, channel, reason):
    """
	A user parted the channel.

	If we are the user who parted, mark the channel
	as parted (joined=False)
	"""
    nick = parse_from(from_str)[0]

    stab, tab = gui.tabs.search_tabs(server, channel)

    if not tab:
        # tab was closed
        return

    channelString = markup.escape(channel)
    reasonString = markup.escape(reason)

    if nick == stab.nick:
        # we parted

        tab.joined = False

        if _show_output_exclusive(stab, tab, "part", own=True):

            if reason:
                message = _(u"« You have left %(channel)s (%(reason)s).")
            else:
                message = _(u"« You have left %(channel)s.")

            tab.write(
                timestamp, message % {
                    "channel": channelString,
                    "reason": reasonString
                }, gui.tabs.ACTION)

    else:  # another user parted

        tab.nickList.remove_nick(nick)

        if tab.is_active():
            gui.mgmt.set_user_count(len(tab.nickList),
                                    tab.nickList.get_operator_count())

        if _show_output_exclusive(stab, tab, "part", False):

            nickString = "<font foreground='%s' weight='bold'>"\
             "%s</font>" % (
             color.get_nick_color(nick), markup.escape(nick))

            if reason:
                message = _(u"« %(nick)s has left %(channel)s "\
                 "(%(reason)s).")
            else:
                message = _(u"« %(nick)s has left %(channel)s.")

            tab.write(
                timestamp, message % {
                    "nick": nickString,
                    "channel": channelString,
                    "reason": reasonString
                }, gui.tabs.ACTION)
Beispiel #45
0
def userJoin_cb(timestamp, server, from_str, channel):
    """
	A user identified by "nick" joins the channel "channel" on
	server "server.

	If the nick is our we add the channeltab and set properties
	on it, else we generate messages and stuff.
	"""
    nick = parse_from(from_str)[0]
    stab, tab = gui.tabs.search_tabs(server, channel)
    doPrint = False

    if nick == stab.nick:
        # we joined a channel, fetch nicks and topic, create
        # channel and print the log

        if not tab:
            tab = gui.tabs.create_channel(stab, channel)

            if not gui.tabs.add_tab(stab, tab):
                raise Exception, "userJoin_cb: adding tab for channel '%s' failed." % (channel)

            tab.print_last_log()

        tab.nickList.clear()

        if tab.is_active():
            gui.mgmt.set_user_count(len(tab.nickList), tab.nickList.get_operator_count())

        tab.joined = True
        tab.connected = True

        if config.get_bool("tekka", "switch_to_channel_after_join"):
            gui.tabs.switch_to_path(tab.path)

        doPrint = _show_output_exclusive(stab, tab, "join", own=True)

        if doPrint:

            nickString = "You"
            message = _(u"» You have joined %(channel)s.")

    else:  # another one joined the channel

        if not tab:
            raise Exception, "No tab for channel '%s' in userJoin (not me)."

        doPrint = _show_output_exclusive(stab, tab, "join", own=False)

        if doPrint:
            message = _(u"» %(nick)s has joined %(channel)s.")
            nickString = "<font foreground='%s' weight='bold'>" "%s</font>" % (
                action_nick_color(nick),
                markup.escape(nick),
            )

        tab.nickList.append_nick(nick)

        if tab.is_active():
            gui.mgmt.set_user_count(len(tab.nickList), tab.nickList.get_operator_count())

    if doPrint:
        message = message % {"nick": nickString, "channel": markup.escape(channel)}

        tab.write(timestamp, message, gui.tabs.ACTION)
Beispiel #46
0
def userJoin_cb(timestamp, server, from_str, channel):
    """
	A user identified by "nick" joins the channel "channel" on
	server "server.

	If the nick is our we add the channeltab and set properties
	on it, else we generate messages and stuff.
	"""
    nick = parse_from(from_str)[0]
    stab, tab = gui.tabs.search_tabs(server, channel)
    doPrint = False

    if nick == stab.nick:
        # we joined a channel, fetch nicks and topic, create
        # channel and print the log

        if not tab:
            tab = gui.tabs.create_channel(stab, channel)

            if not gui.tabs.add_tab(stab, tab):
                raise Exception, \
                 "userJoin_cb: adding tab for channel '%s' failed." % (
                 channel)

            tab.print_last_log()

        tab.nickList.clear()

        if tab.is_active():
            gui.mgmt.set_user_count(len(tab.nickList),
                                    tab.nickList.get_operator_count())

        tab.joined = True
        tab.connected = True

        if config.get_bool("tekka", "switch_to_channel_after_join"):
            gui.tabs.switch_to_path(tab.path)

        doPrint = _show_output_exclusive(stab, tab, "join", own=True)

        if doPrint:

            nickString = "You"
            message = _(u"» You have joined %(channel)s.")

    else:  # another one joined the channel

        if not tab:
            raise Exception, \
             "No tab for channel '%s' in userJoin (not me)."

        doPrint = _show_output_exclusive(stab, tab, "join", own=False)

        if doPrint:
            message = _(u"» %(nick)s has joined %(channel)s.")
            nickString = "<font foreground='%s' weight='bold'>"\
             "%s</font>" % (
              action_nick_color(nick),
              markup.escape(nick))

        tab.nickList.append_nick(nick)

        if tab.is_active():
            gui.mgmt.set_user_count(len(tab.nickList),
                                    tab.nickList.get_operator_count())

    if doPrint:
        message = message % {
            "nick": nickString,
            "channel": markup.escape(channel)
        }

        tab.write(timestamp, message, gui.tabs.ACTION)
Beispiel #47
0
def userQuit_cb(time, server, from_str, reason):
    """
	The user identified by nick quit on the server "server" with
	the reason "reason". "reason" can be empty ("").
	If we are the user all channels were set to joined=False and
	the server's connected-flag is set to False (as well as the
	connect-flags of the childs).

	If another user quits on all channels on which the user was on
	a message is generated.
	"""
    server_tab = gui.tabs.search_tab(server)
    nick = parse_from(from_str)[0]

    if not server_tab:
        # tab was closed before
        return

    if nick == server_tab.nick:
        # set the connected flag to False for the server

        server_tab.connected = False

        hideServerPrint = _hide_output(server_tab, "quit", own=True)

        # walk through all channels and set joined = False on them
        channels = gui.tabs.get_all_tabs(servers=[server])[1:]

        if reason:
            message = _(u"« You have quit (%(reason)s).")
        else:
            message = _(u"« You have quit.")

        # deactivate channels/queries
        for channelTab in channels:

            hideChannelPrint = _hide_output(channelTab, "quit", own=True)

            if channelTab.is_channel():
                channelTab.joined = False

            channelTab.connected = False

            if not (hideServerPrint or hideChannelPrint):
                channelTab.write(time, message % {"reason": reason},
                                 gui.tabs.ACTION)

    else:  # another user quit the network

        hideServerPrint = _hide_output(server_tab, "quit")

        if reason:
            message = _(u"« %(nick)s has quit (%(reason)s).")
        else:
            message = _(u"« %(nick)s has quit.")

        nickString = "<font foreground='%s' weight='bold'>"\
         "%s</font>" % (
          action_nick_color(nick),
          markup.escape(nick))

        reasonString = markup.escape(reason)

        message = message % {"nick": nickString, "reason": reasonString}

        channels = gui.tabs.get_all_tabs(servers=[server])[1:]

        if not channels:
            logging.debug("No channels but quit reported.. Hum wtf? o.0")
            return

        # print in all channels where nick joined a message
        for channelTab in channels:

            hideChannelPrint = _hide_output(channelTab, "quit")

            if channelTab.is_query():
                # on query with `nick` only print quitmessage

                if (not (hideChannelPrint or hideServerPrint)
                        and channelTab.name.lower() == nick.lower()):
                    channelTab.write(time, message, gui.tabs.ACTION)

                # skip nickList modification for queries
                continue

            # search for the nick in the channel
            # and print the quit message if the
            # nick was found.
            nickList = channelTab.nickList
            nicks = nickList.get_nicks() or []

            if nick in nicks:
                nickList.remove_nick(nick)

                if channelTab.is_active():
                    # update gui display for usercount
                    gui.mgmt.set_user_count(len(nickList),
                                            nickList.get_operator_count())

                if not (hideServerPrint or hideChannelPrint):
                    channelTab.write(time, message, gui.tabs.ACTION)
Beispiel #48
0
def _report_topic(time, server, channel, topic):
    message = _(u"• Topic for %(channel)s: %(topic)s") % {"channel": channel, "topic": markup.escape(topic)}

    tab = gui.tabs.search_tab(server, channel)

    if not tab:
        raise Exception, "%s:%s not found." % (server, channel)

    tab.write(time, message, gui.tabs.ACTION, no_general_output=True)