コード例 #1
0
    def _on_text(self, e: Event, entity: str, who: str, text: str) -> None:
        words = text.split()

        if len(words):
            Event.trigger(Event(words[0], self, entity=entity, args=words[1:]))
        else:
            text = f'你要作什麼?'
            Channel.toRole(entity, Message.TEXT, text)
コード例 #2
0
ファイル: cmd_echo.py プロジェクト: LZJ861124/mute
    def _on_cmd_echo(self, e: Event, entity: str = '', args: str = '') -> None:
        if not args:
            text = f'Echo : ?'

            Channel.toRole(entity, Message.TEXT, text)
        else:
            text = f'Echo:{" ".join(args)}'

            role = Role.instance(entity)
            Channel.toRoom(role.room, Message.TEXT, text)
コード例 #3
0
    def _on_cmd_say(
        self, e: Event, entity: str = '', args: List[str] = []
    ) -> None:
        if not args:
            text = f'你想說什麼?'

            Channel.toRole(entity, Message.TEXT, text)
        else:
            text = f'{Name.instance(entity).text} 說:{" ".join(args)}'

            role = Role.instance(entity)
            Channel.toRoom(role.room, Message.TEXT, text)
コード例 #4
0
ファイル: cmd_logout.py プロジェクト: fuliheng/mutee
    def _on_cmd_logout(self,
                       e: Event,
                       entity: str = '',
                       args: List[str] = []) -> None:

        if not args:
            socket.disconnect()

        else:
            text = f'目前不支援參數請勿輸入任何數值'

            role = Role.instance(entity)
            Channel.toRole(entity, Message.TEXT, text)
コード例 #5
0
ファイル: sign_in.py プロジェクト: LZJ861124/mute
    def _on_sign_in(self,
                    e: Event,
                    entity: str,
                    user_id: str = '',
                    passwd: str = '') -> None:
        role = Role.instance(user_id, name=user_id)

        Name.instance(entity, name=role.name)
        Room.instance(role.room).enter(entity)

        text = f'歡迎來到 MUTE: Multi-User Texting Environment'
        Channel.toRole(entity, Message.SYSTEM, text)

        Event.trigger(Event(Event.CMD_LOOK, self._servant, entity=entity))
コード例 #6
0
ファイル: cmd_time.py プロジェクト: fuliheng/mutee
    def _on_cmd_time(
        self, e: Event, entity: str = '', args: List[str] = []

    ) -> None:
        localtime = time.asctime( time.localtime(time.time()) )
        if not args:
            text = f'現在時間為{" ".join(localtime)}'

            role = Role.instance(entity)
            Channel.toRoom(role.room, Message.TEXT, text)

        else:
            text = f'目前不支援參數請勿輸入任何數值'

            role = Role.instance(entity)
            Channel.toRole(entity, Message.TEXT, text)
コード例 #7
0
    def _on_cmd_look(self, e: Event, entity: str = '', args: str = '') -> None:
        role = Role.instance(entity)

        if not args:
            room = Room.instance(role.room)

            text = f'{room.name} -'
            Channel.toRole(entity, Message.TEXT, text)

            for text in room.description:
                Channel.toRole(entity, Message.TEXT, text)

            if not room.exits:
                text = '這裡沒有出口'
            else:
                text = room.exits
        else:
            text = f'你在看什麼?'

        Channel.toRole(entity, Message.TEXT, text)
コード例 #8
0
    def _on_any(self, e: Event, entity: str, **kwargs) -> None:
        text = f'你要作什麼?'

        Channel.toRole(entity, Message.TEXT, text)
コード例 #9
0
ファイル: sign_in.py プロジェクト: LZJ861124/mute
    def _on_reception(self, e: Event, entity: str) -> None:
        text = f'歡迎來到 MUTE: Multi-User Texting Environment'
        Channel.toRole(entity, Message.TEXT, text)

        Channel.askRole(entity, Message.SIGN_IN)
コード例 #10
0
    def _on_cmd_echo(
        self, e: Event, entity: str = '', args: List[str] = []
    ) -> None:
        text = f'ECHO 說:{" ".join(args)}'

        Channel.toRole(entity, Message.TEXT, text)