当前位置: 首页>>代码示例>>Python>>正文


Python Interface.add_link方法代码示例

本文整理汇总了Python中Interface.Interface.add_link方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.add_link方法的具体用法?Python Interface.add_link怎么用?Python Interface.add_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Interface.Interface的用法示例。


在下文中一共展示了Interface.add_link方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from Interface import Interface [as 别名]
# 或者: from Interface.Interface import add_link [as 别名]
def main():
    match = re.match(r"((?:\")(.+)(?:\")|([^ ]+))"
            "( (removeall|(add|remove) ([^ ]+)|add))?", msg)

    if not match:
        activator.Controller().DrawInfo(
                "Usage: /cmd_permission <[]\"]player name[]\"]>",
                color = COLOR_WHITE)
        return

    player = match.group(2) or match.group(3)
    action = match.group(6) or match.group(5)
    cmd_permission = match.group(7)

    pl = FindPlayer(player)

    if not pl:
        activator.Controller().DrawInfo("No such player.", color = COLOR_RED)
        return

    inf = Interface(activator, pl)

    if cmd_permission:
        cmd_permission = markup_unescape(cmd_permission)

    if action == "add":
        if cmd_permission:
            if not cmd_permission in pl.Controller().cmd_permissions:
                pl.Controller().cmd_permissions.append(cmd_permission)
            else:
                inf.add_msg("{pl.name} already has that permission.",
                        color = COLOR_RED, pl = pl)
        else:
            inf.set_text_input(prepend = "/cmd_permission {} add ".format(
                    pl.name))
    elif action == "remove":
        try:
            pl.Controller().cmd_permissions.remove(cmd_permission)
        except ValueError:
            inf.add_msg("{pl.name} does not have that permission.",
                    color = COLOR_RED, pl = pl)
    elif action == "removeall":
        pl.Controller().cmd_permissions.clear()

    inf.add_msg("{pl.name} has the following permissions:\n", pl = pl)

    for tmp in pl.Controller().cmd_permissions:
        if tmp:
            inf.add_msg("\n    {perm} [y=-2][a=:/cmd_permission "
                    "{pl.name} remove {perm}]x[/a]",
                    perm = markup_escape(tmp), newline = False, pl = pl)

    inf.add_link("Add permission",
            dest = "/cmd_permission {} add".format(pl.name))
    inf.add_link("Remove all permissions",
            dest = "/cmd_permission {} removeall".format(pl.name))
    inf.send()
开发者ID:atrinik,项目名称:atrinik,代码行数:59,代码来源:cmd_permission.py


注:本文中的Interface.Interface.add_link方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。