def action_nick_color(nick): """ return the nick color if color_action_nicks is activated, otherwise return the default text color """ if config.get_bool("colors", "color_action_nicks"): return color.get_nick_color(nick) return color.get_color_by_key("text_action")
def cannotJoin(time, server, channel, reason): """ The channel could not be joined. reason : { l (full), i (invite only), b (banned), k (key) } """ message = _("Unknown reason") if reason == "full": message = _("The channel is full.") elif reason == "invite": message = _("The channel is invite-only.") elif reason == "banned": message = _("You are banned.") elif reason == "key": if config.get_bool("tekka", "ask_for_key_on_cannotjoin"): def key_dialog_response_cb(dialog, id): if id == gtk.RESPONSE_OK: sushi.join(server, channel, dialog.entry.get_text()) dialog.destroy() # open a input dialog which asks for the key d = key_dialog.KeyDialog(server, channel) d.connect("response", key_dialog_response_cb) gui.mgmt.show_inline_dialog(d) return else: message = _("You need the correct channel key.") server_tab = gui.tabs.search_tab(server) server_tab.current_write( time, _("You can not join %(channel)s: %(reason)s" % {"channel": channel, "reason": message}) )
def _setup_server(server): tab = gui.tabs.create_server(server) gui.tabs.add_tab(None, tab, update_shortcuts=config.get_bool("tekka", "server_shortcuts")) return tab
def cannotJoin(time, server, channel, reason): """ The channel could not be joined. reason : { l (full), i (invite only), b (banned), k (key) } """ message = _("Unknown reason") if reason == "full": message = _("The channel is full.") elif reason == "invite": message = _("The channel is invite-only.") elif reason == "banned": message = _("You are banned.") elif reason == "key": if config.get_bool("tekka", "ask_for_key_on_cannotjoin"): def key_dialog_response_cb(dialog, id): if id == gtk.RESPONSE_OK: sushi.join(server, channel, dialog.entry.get_text()) dialog.destroy() # open a input dialog which asks for the key d = key_dialog.KeyDialog(server, channel) d.connect("response", key_dialog_response_cb) gui.mgmt.show_inline_dialog(d) return else: message = _("You need the correct channel key.") server_tab = gui.tabs.search_tab(server) server_tab.current_write( time, _("You can not join %(channel)s: %(reason)s" % { "channel": channel, "reason": message }))
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)
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)