Exemplo n.º 1
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)
Exemplo n.º 2
0
def userAway_cb(time, server, from_str, away):
    nick = parse_from(from_str)[0]
    server_tab = gui.tabs.search_tab(server)

    if not server_tab:
        return

    if nick == server_tab.nick:
        if away:
            server_tab.away = "-- Not implemented yet --"
        else:
            server_tab.away = ""

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

        if tab.is_channel():
            if nick in tab.nickList.get_nicks():
                tab.nickList.set_away(nick, away)

        elif tab.is_query():
            if tab.name == nick:
                # FIXME
                continue
Exemplo n.º 3
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)
Exemplo n.º 4
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)),
        )
Exemplo n.º 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)))
Exemplo n.º 6
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)))
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
0
def userAway_cb(time, server, from_str, away):
    nick = parse_from(from_str)[0]
    server_tab = gui.tabs.search_tab(server)

    if not server_tab:
        return

    if nick == server_tab.nick:
        if away:
            server_tab.away = "-- Not implemented yet --"
        else:
            server_tab.away = ""

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

        if tab.is_channel():
            if nick in tab.nickList.get_nicks():
                tab.nickList.set_away(nick, away)

        elif tab.is_query():
            if tab.name == nick:
                # FIXME
                continue
Exemplo n.º 11
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,
    )
Exemplo n.º 12
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)
Exemplo n.º 13
0
    def _message_cb(self, time, server, from_str, target, msg):

        if com.parse_from(from_str)[0] == self.get_nick(server):
            return

        if (self.get_config("beep_%s" %
                            (tab_id_str(server, target))) == "True"):

            self.beep()
Exemplo n.º 14
0
	def _message_cb(self, time, server, from_str, target, msg):

		if com.parse_from(from_str)[0] == self.get_nick(server):
			return

		if (self.get_config(
				"beep_%s" % (tab_id_str(server, target))) == "True"):

			self.beep()
Exemplo n.º 15
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,
            )
Exemplo n.º 16
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)
Exemplo n.º 17
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)
Exemplo n.º 18
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)
Exemplo n.º 19
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)
Exemplo n.º 20
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)
Exemplo n.º 21
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)
Exemplo n.º 22
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,
    )
Exemplo n.º 23
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)))
Exemplo n.º 24
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)
Exemplo n.º 25
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)))
Exemplo n.º 26
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)
Exemplo n.º 27
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)),
        )
Exemplo n.º 28
0
def dcc_send_cb(time, id, server, sender, filename, size, progress, speed, status):
    """
	status:
	- 1 << 0 = incoming
	- 1 << 1 = resumed
	- 1 << 2 = running
	- 1 << 3 = error

	"" in (server, sender, filename)
		and 0 in (size, progress, speed, status):
	send was removed
	"""

    def dcc_dialog_response_cb(dialog, id, tid):
        if id == gtk.RESPONSE_OK:
            sushi.dcc_send_accept(tid)
        elif id == gtk.RESPONSE_CANCEL:
            sushi.dcc_send_remove(tid)
        dialog.destroy()

        # create dcc_news new-transfer-cache

    self = code.init_function_attrs(dcc_send_cb, dcc_news={}, dcc_notifies={})

    if server == "" and sender == "" and filename == "" and size == 0 and progress == 0 and speed == 0 and status == 0:

        # send was removed
        logging.debug("filetransfer %d removed." % (id))

        try:
            del self.dcc_news[id]
            del self.dcc_notifies[id]
        except KeyError:
            pass

        return

    logging.debug("status is %d." % (status))

    # import dcc transfer states
    from tekka.helper.dcc import s_new, s_incoming, s_resumable, s_running

    # handle incoming transfer
    if status & s_incoming == s_incoming:

        if status & s_new == s_new:
            # attempt made

            d = dcc_dialog.DCCDialog(
                id, parse_from(sender)[0], filename, size, resumable=(status & s_resumable == s_resumable)
            )

            self.dcc_news[id] = True

            d.connect("response", dcc_dialog_response_cb, id)
            gui.mgmt.show_inline_dialog(d)

        elif status & s_running and status & s_incoming:
            if not self.dcc_news.has_key(id) and not self.dcc_notifies.has_key(id):
                # notify about auto accepted file transfer
                gui.mgmt.show_inline_message(
                    _("Auto accepted file transfer"),
                    _(
                        "maki auto accepted the following file transfer:\n"
                        "Filename: %(filename)s\n"
                        "Sender: %(sender)s\n"
                        "Size: %(size)s\n"
                        "Server: %(server)s"
                        % {"filename": filename, "sender": parse_from(sender)[0], "size": size, "server": server}
                    ),
                    dtype="info",
                )

                self.dcc_notifies[id] = True
Exemplo n.º 29
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)
Exemplo n.º 30
0
def userMode_cb(time, server, from_str, target, mode, param):
    """
		Mode change on target from nick detected.
		nick and param are optional arguments and
		can be empty.

		As nemo:
			/mode #xesio +o nemo
		will result in:
			userMode(<time>,<server>,"nemo","#xesio","+o","nemo")
	"""

    def n_updatePrefix(tab, nick, mode):
        """ checks if the mode is a prefix-mode (e.g. +o)
			If so, the prefix of the nick `nick` in channel `channel`
			will be updated (fetched).
		"""
        if not nick:
            return

        if mode[1] in tab.server.support_prefix[0]:
            tab.nickList.set_prefix(nick, sushi.user_channel_prefix(tab.server.name, tab.name, nick))

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

    nick = parse_from(from_str)[0]

    # nick: /mode target +mode param
    server_tab = gui.tabs.search_tab(server)

    if not nick:
        # only a mode listing
        server_tab.current_write(
            time, _("• Modes for %(target)s: %(mode)s") % {"target": target, "mode": mode}, gui.tabs.ACTION
        )

    else:
        actor = nick
        own = nick == server_tab.nick

        if own:
            actor = "You"

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

        if not tab:
            # no channel/query found

            if param:
                param = " " + param

            if not _hide_output(server_tab, "mode"):

                actor = "<font foreground='%s'>%s</font>" % (action_nick_color(actor), actor)
                target = "<font foreground='%s'>%s</font>" % (action_nick_color(target), target)

                server_tab.current_write(
                    time,
                    "• %(actor)s set %(mode)s%(param)s on %(target)s"
                    % {"actor": actor, "mode": mode, "param": param, "target": target},
                    gui.tabs.ACTION,
                )
        else:
            # suitable channel/query found, print it there

            n_updatePrefix(tab, param, mode)

            type = gui.tabs.ACTION
            victim = target
            own = target == server_tab.nick

            if (param == server_tab.nick) or own:
                type = gui.tabs.HIGHACTION
            elif own:
                victim = "you"

            if param:
                param = " " + param

            if _show_output_exclusive(server_tab, tab, "mode", own=own):

                actor = "<font foreground='%s'>%s</font>" % (color.get_nick_color(actor), actor)
                victim = "<font foreground='%s'>%s</font>" % (color.get_nick_color(victim), victim)

                tab.write(
                    time,
                    "• %(actor)s set %(mode)s%(param)s on %(victim)s."
                    % {"actor": actor, "mode": mode, "param": param, "victim": victim},
                    type,
                )
Exemplo n.º 31
0
	def parse_from(self, host):
		return com.parse_from(host)
Exemplo n.º 32
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)
Exemplo n.º 33
0
def dcc_send_cb(time, id, server, sender, filename, size, progress, speed,
                status):
    """
	status:
	- 1 << 0 = incoming
	- 1 << 1 = resumed
	- 1 << 2 = running
	- 1 << 3 = error

	"" in (server, sender, filename)
		and 0 in (size, progress, speed, status):
	send was removed
	"""
    def dcc_dialog_response_cb(dialog, id, tid):
        if id == gtk.RESPONSE_OK:
            sushi.dcc_send_accept(tid)
        elif id == gtk.RESPONSE_CANCEL:
            sushi.dcc_send_remove(tid)
        dialog.destroy()

    # create dcc_news new-transfer-cache
    self = code.init_function_attrs(dcc_send_cb, dcc_news={}, dcc_notifies={})

    if (server == "" and sender == "" and filename == "" and size == 0
            and progress == 0 and speed == 0 and status == 0):

        # send was removed
        logging.debug("filetransfer %d removed." % (id))

        try:
            del self.dcc_news[id]
            del self.dcc_notifies[id]
        except KeyError:
            pass

        return

    logging.debug("status is %d." % (status))

    # import dcc transfer states
    from tekka.helper.dcc import s_new, s_incoming, s_resumable, s_running

    # handle incoming transfer
    if status & s_incoming == s_incoming:

        if status & s_new == s_new:
            # attempt made

            d = dcc_dialog.DCCDialog(id,
                                     parse_from(sender)[0],
                                     filename,
                                     size,
                                     resumable=(status
                                                & s_resumable == s_resumable))

            self.dcc_news[id] = True

            d.connect("response", dcc_dialog_response_cb, id)
            gui.mgmt.show_inline_dialog(d)

        elif status & s_running and status & s_incoming:
            if not self.dcc_news.has_key(id) and not self.dcc_notifies.has_key(
                    id):
                # notify about auto accepted file transfer
                gui.mgmt.show_inline_message(
                    _("Auto accepted file transfer"),
                    _(
                        "maki auto accepted the following file transfer:\n"
                        "Filename: %(filename)s\n"
                        "Sender: %(sender)s\n"
                        "Size: %(size)s\n"
                        "Server: %(server)s" % {
                            "filename": filename,
                            "sender": parse_from(sender)[0],
                            "size": size,
                            "server": server
                        }),
                    dtype="info")

                self.dcc_notifies[id] = True
Exemplo n.º 34
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)
Exemplo n.º 35
0
def userMode_cb(time, server, from_str, target, mode, param):
    """
		Mode change on target from nick detected.
		nick and param are optional arguments and
		can be empty.

		As nemo:
			/mode #xesio +o nemo
		will result in:
			userMode(<time>,<server>,"nemo","#xesio","+o","nemo")
	"""
    def n_updatePrefix(tab, nick, mode):
        """ checks if the mode is a prefix-mode (e.g. +o)
			If so, the prefix of the nick `nick` in channel `channel`
			will be updated (fetched).
		"""
        if not nick:
            return

        if mode[1] in tab.server.support_prefix[0]:
            tab.nickList.set_prefix(
                nick, sushi.user_channel_prefix(tab.server.name, tab.name,
                                                nick))

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

    nick = parse_from(from_str)[0]

    # nick: /mode target +mode param
    server_tab = gui.tabs.search_tab(server)

    if not nick:
        # only a mode listing
        server_tab.current_write(
            time,
            _("• Modes for %(target)s: %(mode)s") % {
                "target": target,
                "mode": mode
            }, gui.tabs.ACTION)

    else:
        actor = nick
        own = (nick == server_tab.nick)

        if own:
            actor = "You"

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

        if not tab:
            # no channel/query found

            if param: param = " " + param

            if not _hide_output(server_tab, "mode"):

                actor = "<font foreground='%s'>%s</font>" % (
                    action_nick_color(actor), actor)
                target = "<font foreground='%s'>%s</font>" % (
                    action_nick_color(target), target)

                server_tab.current_write(
                    time, "• %(actor)s set %(mode)s%(param)s on %(target)s" % {
                        "actor": actor,
                        "mode": mode,
                        "param": param,
                        "target": target
                    }, gui.tabs.ACTION)
        else:
            # suitable channel/query found, print it there

            n_updatePrefix(tab, param, mode)

            type = gui.tabs.ACTION
            victim = target
            own = (target == server_tab.nick)

            if (param == server_tab.nick) or own:
                type = gui.tabs.HIGHACTION
            elif own:
                victim = "you"

            if param: param = " " + param

            if _show_output_exclusive(server_tab, tab, "mode", own=own):

                actor = "<font foreground='%s'>%s</font>" % (
                    color.get_nick_color(actor), actor)
                victim = "<font foreground='%s'>%s</font>" % (
                    color.get_nick_color(victim), victim)

                tab.write(
                    time,
                    "• %(actor)s set %(mode)s%(param)s on %(victim)s." % {
                        "actor": actor,
                        "mode": mode,
                        "param": param,
                        "victim": victim
                    }, type)
Exemplo n.º 36
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)
Exemplo n.º 37
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)