import re
from tools.ToolBase import ToolBase

class WhoisTool(ToolBase):
    def validate_instruction(self, instruction):
        #过滤
        timeout = 60*15
        return instruction,timeout

    def analyze_result(self, result,instruction,stderr,stdout):
        # 定义正则表达式模式来匹配所需的行
        pattern = r"(Registrant:.*?\n|Registrant Contact Email:.*?\n|Sponsoring Registrar:.*?\n)"
        # 使用re.findall()方法查找所有匹配项
        matches = re.findall(pattern, result)
        newresult = ""
        # 打印结果
        for match in matches:
            newresult += match.strip()
        if not newresult:
            return result
        return newresult