コード例 #1
0
    def packet2response(cls, packet):
        chatroom = Chatroom.codename2chatroom(
            KhalaPacket.packet2chatroom(packet))
        locale = Chatroom.chatroom2locale(chatroom)
        lang = LocaleTool.locale2lang(locale)

        text_in = KhalaPacket.packet2text(packet)
        config = {HenriqueEntity.Config.Field.LOCALE: locale}

        def entity2is_valid(entity):
            if FoxylibEntity.entity2value(
                    entity) != HenriqueSkill.Codename.HELP:
                return True

            span = FoxylibEntity.entity2span(entity)
            if len(str2strip(text_in[:span[0]])) > 1:
                return True

        entity_list_skill = lfilter(
            entity2is_valid,
            SkillEntity.text2entity_list(text_in, config=config))

        def entity_list2codename_list(entity_list):
            codename_list = luniq(
                map(SkillEntity.entity2skill_codename, entity_list))
            if codename_list:
                return codename_list

            return [HenriqueSkill.Codename.HELP]

        codename_list = entity_list2codename_list(entity_list_skill)
        clazz_list = lmap(HenriqueSkill.codename2class, codename_list)

        blocks = [clazz.lang2description(lang) for clazz in clazz_list]
        return Rowsblock.blocks2text(blocks)
コード例 #2
0
    def packet2response(cls, packet):
        chatroom = Chatroom.codename2chatroom(KhalaPacket.packet2chatroom(packet))
        locale = Chatroom.chatroom2locale(chatroom)
        lang = LocaleTool.locale2lang(locale)

        entity_classes = cls.target_entity_classes()
        text_in = KhalaPacket.packet2text(packet)

        config = {HenriqueEntity.Config.Field.LOCALE: locale}
        entity_list = HenriqueEntity.text_classes2entity_list(text_in, entity_classes, config=config)

        blocks = [cls.entity_lang2response_block(entity, lang) for entity in entity_list]

        return Rowsblock.blocks2text(blocks)
コード例 #3
0
    def packet2response(cls, packet):
        chatroom = Chatroom.codename2chatroom(
            KhalaPacket.packet2chatroom(packet))
        locale = Chatroom.chatroom2locale(chatroom)

        entity_classes = cls.target_entity_classes()
        text_in = KhalaPacket.packet2text(packet)
        config = {HenriqueEntity.Config.Field.LOCALE: locale}
        entity_list_raw = lchain(*[
            c.text2entity_list(text_in, config=config) for c in entity_classes
        ])

        entity_list = sorted(entity_list_raw, key=FoxylibEntity.entity2span)

        blocks = [
            cls.entity2response_block(packet, entity) for entity in entity_list
        ]

        return Rowsblock.blocks2text(blocks)
コード例 #4
0
    def packet2response(cls, packet):
        logger = HenriqueLogger.func_level2logger(cls.packet2response, logging.DEBUG)

        logger.debug({"packet":packet})

        chatroom = Chatroom.codename2chatroom(KhalaPacket.packet2chatroom(packet))
        if Chatroom.chatroom2codename(chatroom) != ChatroomKakaotalk.codename():
            return

        text_in = KhalaPacket.packet2text(packet)
        # config = {HenriqueEntity.Config.Field.LOCALE: locale}

        # config = {HenriqueEntity.Config.Field.LOCALE: locale}
        # entity_list_raw = lchain(*[c.text2entity_list(text_in, config=config) for c in entity_classes])
        #
        entity_list_chatroomuser = sorted(ChatroomuserEntity.text2entity_list(text_in), key=FoxylibEntity.entity2span)
        blocks = [cls.entity2response_block(entity, packet,) for entity in entity_list_chatroomuser]

        return Rowsblock.blocks2text(blocks)
コード例 #5
0
 def packet2response(cls, packet):
     blocks = cls.packet2rowsblocks(packet)
     return Rowsblock.blocks2text(blocks)