diff options
author | 0w0 <[email protected]> | 2022-12-29 16:39:00 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2022-12-29 16:39:00 +0800 |
commit | 5e63be78aabb6feda2bf92b9db2264aac2721641 (patch) | |
tree | d90bc810150d859c76e64f6e71d8524478014f31 /ATRI/plugins | |
parent | bb13b38f862d859007d1d37941f5b5c9d5f38cbc (diff) | |
parent | c0e5f0398bd4c3c55378cff303f31ff968822346 (diff) | |
download | ATRI-5e63be78aabb6feda2bf92b9db2264aac2721641.tar.gz ATRI-5e63be78aabb6feda2bf92b9db2264aac2721641.tar.bz2 ATRI-5e63be78aabb6feda2bf92b9db2264aac2721641.zip |
🔀 Merge pull request #66 from yangrq1018/main
Feature add + bug fix
Diffstat (limited to 'ATRI/plugins')
-rw-r--r-- | ATRI/plugins/anti_effort/__init__.py | 2 | ||||
-rw-r--r-- | ATRI/plugins/geoip.py | 33 | ||||
-rw-r--r-- | ATRI/plugins/manage/__init__.py | 2 |
3 files changed, 37 insertions, 0 deletions
diff --git a/ATRI/plugins/anti_effort/__init__.py b/ATRI/plugins/anti_effort/__init__.py index aa38f78..f44869f 100644 --- a/ATRI/plugins/anti_effort/__init__.py +++ b/ATRI/plugins/anti_effort/__init__.py @@ -225,6 +225,8 @@ async def _(): raw_data = json.loads(file_path.read_bytes()) data = raw_data["data"] data = sorted(data, key=lambda x: x["recent_count"], reverse=True) + if len(data) == 0: + continue winner = data[0] winner_id = int(winner["user_id"]) winner_nickname = winner["user_nickname"] diff --git a/ATRI/plugins/geoip.py b/ATRI/plugins/geoip.py new file mode 100644 index 0000000..bbe8d60 --- /dev/null +++ b/ATRI/plugins/geoip.py @@ -0,0 +1,33 @@ +from nonebot.params import ArgStr +import geoip2.webservice +from ATRI.service import Service +from ATRI import conf + + +geoip = Service("GEOIP查询").document("search ip in MaxMind GEOIP databases") + +query_geoip = geoip.on_command("ip查询", "查询IP的地理位置", aliases={"IP查询", "查询IP"}) + +LANG = "zh-CN" + + +@query_geoip.got("ip_address", prompt="地址是?(支持ipv4/ipv6)") +async def _(ip_address: str = ArgStr()): + with geoip2.webservice.Client( + conf.GeoIP.account_id, conf.GeoIP.license_key, host="geolite.info" + ) as client: + await query_geoip.send("正在查询...请稍候") + response = client.city(ip_address) + country = response.country.names[LANG] + city = response.city.names[LANG] + org = response.traits.autonomous_system_organization + network = str(response.traits.network) + subdivision = "" + if subs := response.subdivisions: + subdivision = subs[0].names[LANG] + await query_geoip.finish( + f"IP: {ip_address}\n" + f"{country}{subdivision}{city}\n" + f"运营商{org}\n" + f"网段{network}" + ) diff --git a/ATRI/plugins/manage/__init__.py b/ATRI/plugins/manage/__init__.py index 0268ec9..03de2fe 100644 --- a/ATRI/plugins/manage/__init__.py +++ b/ATRI/plugins/manage/__init__.py @@ -290,6 +290,8 @@ async def _deal_approve_friend_add( except Exception: await approve_friend_add.finish("同意失败...尝试下手动?") data = Manage().load_friend_apply_list() + if apply_code not in data: + await approve_friend_add.reject("申请码不存在...请检查是否输入正确") data.pop(apply_code) Manage().save_friend_apply_list(data) await approve_friend_add.finish("好欸!申请已通过!") |