Ejemplo n.º 1
0
def cmd_description(args, context):
    if len(args) == 0:  # Show story description.
        body = "Description: " + sf.data[-1]["info"]["description"]
    else:  # Change story description.
        sf.new_revision()
        sf.set_info("description", " ".join(args))
        body = "Description updated."
    return {"body": body}
Ejemplo n.º 2
0
def cmd_description(args, context):
    if len(args) == 0:  # Show story description.
        body = "Description: " + sf.data[-1]["info"]["description"]
    else:  # Change story description.
        sf.new_revision()
        sf.set_info("description", ' '.join(args))
        body = "Description updated."
    return {"body": body}
Ejemplo n.º 3
0
def cmd_author(args, context):
    if len(args) == 0:  # Show story author.
        body = "Author: " + sf.data[-1]["info"]["author"]
    else:  # Change story author.
        sf.new_revision()
        sf.set_info("author", " ".join(args))
        body = "Author updated."
    return {"body": body}
Ejemplo n.º 4
0
def cmd_author(args, context):
    if len(args) == 0:  # Show story author.
        body = "Author: " + sf.data[-1]["info"]["author"]
    else:  # Change story author.
        sf.new_revision()
        sf.set_info("author", ' '.join(args))
        body = "Author updated."
    return {"body": body}
Ejemplo n.º 5
0
def cmd_put(args, context):
    if len(args) < 2:
        return False
    try:  # Get destination position and fit within bounds.
        pos = int(args[0])
        if pos < 1:
            pos = 1
        elif pos > len(sf.data[-1]["scenes"]) + 1:
            pos = len(sf.data[-1]["scenes"]) + 1
    except (ValueError):
        return False
    sf.new_revision()
    sf.add_scene(pos, " ".join(args[1:]))
    body = "New scene inserted."
    return {"body": body}
Ejemplo n.º 6
0
def cmd_put(args, context):
    if len(args) < 2:
        return False
    try:  # Get destination position and fit within bounds.
        pos = int(args[0])
        if pos < 1:
            pos = 1
        elif pos > len(sf.data[-1]["scenes"]) + 1:
            pos = len(sf.data[-1]["scenes"]) + 1
    except (ValueError):
        return False
    sf.new_revision()
    sf.add_scene(pos, ' '.join(args[1:]))
    body = "New scene inserted."
    return {"body": body}
Ejemplo n.º 7
0
def cmd_move(args, context):
    if len(args) != 2:
        return False
    try:
        pos = int(args[0])
        amount = int(args[1])
    except (ValueError):
        return False
    if pos < 1 or pos > len(sf.data[-1]["scenes"]):
        return False
    if pos + amount < 1 or pos + amount > len(sf.data[-1]["scenes"]):
        return False
    sf.new_revision()
    if not sf.move_scene(pos, amount):
        return False
    body = "Scene moved."
    return {"body": body}
Ejemplo n.º 8
0
def cmd_move(args, context):
    if len(args) != 2:
        return False
    try:
        pos = int(args[0])
        amount = int(args[1])
    except (ValueError):
        return False
    if pos < 1 or pos > len(sf.data[-1]["scenes"]):
        return False
    if pos + amount < 1 or pos + amount > len(sf.data[-1]["scenes"]):
        return False
    sf.new_revision()
    if not sf.move_scene(pos, amount):
        return False
    body = "Scene moved."
    return {"body": body}
Ejemplo n.º 9
0
def cmd_name(args, context):
    if context[1] == "STORY":
        if len(args) == 0:  # Show story name.
            body = "Story Name: " + sf.data[-1]["info"]["name"]
        else:  # Change story name.
            sf.new_revision()
            sf.set_info("name", " ".join(args))
            body = "Story name updated."
            c = ""
    elif context[1] == "SCENE":
        if len(args) == 0:  # Show scene name.
            body = "Scene Name: " + sf.get_scene_by_id(context[2])[1]
        else:  # Change scene name.
            sf.new_revision()
            sf.set_scene(context[2], "name", " ".join(args))
            body = "Scene name updated."
            c = "Scene: "
    if len(args) != 0:
        return {"body": body, "name": '{0}"{1}"'.format(c, " ".join(args))}
    else:
        return {"body": body}
Ejemplo n.º 10
0
def cmd_name(args, context):
    if context[1] == "STORY":
        if len(args) == 0:  # Show story name.
            body = "Story Name: " + sf.data[-1]["info"]["name"]
        else:  # Change story name.
            sf.new_revision()
            sf.set_info("name", ' '.join(args))
            body = "Story name updated."
            c = ""
    elif context[1] == "SCENE":
        if len(args) == 0:  # Show scene name.
            body = "Scene Name: " + sf.get_scene_by_id(context[2])[1]
        else:  # Change scene name.
            sf.new_revision()
            sf.set_scene(context[2], "name", ' '.join(args))
            body = "Scene name updated."
            c = "Scene: "
    if len(args) != 0:
        return {"body": body, "name": "{0}\"{1}\"".format(c, ' '.join(args))}
    else:
        return {"body": body}