Adjust filter structure

This commit is contained in:
Richard Chien
2017-01-11 13:29:40 +08:00
parent 80386b910f
commit 461612e166
7 changed files with 85 additions and 45 deletions

16
app.py
View File

@ -24,7 +24,6 @@ def _handle_wx_message():
def _main(ctx_msg: dict):
_preprocess_ctx_msg(ctx_msg)
try:
if ctx_msg.get('post_type') != 'receive_message':
raise SkipException
@ -37,21 +36,6 @@ def _main(ctx_msg: dict):
return '', 204
def _preprocess_ctx_msg(ctx_msg: dict):
if 'group_uid' in ctx_msg:
ctx_msg['group_uid'] = str(ctx_msg['group_uid'])
if 'sender_uid' in ctx_msg:
ctx_msg['sender_uid'] = str(ctx_msg['sender_uid'])
if 'sender_id' in ctx_msg:
ctx_msg['sender_id'] = str(ctx_msg['sender_id'])
if 'discuss_id' in ctx_msg:
ctx_msg['discuss_id'] = str(ctx_msg['discuss_id'])
if 'group_id' in ctx_msg:
ctx_msg['group_id'] = str(ctx_msg['group_id'])
if 'id' in ctx_msg:
ctx_msg['id'] = str(ctx_msg['id'])
def _load_filters():
filter_mod_files = filter(
lambda filename: filename.endswith('.py') and not filename.startswith('_'),