Browse Source

实现进群

master
欧醚 4 years ago
parent
commit
4a0ca7c1ae
Signed by: OmmyZhang GPG Key ID: 757D312E7C9D13F7
2 changed files with 29 additions and 16 deletions
  1. +25
    -12
      app.py
  2. +4
    -4
      templates/list.html

+ 25
- 12
app.py View File

@ -9,6 +9,18 @@ from datetime import datetime
from dateutil.tz import tzlocal
import html2text
from config import C
WRONG_ANS_HTML = '''<html>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width initial-scale=1'>
<title></title>
</head>
<body>
<h1></h1>
<a href="##" onclick="window.history.back()">退</a>
</body>
</html>
'''
app = Flask(__name__)
app.config.from_object('config.C')
@ -99,18 +111,7 @@ def new_one():
for name, ques, hint, ans in C.verify:
if request.form.get(name) != ans:
return '''<html>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width initial-scale=1'>
<title></title>
</head>
<body>
<h1></h1>
<a href="##" onclick="window.history.back()">退</a>
</body>
</html>
''', 401
return WRONG_ANS_HTML, 401
if not content or len(content)>4000: abort(422)
if private and len(private)>1000: abort(422)
@ -134,6 +135,18 @@ def new_one():
return redirect(".")
@app.route('/ordinary/judge', methods=['POST'])
@limiter.limit("10 / hour; 1 / 2 second")
def judge():
group = request.form.get('groupType')
for name, ques, hint, ans in C.verify:
if request.form.get(name) != ans:
return WRONG_ANS_HTML, 401
return redirect(C.groups.get(group))
@limiter.limit("100 / hour; 2 / second")
@app.route('/ordinary/<int:toot>/comments')
def get_comments(toot):

+ 4
- 4
templates/list.html View File

@ -258,15 +258,15 @@
<div style="text-align:center">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="groupType" value="mx">
<input class="form-check-input" type="radio" name="groupType" value="mx" required>
<label class="form-check-label" for="mx">闭聊</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="groupType" value="tg">
<input class="form-check-input" type="radio" name="groupType" value="tg" required>
<label class="form-check-label" for="tg">Telegram</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="groupType" value="wx">
<input class="form-check-input" type="radio" name="groupType" value="wx" required>
<label class="form-check-label" for="wx">微信</label>
</div>
</div>
@ -279,7 +279,7 @@
</div>
</div>
{% endfor %}
<p>(火热开发中... 马上就可以点了)</p>
<buttonpan> type="submit" class="btn btn-link btn-lg">进群</button>
</div>
</form>
</div>

Loading…
Cancel
Save