Archived
1
0
Fork 0

Merge pull request #8 from wyapx/patch-2

做了一些微小的工作
This commit is contained in:
yzhh 2021-02-19 05:42:05 -06:00 committed by GitHub
commit 01f9b15823
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 23 deletions

View file

@ -23,35 +23,30 @@ def computeMD5hash(my_string):
return m.hexdigest()
async def check(text: list):
try:
async def check(*text):
config_path = os.path.abspath('config/config.cfg')
try:
accessKeyId = config(config_path, "Check_accessKeyId")
accessKeySecret = config(config_path, "Check_accessKeySecret")
except Exception:
except FileNotFoundError:
return '\n'.join(text)
print('hello')
body = {
"scenes": [
"antispam"
],
"tasks": list(map(lambda x: {
"dataId": "LittleC is god {}".format(time.time()),
"dataId": "OasisAkari is god {}".format(time.time()),
"content": x
}, text))
}
print(urlencode({
'we': 123
}))
clientInfo = '{}'
root = 'https://green.cn-shanghai.aliyuncs.com'
url = '/green/text/scan?{}'.format(clientInfo)
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 = 'OasisAkari is god forever {}'.format(time.time())
contentMd5 = base64.b64encode(hashlib.md5(json.dumps(body).encode('utf-8')).digest()).decode('utf-8')
print(json.dumps(body))
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
@ -62,7 +57,6 @@ async def check(text: list):
'x-acs-signature-version': '1.0',
'x-acs-signature-method': 'HMAC-SHA1'
}
print(headers)
tmp = {
'x-acs-version': '2018-05-09',
'x-acs-signature-nonce': nonce,
@ -75,16 +69,13 @@ async def check(text: list):
step3 = "POST\napplication/json\n{contentMd5}\napplication/json\n{date}\n{step1}\n{step2}".format(
contentMd5=contentMd5,
date=headers['Date'], step1=step1, step2=step2)
print(step3)
sign = "acs {}:{}".format(accessKeyId, hash_hmac(accessKeySecret, step3, hashlib.sha1))
headers['Authorization'] = sign
print(headers)
# 'Authorization': "acs {}:{}".format(accessKeyId, sign)
async with aiohttp.ClientSession(headers=headers) as session:
async with session.post('{}{}'.format(root, url), data=json.dumps(body)) as resp:
if resp.status == 200:
result = await resp.json()
print(result)
resultUsers = []
for item in result['data']:
content = item['content']
@ -100,4 +91,4 @@ async def check(text: list):
return ''.join(resultUsers)
else:
return (await resp.text())
return await resp.text()

View file

@ -27,7 +27,7 @@ async def newbie(app):
if xz['title'] in qq:
pass
else:
s = await check([UTC8(xz['timestamp'], 'onlytime') + '新增新人:' + xz['title']])
s = await check(UTC8(xz['timestamp'], 'onlytime') + '新增新人:' + xz['title'])
if s.find("<吃掉了>") != -1 or s.find("<全部吃掉了>") != -1:
await app.sendGroupMessage(731397727, MessageChain.create(
[Plain(s + '\n检测到外来信息介入请前往日志查看所有消息。Special:日志?type=newusers')]).asSendable())

View file

@ -21,10 +21,10 @@ async def main(kwargs: dict):
else:
showplayer = False
sendmsg = await server(message, raw, showplayer)
sendmsg = await check([sendmsg])
sendmsg = await check(sendmsg)
send = await sendMessage(kwargs, sendmsg)
sendmsgb = await server_be(message, raw)
sendmsgb = await check([sendmsgb])
sendmsgb = await check(sendmsgb)
sendb = await sendMessage(kwargs, sendmsgb)
await asyncio.sleep(30)
await revokeMessage(send)

View file

@ -22,7 +22,7 @@ async def ab(table, id):
for x in file['query']['abuselog'][:5]:
d.append('' + x['title'] + ' - ' + x['user'] + '' + UTC8(x['timestamp'], 'onlytimenoutc') + '\n过滤器名:' + x[
'filter'] + '\n处理结果:' + x['result'])
y = await check(['\n'.join(d)])
y = await check('\n'.join(d))
if y.find('<吃掉了>') != -1 or y.find('<全部吃掉了>') != -1:
return y + '\n...仅显示前5条内容\n检测到外来信息介入请前往滥用日志查看所有消息。Special:滥用日志\n[一分钟后撤回本消息]'
else:

View file

@ -23,7 +23,7 @@ async def newbie(table, id):
d.append(x['title'])
print(str(d))
m = '\n'.join(d)
y = await check([m])
y = await check(m)
print(str(y))
f = re.findall(r'.*\n.*\n.*\n.*\n.*', str(y))
g = '这是当前的新人列表:\n' + f[0] + '\n...仅显示前5条内容'

View file

@ -23,7 +23,7 @@ async def rc(table, id):
d.append(x['title'] + ' - ' + x['user'] + ' ' + UTC8(x['timestamp'], 'onlytime'))
m = '\n'.join(d)
print(m)
y = await check([m])
y = await check(m)
print(y)
if y.find('<吃掉了>') != -1 or y.find('<全部吃掉了>') != -1:
msg = y + '\n...仅显示前5条内容\n检测到外来信息介入请前往最近更改查看所有消息。Special:最近更改'

View file

@ -4,7 +4,7 @@ import urllib
import aiohttp
import core.dirty_check
from core import dirty_check
from .helper import check_wiki_available
@ -41,7 +41,7 @@ class wikilib:
async def danger_text_check(self, text):
if not self.danger_wiki_check():
return False
check = await core.dirty_check.check([text])
check = await dirty_check.check(text)
print(check)
if check.find('<吃掉了>') != -1 or check.find('<全部吃掉了>') != -1:
return True