Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/core/utils/ip.py
2023-08-30 17:49:45 +08:00

27 lines
670 B
Python

import traceback
from core.logger import Logger
from core.types import Secret
from core.utils.http import get_url
class IP:
address = None
country = None
def append_ip(ip_info):
Secret.add(ip_info['ip'])
IP.country = ip_info['country']
IP.address = ip_info['ip']
async def fetch_ip_info() -> dict:
try:
Logger.info('Fetching IP information...')
ip_info = await get_url('https://api.ip.sb/geoip', timeout=10, fmt='json')
Logger.info('Successfully fetched IP information.')
return ip_info
except Exception:
Logger.info('Failed to get IP information.')
Logger.error(traceback.format_exc())