示例#1
0
def cmd_overview(main_window, argv):
    """ /overview [<server>] """
    if no_connection():
        return

    if len(argv) == 2:
        if argv[1] not in [n.name for n in main_window.servers]:
            print_error("Server '%s' not found." % (argv[1]))
            return
        server_list = [main_window.find_server(argv[1])]
    else:
        server_list = main_window.servers

    print_normal("Begin overview.")

    for server in server_list:
        if server.connected:
            connected = "connected"
        else:
            connected = "not connected"

        print_normal("Server '%s' (%s)" % (server, connected))

        for child in server.children:
            if type(child) == tabs.Channel:
                if child.joined:
                    joined = "joined"
                else:
                    joined = "not joined"
                print_normal("- Channel '%s' (%s)" % (child.name, joined))
            else:
                print_normal("- Query '%s'" % (child.name))

    print_normal("End of overview.")
示例#2
0
def cmd_overview(main_window, argv):
    """ /overview [<server>] """
    if no_connection():
        return

    if len(argv) == 2:
        if argv[1] not in [n.name for n in main_window.servers]:
            print_error("Server '%s' not found." % (argv[1]))
            return
        server_list = [main_window.find_server(argv[1])]
    else:
        server_list = main_window.servers

    print_normal("Begin overview.")

    for server in server_list:
        if server.connected:
            connected = "connected"
        else:
            connected = "not connected"

        print_normal("Server '%s' (%s)" % (server, connected))

        for child in server.children:
            if type(child) == tabs.Channel:
                if child.joined:
                    joined = "joined"
                else:
                    joined = "not joined"
                print_normal("- Channel '%s' (%s)" % (child.name, joined))
            else:
                print_normal("- Query '%s'" % (child.name))

    print_normal("End of overview.")
示例#3
0
def cmd_ignores(main_window, argv):
    """ /ignores """
    server = tabs.get_server(main_window.current_tab).name
    ignores = connection.sushi.ignores(server)

    if not ignores:
        print_normal("No users ignored on %(server)s." % {"server": server})
    else:
        print_normal("Ignored users: %(ulist)s." % {"ulist": ", ".join(ignores)})
示例#4
0
def cmd_ignores(main_window, argv):
    """ /ignores """
    server = tabs.get_server(main_window.current_tab).name
    ignores = connection.sushi.ignores(server)

    if not ignores:
        print_normal("No users ignored on %(server)s." % {"server": server})
    else:
        print_normal("Ignored users: %(ulist)s." %
                     {"ulist": ", ".join(ignores)})
示例#5
0
def cmd_servers(main_window, argv):
    """ /servers """
    active_servers = connection.sushi.servers()

    print_normal("Servers known to maki: ")
    for name in connection.sushi.server_list("", ""):
        if name in active_servers:
            connected = "connected"
        else:
            connected = "not connected"
        print_normal("- '%s' (%s)" % (name, connected))
示例#6
0
def cmd_servers(main_window, argv):
    """ /servers """
    active_servers = connection.sushi.servers()

    print_normal("Servers known to maki: ")
    for name in connection.sushi.server_list("", ""):
        if name in active_servers:
            connected = "connected"
        else:
            connected = "not connected"
        print_normal("- '%s' (%s)" % (name, connected))
示例#7
0
def cmd_help(main_window, argv):
    """ /help [<command>] """
    if len(argv) == 2:
        sCmd = argv[1]
    else:
        sCmd = None

    msg = ""

    for (name, value) in globals().items():
        cmd_name = name[4:]

        if name[0:4] == "cmd_":
            if sCmd and sCmd != cmd_name:
                continue

            msg += "%s:\n %s\n" % (cmd_name, (value.__doc__ or "No documentation yet.").replace("\t", "   "))

            if sCmd and sCmd == cmd_name:
                break

    print_normal(msg)
示例#8
0
def cmd_help(main_window, argv):
    """ /help [<command>] """
    if len(argv) == 2:
        sCmd = argv[1]
    else:
        sCmd = None

    msg = ""

    for (name, value) in globals().items():
        cmd_name = name[4:]

        if name[0:4] == "cmd_":
            if sCmd and sCmd != cmd_name:
                continue

            msg += "%s:\n %s\n" % (cmd_name, (
                value.__doc__ or "No documentation yet.").replace("\t", "   "))

            if sCmd and sCmd == cmd_name:
                break

    print_normal(msg)
示例#9
0
def cmd_dcc(main_window, argv):
    """ /dcc chat <target>
	/dcc send <target> <path>
	/dcc list <type>
	/dcc remove <type> <id>
	"""
    if no_connection():
        return

    if len(argv) < 2:
        print_notification("Usage: /dcc accept|chat|send|list|remove")
        return

    server_tab = tabs.get_server(main_window.current_tab)

    if argv[1] == "send":
        if len(argv) < 4:
            print_notification("Usage: /dcc send <target> <path>")
            return

        connection.sushi.dcc_send(server_tab.name, argv[2], argv[3])
    elif argv[1] == "accept":

        def accepted_cb(time, id, *x):
            if id == int(argv[2]):
                print_notification(_("DCC action with id %(id)d accepted.") % {"id": id})
                signals.disconnect_signal("dcc_send", accepted_cb)

        if len(argv) < 3:
            print_notification("Usage: /dcc accept <id>")
            return

        signals.connect_signal("dcc_send", accepted_cb)
        connection.sushi.dcc_send_accept(int(argv[2]))
    elif argv[1] == "chat":
        pass
    elif argv[1] == "list":
        if len(argv) < 3:
            print_notification("Usage: /dcc list chat|send")
            return

        if argv[2] == "send":
            ids, servers, froms, filenames, sizes, progresses, speeds, statuses = connection.sushi.dcc_sends()

            for i in range(len(ids)):
                print_normal(
                    "#%(id)d: %(filename)s from/to %(from)s [%(server)s]: %(progress)d/%(size)d @ %(speed)d"
                    % {
                        "id": ids[i],
                        "filename": filenames[i],
                        "from": froms[i],
                        "server": servers[i],
                        "progress": progresses[i],
                        "size": sizes[i],
                        "speed": speeds[i],
                    }
                )
        elif argv[2] == "chat":
            pass
    elif argv[1] == "remove":
        if len(argv) < 4:
            print_notification("Usage: /dcc remove <type> <id>")
            return

        if argv[2] == "send":
            connection.sushi.dcc_send_remove(int(argv[3]))
        elif argv[2] == "chat":
            pass
示例#10
0
def cmd_dcc(main_window, argv):
    """ /dcc chat <target>
	/dcc send <target> <path>
	/dcc list <type>
	/dcc remove <type> <id>
	"""
    if no_connection():
        return

    if len(argv) < 2:
        print_notification("Usage: /dcc accept|chat|send|list|remove")
        return

    server_tab = tabs.get_server(main_window.current_tab)

    if argv[1] == "send":
        if len(argv) < 4:
            print_notification("Usage: /dcc send <target> <path>")
            return

        connection.sushi.dcc_send(server_tab.name, argv[2], argv[3])
    elif argv[1] == "accept":

        def accepted_cb(time, id, *x):
            if id == int(argv[2]):
                print_notification(
                    _("DCC action with id %(id)d accepted.") % {"id": id})
                signals.disconnect_signal("dcc_send", accepted_cb)

        if len(argv) < 3:
            print_notification("Usage: /dcc accept <id>")
            return

        signals.connect_signal("dcc_send", accepted_cb)
        connection.sushi.dcc_send_accept(int(argv[2]))
    elif argv[1] == "chat":
        pass
    elif argv[1] == "list":
        if len(argv) < 3:
            print_notification("Usage: /dcc list chat|send")
            return

        if argv[2] == "send":
            ids, servers, froms, filenames, sizes, progresses, speeds, statuses = connection.sushi.dcc_sends(
            )

            for i in range(len(ids)):
                print_normal(
                    "#%(id)d: %(filename)s from/to %(from)s [%(server)s]: %(progress)d/%(size)d @ %(speed)d"
                    % {
                        "id": ids[i],
                        "filename": filenames[i],
                        "from": froms[i],
                        "server": servers[i],
                        "progress": progresses[i],
                        "size": sizes[i],
                        "speed": speeds[i]
                    })
        elif argv[2] == "chat":
            pass
    elif argv[1] == "remove":
        if len(argv) < 4:
            print_notification("Usage: /dcc remove <type> <id>")
            return

        if argv[2] == "send":
            connection.sushi.dcc_send_remove(int(argv[3]))
        elif argv[2] == "chat":
            pass