diff --git a/core/dirty_check.py b/core/dirty_check.py index 4408b627..8904bc37 100644 --- a/core/dirty_check.py +++ b/core/dirty_check.py @@ -85,6 +85,7 @@ async def check(*text) -> list: call_api_list.update({pq: []}) call_api_list[pq].append(q) call_api_list_ = [x for x in call_api_list] + Logger.debug(call_api_list_) if call_api_list_: body = { "scenes": [ @@ -101,7 +102,7 @@ async def check(*text) -> list: GMT_FORMAT = '%a, %d %b %Y %H:%M:%S GMT' date = datetime.datetime.utcnow().strftime(GMT_FORMAT) - nonce = 'LittleC is god forever {}'.format(time.time()) + nonce = 'LittleC sb {}'.format(time.time()) contentMd5 = base64.b64encode(hashlib.md5(json.dumps(body).encode('utf-8')).digest()).decode('utf-8') headers = { 'Accept': 'application/json', @@ -132,6 +133,7 @@ async def check(*text) -> list: async with session.post('{}{}'.format(root, url), data=json.dumps(body)) as resp: if resp.status == 200: result = await resp.json() + Logger.debug(result) for item in result['data']: content = item['content'] for n in call_api_list[content]: diff --git a/core/logger.py b/core/logger.py index bf402160..6fdc1737 100644 --- a/core/logger.py +++ b/core/logger.py @@ -23,7 +23,7 @@ class Logginglogger: self.log.remove() self.log.add(sys.stderr, format=basic_logger_format, level="DEBUG" if debug else "INFO", colorize=True) self.log.add(logpath + '/' + bot_name + "_{time:YYYY-MM-DD}.log", format=basic_logger_format, - retention="10 days") + retention="10 days", encoding="utf8") self.info = self.log.info self.error = self.log.error self.debug = self.log.debug diff --git a/modules/meme/urban.py b/modules/meme/urban.py index 5d64a2f2..7ddc4929 100644 --- a/modules/meme/urban.py +++ b/modules/meme/urban.py @@ -4,6 +4,7 @@ import ujson as json from config import Config from core.elements import Url +from core.logger import Logger from core.utils import get_url @@ -16,13 +17,13 @@ async def urban(term: str): url = 'http://api.urbandictionary.com/v0/define?term=' + term webrender = Config('web_render') if not webrender: - return + return '' url = webrender + 'source?url=' + url text = await get_url(url, 200, headers={'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'accept-language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,en-GB;q=0.6', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62'}) - print(text) + Logger.debug(text) data = json.loads(text)['list'] if data == []: return '[Urban Dictionary] 没有找到相关结果。'