def userNames_cb(timestamp, server, channel, nicks, prefixes): """ this signal is called for each nick in the channel. remove the nick to make sure it isn't there (hac--workaround), add the nick, fetch the prefix for it and at least update the user count. """ server_tab, tab = gui.tabs.search_tabs(server, channel) if not server_tab or not tab: # /names for unexisting channel? return if not nicks: # end of list tab.nickList.sort_nicks() else: for i in xrange(len(nicks)): # FIXME tab.nickList.remove_nick(nicks[i]) tab.nickList.append_nick(nicks[i], sort=False) if prefixes[i]: tab.nickList.set_prefix(nicks[i], prefixes[i], sort=False) # FIXME inefficient tab.nickList.set_away(nicks[i], sushi.user_away(server_tab.name, nicks[i])) if tab.is_active(): gui.mgmt.set_user_count(len(tab.nickList), tab.nickList.get_operator_count())
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())