diff options
author | Kyomotoi <[email protected]> | 2020-11-22 01:01:43 +0800 |
---|---|---|
committer | Kyomotoi <[email protected]> | 2020-11-22 01:01:43 +0800 |
commit | f7198e8722f310926cf147bd0b218c5d9ef5d6c3 (patch) | |
tree | f4c3d0f2a003695b67e0e2018ec8d88898bcda90 /ATRI/plugins/plugin_anime/body.py | |
parent | 6c3e4c7f583be0006cd7bb913b7db81b987d2813 (diff) | |
download | ATRI-f7198e8722f310926cf147bd0b218c5d9ef5d6c3.tar.gz ATRI-f7198e8722f310926cf147bd0b218c5d9ef5d6c3.tar.bz2 ATRI-f7198e8722f310926cf147bd0b218c5d9ef5d6c3.zip |
[Update]
新增:
* 舆情检测
* 对涩图加以调用限制
修复:
* Pixiv插件全体
* 储存群聊信息时无法创建文件
优化:
* 部分代码重构,效率up
* 调整插件结构,使其看起来更舒服
Diffstat (limited to 'ATRI/plugins/plugin_anime/body.py')
-rw-r--r-- | ATRI/plugins/plugin_anime/body.py | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/ATRI/plugins/plugin_anime/body.py b/ATRI/plugins/plugin_anime/body.py deleted file mode 100644 index d7dae84..0000000 --- a/ATRI/plugins/plugin_anime/body.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : body.py -@Time : 2020/10/11 14:38:23 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import json - -from utils.utils_error import errorRepo -from utils.utils_request import request_get - - -class SauceNAO: - """搜图请求主体""" - def __init__(self, - api_key, - output_type=2, - testmode=0, - dbmask=None, - dbmaski=32768, - db=5, - numres=1): - api = 'https://saucenao.com/search.php' - self.api = api - params = dict() - params['api_key'] = api_key - params['output_type'] = output_type - params['testmode'] = testmode - params['dbmask'] = dbmask - params['dbmaski'] = dbmaski - params['db'] = db - params['numres'] = numres - self.params = params - - def search(self, url): - self.params['url'] = url - return request_get(self.api, self.params) - - -def resultRepo(user: str, key: str, img_url: str): - try: - task = SauceNAO(key) - data = task.search(img_url) - except Exception: - return errorRepo('请求数据失败') - - data = json.loads(data)['results'][0] - msg0 = '' - print(data) - - msg0 += f'[CQ:at,qq={user}]\n' - msg0 += "SauceNAO INFO:\n" - msg0 += f"[CQ:image,file={data['header'].get('thumbnail', None)}]\n" - msg0 += f"Like:{data['header'].get('similarity', 0)}%\n" - msg0 += f"Title:{data['data'].get('title', None)}\n" - msg0 += f"Pixiv ID:{data['data'].get('pixiv_id', None)}\n" - msg0 += f"Author:{data['data'].get('member_name', None)}\n" - msg0 += f"Autoor ID:{data['data'].get('member_id', None)}\n" - msg0 += f"Pixiv URL: https://www.pixiv.net/artworks/{data['data'].get('pixiv_id', None)}\n" - msg0 += f"Pic URL: https://pixiv.cat/{data['data'].get('pixiv_id', None)}.jpg" - - if float(data['header'].get('similarity', 0)) < 65: - msg0 += '\n注:相似率小于65%不一定正确' - - return msg0
\ No newline at end of file |