コード例 #1
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)
コード例 #2
0
ファイル: signal_handler.py プロジェクト: sushi-irc/tekka
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)
コード例 #3
0
def _add_channels(server_tab):
    """
		Adds all channels to tekka wich are reported by maki.
	"""
    channels = sushi.channels(server_tab.name)

    for channel in channels:

        add = False
        nicks, prefixes = sushi.channel_nicks(server_tab.name, channel)

        tab = gui.tabs.search_tab(server_tab.name, channel)

        if not tab:
            tab = gui.tabs.create_channel(server_tab, channel)
            add = True

        tab.nickList.clear()
        tab.nickList.add_nicks(nicks, prefixes)

        for nick in nicks:
            # FIXME inefficient → nicks, prefixes, aways = …?
            tab.nickList.set_away(nick, sushi.user_away(server_tab.name, nick))

        tab.topic = sushi.channel_topic(server_tab.name, channel)
        tab.topicsetter = ""

        if tab.is_active():
            gui.set_topic(markup.markup_escape(tab.topic))
            gui.mgmt.set_user_count(len(tab.nickList),
                                    tab.nickList.get_operator_count())

        # TODO: handle topic setter
        tab.joined = True
        tab.connected = True

        if add:
            gui.tabs.add_tab(server_tab, tab, update_shortcuts=False)
            tab.print_last_log()

        topic = sushi.channel_topic(server_tab.name, channel)
        _report_topic(mtime.time(), server_tab.name, channel, topic)

    gui.shortcuts.assign_numeric_tab_shortcuts(gui.tabs.get_all_tabs())
コード例 #4
0
ファイル: signal_handler.py プロジェクト: sushi-irc/tekka
def _add_channels(server_tab):
    """
		Adds all channels to tekka wich are reported by maki.
	"""
    channels = sushi.channels(server_tab.name)

    for channel in channels:

        add = False
        nicks, prefixes = sushi.channel_nicks(server_tab.name, channel)

        tab = gui.tabs.search_tab(server_tab.name, channel)

        if not tab:
            tab = gui.tabs.create_channel(server_tab, channel)
            add = True

        tab.nickList.clear()
        tab.nickList.add_nicks(nicks, prefixes)

        for nick in nicks:
            # FIXME inefficient → nicks, prefixes, aways = …?
            tab.nickList.set_away(nick, sushi.user_away(server_tab.name, nick))

        tab.topic = sushi.channel_topic(server_tab.name, channel)
        tab.topicsetter = ""

        if tab.is_active():
            gui.set_topic(markup.markup_escape(tab.topic))
            gui.mgmt.set_user_count(len(tab.nickList), tab.nickList.get_operator_count())

            # TODO: handle topic setter
        tab.joined = True
        tab.connected = True

        if add:
            gui.tabs.add_tab(server_tab, tab, update_shortcuts=False)
            tab.print_last_log()

        topic = sushi.channel_topic(server_tab.name, channel)
        _report_topic(mtime.time(), server_tab.name, channel, topic)

    gui.shortcuts.assign_numeric_tab_shortcuts(gui.tabs.get_all_tabs())