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

View file

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

View file

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

View file

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

View file

@ -23,7 +23,7 @@ async def newbie(table, id):
d.append(x['title']) d.append(x['title'])
print(str(d)) print(str(d))
m = '\n'.join(d) m = '\n'.join(d)
y = await check([m]) y = await check(m)
print(str(y)) print(str(y))
f = re.findall(r'.*\n.*\n.*\n.*\n.*', str(y)) f = re.findall(r'.*\n.*\n.*\n.*\n.*', str(y))
g = '这是当前的新人列表:\n' + f[0] + '\n...仅显示前5条内容' 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')) d.append(x['title'] + ' - ' + x['user'] + ' ' + UTC8(x['timestamp'], 'onlytime'))
m = '\n'.join(d) m = '\n'.join(d)
print(m) print(m)
y = await check([m]) y = await check(m)
print(y) print(y)
if y.find('<吃掉了>') != -1 or y.find('<全部吃掉了>') != -1: if y.find('<吃掉了>') != -1 or y.find('<全部吃掉了>') != -1:
msg = y + '\n...仅显示前5条内容\n检测到外来信息介入请前往最近更改查看所有消息。Special:最近更改' msg = y + '\n...仅显示前5条内容\n检测到外来信息介入请前往最近更改查看所有消息。Special:最近更改'

View file

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