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


Python Interface.send方法代码示例

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


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

示例1: main

# 需要导入模块: from Interface import Interface [as 别名]
# 或者: from Interface.Interface import send [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

示例2: show

# 需要导入模块: from Interface import Interface [as 别名]
# 或者: from Interface.Interface import send [as 别名]
    def show (self, ac = None, append = None):
        inf = Interface(self.activator, self.activator)

        if ac is None:
            inf.set_title(self.activator.name + "'s Python Console")
            msg = markup_escape("\n".join(self.inf_data))
            inf.add_msg("[font=mono 12]{}[/font]".format(msg))
        else:
            inf.restore()

        inf.set_text_input(prepend = "/console \"", allow_tab = True,
                allow_empty = True, cleanup_text = False, scroll_bottom = True,
                autocomplete = "noinf::ac::",
                text = ac if ac else "")

        if append:
            inf.set_append_text("[font=mono 12]\n{}[/font]".format(append))

        inf.send()
开发者ID:atrinik,项目名称:atrinik,代码行数:21,代码来源:console.py

示例3: WhoIsActivator

# 需要导入模块: from Interface import Interface [as 别名]
# 或者: from Interface.Interface import send [as 别名]
from Atrinik import *
from Interface import Interface

activator = WhoIsActivator()
me = WhoAmI()
msg = WhatIsMessage().strip().lower()
inf = Interface(activator, me)

def main():
    if msg == "hello":
        import random

        replies = [
            "Get away from my *hic* beer *hic*!",
            "I can see you! *hic* Don' make me come af'er you! *hic* ... Can ye find my sword? I think I losst it!",
            "Bartender, 'nother beer here!",
            "[yellow]The " + me.name + " breaks into a song...[/yellow]\n\nI am a guard aaaand I am havin' a beer. Drinky drinky guard, drinky drinky guard.",
            "*HIC*",
            "I'm *hic!* watchin' you! I bets ye think I'm *hic* off duty but ye be wrong! I'm here guardin' my beer an' no-one iss gonna *hic!* take it from me!",
            "It's not fair! *hic!* I gets paid low wages! But I *hic* are super guard! We don' needs so many *hic* guards aroun' here! I can handles this whole *hic* here place meself! Noth'n can *hic* beat me! Hahahaha*hic!*!",
            "Ahhh! Stop that... shouting! It's making... people... me... nervous!",
        ]

        inf.add_msg(random.choice(replies))

main()
inf.send()
开发者ID:atrinik,项目名称:atrinik,代码行数:29,代码来源:guard_drunk.py


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