diff --git a/addons/builtin/copilot.py b/addons/builtin/copilot.py index aefbd23..f8ffd63 100644 --- a/addons/builtin/copilot.py +++ b/addons/builtin/copilot.py @@ -3,9 +3,20 @@ import aiohttp from loguru import logger -from utils import retry +# 解锁判定方式;目前Copilot除了极少数地区未提供支持,其他的几乎都支持。和节点质量关系并不大。 UNS_REGION = ["MY", "CV", "CN", "CU", "SR", "TL", "IR", 'CI', 'KP', 'PS', 'RU', 'SH', 'SY'] +try: + from utils import retry +except ImportError: + def retry(_=3): + def wrapper(func): + async def inner(*args, **kwargs): + await func(*args, **kwargs) + + return inner + + return wrapper @retry(3) @@ -21,7 +32,7 @@ async def fetch_copilot(collector, session: aiohttp.ClientSession, proxy=None): 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0' } - url = 'https://www.bing.com/search?q=bing' + url = 'https://www.bing.com/chat?toWww=1' async with session.get(url, headers=headers, proxy=proxy, timeout=5) as resp: if resp.history: for i in resp.history: @@ -30,8 +41,10 @@ async def fetch_copilot(collector, session: aiohttp.ClientSession, proxy=None): return True if resp.status == 200: text = await resp.text() - # index = text.find("Copilot") - index = text.find("b-scopeListItem-conv") + index = text.find("b_wlcmPersLogo.copilot") + # print("b_wlcmPersLogo.copilot:", index) + collector.info['copilot'] = str(index) + # return True try: region = re.search(r'Region:"(\w\w)"', text).group(1) # region2 = re.search(r'Region:"(.*)"', text).group(1) @@ -81,4 +94,6 @@ async def demo(): if __name__ == "__main__": - asyncio.run(demo()) + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + loop.run_until_complete(demo())