#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""IP信息查询Skill"""

import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))

from skills.base_skill import BaseSkill
from network_tools import run_ip_info_query


class IpInfoSkill(BaseSkill):
    """IP信息查询Skill"""
    
    def get_metadata(self):
        return {
            "name": "ip_info",
            "display_name": "IP信息查询",
            "description": "查询本机或公网IP的详细信息(地理位置、运营商等)",
            "category": "info",
            "keywords": ["ip", "信息", "查询", "地理", "位置", "运营商"],
            "parameters": [
                {
                    "name": "ip",
                    "type": "string",
                    "required": False,
                    "default": "",
                    "description": "IP地址(留空查询本机公网IP)"
                }
            ],
            "examples": [
                "查询本机IP信息",
                "查看公网IP",
                "IP信息查询"
            ],
            "requires_admin": False,
            "requires_ui": False
        }
    
    def execute(self, ip: str = "") -> str:
        """查询IP信息"""
        return run_ip_info_query(ip)
