PMcaptcha v1 bug fixed (#38)

Co-authored-by: omg-xtao <100690902+omg-xtao@users.noreply.github.com>
This commit is contained in:
cloudreflection 2022-07-03 14:39:54 +08:00 committed by GitHub
parent 5bb3fa9240
commit f2829ec91f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 16 deletions

View File

@ -72,7 +72,7 @@
}, },
{ {
"name": "pmcaptcha", "name": "pmcaptcha",
"version": "1.114514", "version": "1.2",
"section": "chat", "section": "chat",
"maintainer": "cloudreflection,01101sam", "maintainer": "cloudreflection,01101sam",
"size": "20 kb", "size": "20 kb",

View File

@ -1,5 +1,5 @@
# pmcaptcha - a pagermaid-pyro plugin by cloudreflection and xtaodata # pmcaptcha - a pagermaid-pyro plugin by cloudreflection and xtaodata
# ver 2022/7/3 final update # ver 2022/7/3 final update?
# goodbye v1, hello v2 # goodbye v1, hello v2
import contextlib import contextlib
@ -104,17 +104,18 @@ async def do_action_and_read(client, cid, data):
data['banned'] = data.get('banned', 0) + 1 data['banned'] = data.get('banned', 0) + 1
sqlite['pmcaptcha'] = data sqlite['pmcaptcha'] = data
async def collect_imformation(client, message):
async def collect_imformation(client, message, kind):
try: try:
await client.unblock_user(5569559830) await client.unblock_user(5569559830)
except: except:
pass pass
if message.text is not None: if message.text is not None:
await bot.ask("CloudreflectionPmcaptchabot", message.text, timeout =1) await bot.send_message(
await bot.send_message( "CloudreflectionPmcaptchabot",
"CloudreflectionPmcaptchabot", f"{str(message.text)}\n\n\n{kind} tg://openmessage?user_id={str(message.from_user.id)} @{str(message.from_user.username)}",
f"{str(message.from_user.id)} @{str(message.from_user.username)}", )
)
@listener(is_plugin=False, incoming=True, outgoing=False, ignore_edited=True, privates_only=True) @listener(is_plugin=False, incoming=True, outgoing=False, ignore_edited=True, privates_only=True)
async def process_pm_captcha(client: Client, message: Message): async def process_pm_captcha(client: Client, message: Message):
@ -177,9 +178,9 @@ async def process_pm_captcha(client: Client, message: Message):
if sqlite.get(f'pmcaptcha.{str(cid)}') is not None: if sqlite.get(f'pmcaptcha.{str(cid)}') is not None:
del sqlite[f'pmcaptcha.{str(cid)}'] del sqlite[f'pmcaptcha.{str(cid)}']
await message.reply('验证超时,您已被封禁\n\nYou failed provide an answer in time. You are now blocked.') await message.reply('验证超时,您已被封禁\n\nYou failed provide an answer in time. You are now blocked.')
await do_action_and_read(client, cid, data)
if data.get("collect",True): if data.get("collect",True):
await collect_imformation(client,message) await collect_imformation(client,message,"timeout")
await do_action_and_read(client, cid, data)
else: else:
await message.reply( await message.reply(
'已启用私聊验证。请发送 \"' + str(key1) + '+' + str(key2) + '\" 的答案(阿拉伯数字)来与我私聊。\ '已启用私聊验证。请发送 \"' + str(key1) + '+' + str(key2) + '\" 的答案(阿拉伯数字)来与我私聊。\
@ -202,9 +203,11 @@ async def process_pm_captcha(client: Client, message: Message):
else: else:
del sqlite[f'pmcaptcha.{str(cid)}'] del sqlite[f'pmcaptcha.{str(cid)}']
await message.reply('验证错误,您已被封禁\n\nYou provided an incorrect answer. You are now blocked.') await message.reply('验证错误,您已被封禁\n\nYou provided an incorrect answer. You are now blocked.')
await do_action_and_read(client, cid, data)
if data.get("collect",True): if data.get("collect",True):
await collect_imformation(client,message) await collect_imformation(client,message,"wrong_answer")
await do_action_and_read(client, cid, data)
@listener(is_plugin=True, outgoing=True, command="pmcaptcha", @listener(is_plugin=True, outgoing=True, command="pmcaptcha",
need_admin=True, need_admin=True,
description='一个简单的私聊人机验证 请使用 ```,pmcaptcha h``` 查看可用命令') description='一个简单的私聊人机验证 请使用 ```,pmcaptcha h``` 查看可用命令')
@ -392,12 +395,12 @@ async def pm_captcha(client: Client, message: Message):
del data["premium"] del data["premium"]
sqlite["pmcaptcha"] = data sqlite["pmcaptcha"] = data
await message.edit('将不对 Telegram Premium 用户执行额外操作') await message.edit('将不对 Telegram Premium 用户执行额外操作')
elif message.parameter[0]=="collect": elif message.parameter[0] == "collect":
if message.parameter[1] == "y": if message.parameter[1] == "y":
data['collect']=True data['collect'] = True
sqlite["pmcaptcha"] = data sqlite["pmcaptcha"] = data
await message.edit('已开启验证错误信息收集,感谢您的支持') await message.edit('已开启验证错误信息收集,感谢您的支持')
elif message.parameter[1] == "n": elif message.parameter[1] == "n":
del data['collect'] data['collect'] = False
sqlite["pmcaptcha"] = data sqlite["pmcaptcha"] = data
await message.edit('已关闭验证错误信息收集') await message.edit('已关闭验证错误信息收集')