first commit

This commit is contained in:
cloudreflection 2023-04-01 21:57:04 +08:00
commit fcc3c98bdd
10 changed files with 1350 additions and 0 deletions

30
.gitignore vendored Normal file
View File

@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
pmcaptcha.py
.vscode/extensions.json

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# pmcaptcha_web-configure
[PMCaptcha](https://github.com/TeamPGM/PagerMaid_Plugins_Pyro/tree/v2/pmcaptcha) web-configure

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.svg">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PMCaptcha Web Configure</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

1027
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

20
package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "pmcaptcha_web-configure",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.47"
},
"devDependencies": {
"@vicons/utils": "^0.1.4",
"@vitejs/plugin-vue": "^4.0.0",
"naive-ui": "^2.34.3",
"vfonts": "^0.0.3",
"vite": "^4.1.4"
}
}

1
public/favicon.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 20 20"><g fill="none"><path d="M1.91 7.383a8.491 8.491 0 0 1 1.78-3.08a.5.5 0 0 1 .54-.135l1.918.686a1 1 0 0 0 1.32-.762l.366-2.006a.5.5 0 0 1 .388-.4a8.532 8.532 0 0 1 3.555 0a.5.5 0 0 1 .387.4l.367 2.006a1 1 0 0 0 1.32.762l1.918-.686a.5.5 0 0 1 .54.136a8.491 8.491 0 0 1 1.78 3.079a.5.5 0 0 1-.152.535l-1.555 1.32a1 1 0 0 0 0 1.524l1.555 1.32a.5.5 0 0 1 .152.535a8.491 8.491 0 0 1-1.78 3.08a.5.5 0 0 1-.54.135l-1.918-.686a1 1 0 0 0-1.32.762l-.367 2.007a.5.5 0 0 1-.387.399a8.53 8.53 0 0 1-3.555 0a.5.5 0 0 1-.388-.4l-.365-2.006a1 1 0 0 0-1.32-.762l-1.919.686a.5.5 0 0 1-.54-.136a8.49 8.49 0 0 1-1.78-3.079a.5.5 0 0 1 .153-.535l1.554-1.32a1 1 0 0 0 0-1.524l-1.554-1.32a.5.5 0 0 1-.153-.535zm1.061-.006l1.294 1.098a2 2 0 0 1 0 3.05L2.97 12.623c.292.782.714 1.51 1.245 2.152l1.596-.57a2 2 0 0 1 2.64 1.525l.305 1.668a7.556 7.556 0 0 0 2.485 0l.305-1.67a1.998 1.998 0 0 1 2.64-1.524l1.597.571a7.492 7.492 0 0 0 1.245-2.152l-1.294-1.098a1.998 1.998 0 0 1 0-3.05l1.294-1.098a7.491 7.491 0 0 0-1.245-2.152l-1.596.57a2 2 0 0 1-2.64-1.524l-.306-1.669a7.555 7.555 0 0 0-2.485 0l-.304 1.669a2 2 0 0 1-2.641 1.525l-1.596-.571a7.491 7.491 0 0 0-1.245 2.152zM7.5 10a2.5 2.5 0 1 1 5 0a2.5 2.5 0 0 1-5 0zm1 0a1.5 1.5 0 1 0 3 0a1.5 1.5 0 0 0-3 0z" fill="currentColor"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

152
src/App.vue Normal file
View File

@ -0,0 +1,152 @@
<template>
<n-layout>
<n-space vertical>
<n-layout-header style="height: 64px; padding: 24px" bordered>
<div style="font-size:medium;">PMCaptcha Web Configure</div>
</n-layout-header>
<n-layout-content content-style="display: flex;justify-content: center;">
<n-space vertical>
<n-card style="max-width: 1200px;">
<n-space vertical>
<n-alert title="无效的配置文件" type="warning" closable style="max-width: 1200px;" v-if="usedefault">
将使用默认配置
</n-alert>
<n-form label-placement="top" :model="model">
<n-grid :cols="24" :x-gap="24">
<n-form-item-gi :span="24" label="验证通过消息" path="welcome"><n-input type="textarea" :autosize="{
minRows: 1
}" placeholder="留空为默认消息" v-model:value="model.welcome"></n-input></n-form-item-gi>
<n-form-item-gi :span="12" label="关键词白名单列表(英文逗号分隔)" path="whitelist"><n-input type="text"
placeholder="留空以重置" v-model:value="model.whitelist"></n-input></n-form-item-gi>
<n-form-item-gi :span="12" label="关键词黑名单列表(英文逗号分隔)" path="blacklist"><n-input type="text"
placeholder="留空以重置" v-model:value="model.blacklist"></n-input></n-form-item-gi>
<n-form-item-gi :span="4" label="计算验证超时时间" path="timeout"><n-input-number placeholder="30"
:show-button="false" v-model:value="model.timeout">
<template #suffix>
</template>
</n-input-number></n-form-item-gi>
<n-form-item-gi :span="4" label="贴纸验证超时时间" path="sticker_timeout"><n-input-number placeholder="30"
:show-button="false" v-model:value="model.sticker_timeout">
<template #suffix>
</template>
</n-input-number></n-form-item-gi>
<n-form-item-gi :span="4" label="图像验证超时时间" path="img_timeout"><n-input-number placeholder="300"
:show-button="false" v-model:value="model.img_timeout">
<template #suffix>
</template>
</n-input-number></n-form-item-gi>
<n-form-item-gi :span="4" label="根据共群数量自动白名单" path="groups_in_common"><n-input-number placeholder="-1"
:show-button="false" v-model:value="model.groups_in_common">
</n-input-number></n-form-item-gi>
<n-form-item-gi :span="4" label="根据历史消息数自动白名单" path="chat_history"><n-input-number placeholder="-1"
:show-button="false" v-model:value="model.chat_history">
</n-input-number></n-form-item-gi>
<n-form-item-gi :span="4" label="轰炸检测触发人数" path="flood"><n-input-number placeholder="5"
:show-button="false" v-model:value="model.flood">
</n-input-number></n-form-item-gi>
<n-form-item-gi :span="4" label="图像验证码重试次数" path="img_captcha_retry"><n-input-number placeholder="3"
:show-button="false" v-model:value="model.img_captcha_retry">
</n-input-number></n-form-item-gi>
<n-form-item-gi :span="4" label="验证失败处理方式" path="action"> <n-select :options="actionlist"
v-model:value="model.action" /></n-form-item-gi>
<n-form-item-gi :span="4" label="验证码类型" path="type"> <n-select :options="typelist"
v-model:value="model.type" /></n-form-item-gi>
<n-form-item-gi :span="5" label="图像验证码接口" path="img_captcha"> <n-select :options="imgproviderlist"
v-model:value="model.img_captcha" /></n-form-item-gi>
<n-form-item-gi :span="5" label="轰炸结束后处理方式" path="flood_act"> <n-select :options="floodactlist"
v-model:value="model.flood_act" /></n-form-item-gi>
<n-form-item-gi :span="4" label="Premium 用户规则" path="premium"> <n-select :options="premiumlist"
v-model:value="model.premium" /></n-form-item-gi>
<n-form-item-gi :span="4" label="主动私聊自动白名单" path="initiative">
<n-switch v-model:value="model.initiative" />
</n-form-item-gi>
<n-form-item-gi :span="3" label="启用陌生人私聊" path="disable_pm">
<n-switch v-model:value="model.disable_pm" />
</n-form-item-gi>
<n-form-item-gi :span="3" label="验证失败时举报" path="report">
<n-switch v-model:value="model.report" />
</n-form-item-gi>
<n-form-item-gi :span="3" label="减少信息发送" path="silent">
<n-switch v-model:value="model.silent" />
</n-form-item-gi>
<n-form-item-gi :span="5" label="被轰炸时启用用户名频道转移" path="flood_username">
<n-switch v-model:value="model.flood_username" />
</n-form-item-gi>
<n-form-item-gi :span="5" label="允许PMCaptcha收集验证数据" path="collect_logs">
<n-switch v-model:value="model.collect_logs" />
</n-form-item-gi>
</n-grid>
</n-form>
</n-space>
</n-card>
<n-card style="max-width: 1200px;" title="将下面的命令粘贴至 Telegram 以应用设置">
<n-input type="textarea" :autosize="{
minRows: 1
}" readonly="true" v-model:value="cmd"></n-input>
</n-card></n-space>
</n-layout-content>
</n-space>
{{ newconf }}{{ conf }}
</n-layout>
{{ model }}
</template>
<script setup>
import { ref, watch } from 'vue';
import { NLayout, NLayoutHeader, NLayoutContent, NCard, NSpace, NGrid, NFormItemGi, NForm, NInput, NInputNumber, NSwitch, NAlert, NSelect } from 'naive-ui'
import { actionlist, premiumlist, typelist, floodactlist, imgproviderlist, defaults } from "./utils"
const usedefault = ref(false)
const conf = ref({ "cmd": defaults.cmd, "version": defaults.version })
try {
conf.value = JSON.parse(atob(location.pathname.replace(new RegExp("/", "g"), "")))
} catch (e) {
usedefault.value = true
}
const model = ref({
"welcome": "",
"blacklist": "",
"whitelist": "",
"timeout": null,
"img_timeout": null,
"sticker_timeout": null,
"disable_pm": false,
"action": "ban",
"report": true,
"premium": "none",
"groups_in_common": null,
"chat_history": null,
"initiative": true,
"silent": false,
"flood": null,
"flood_username": false,
"flood_act": "delete",
"collect_logs": true,
"type": "math",
"img_captcha": "func",
"img_captcha_retry": null
})
for (let i in conf.value) {
model.value[i] = conf.value[i]
}
const newconf = ref({})
const cmd = ref("," + conf.value.cmd + " web " + btoa(JSON.stringify(newconf.value)))
watch(model.value, (nv) => {
newconf.value = {}
for (let i in nv) {
console.log(i)
console.log(i in conf.value)
console.log(conf[i] !== model.value[i])
if (i in conf.value && conf.value[i] !== model.value[i]) {
newconf.value[i] = model.value[i]
}
if (i in conf.value === false && defaults[i] !== model.value[i]) {
newconf.value[i] = model.value[i]
}
}
cmd.value = "," + conf.value.cmd + " web " + btoa(JSON.stringify(newconf.value))
})
</script>

4
src/main.js Normal file
View File

@ -0,0 +1,4 @@
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')

86
src/utils.js Normal file
View File

@ -0,0 +1,86 @@
export const actionlist = [{
label: '封禁',
value: 'ban'
}, {
label: '封禁并删除对话',
value: 'delete'
}, {
label: '不执行任何操作',
value: 'none'
}]
export const premiumlist = [{
label: '白名单',
value: 'allow'
}, {
label: '封禁',
value: 'ban'
}, {
label: '不执行任何操作',
value: 'none'
}, {
label: '只允许',
value: 'only'
}]
export const typelist = [{
label: '计算验证',
value: 'math'
}, {
label: '图像辨识验证',
value: 'img'
}, {
label: ' 贴纸验证',
value: 'sticker'
}]
export const floodactlist = [{
label: '同验证失败处理',
value: 'asis'
}, {
label: '删除并举报(最快)',
value: 'delete'
}, {
label: '逐一进行 CAPTCHA 挑战',
value: 'captcha'
}, {
label: '不执行任何操作',
value: 'none'
}]
export const imgproviderlist = [{
label: 'ArkLabs funCaptcha',
value: 'func'
}, {
label: 'GitHub 螺旋星系',
value: 'github'
}, {
label: 'Google reCAPTCHA ',
value: 'rec'
}]
export const defaults = {
"welcome": "",
"blacklist": "",
"whitelist": "",
"timeout": null,
"img_timeout":null,
"sticker_timeout":null,
"disable_pm": false,
"action": "ban",
"report": true,
"premium": "none",
"groups_in_common": null,
"chat_history": null,
"initiative": true,
"silent": false,
"flood": null,
"flood_username": false,
"flood_act": "delete",
"collect_logs": true,
"type": "math",
"img_captcha": "func",
"img_captcha_retry": null,
"version": "2.26",
"cmd":"pmcaptcha"
}

14
vite.config.js Normal file
View File

@ -0,0 +1,14 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})