diff --git a/func.py b/func.py index ededd26..3b7417a 100644 --- a/func.py +++ b/func.py @@ -20,10 +20,12 @@ def chat_content_exec(update, context): r = connector.get_connection() text = update.message.text chat_type = update.effective_chat.type - if chat_type != "supergroup": - return user_id = update.effective_user.id chat_id = update.effective_message.chat_id + if chat_type != "supergroup": + return + # if chat_id not in ["1231242141"]: + # return try: username = update.effective_user.username except Exception as e: diff --git a/main.py b/main.py index 26829d1..f527ccb 100644 --- a/main.py +++ b/main.py @@ -2,11 +2,14 @@ from telegram.ext import Updater from config import TOKEN from func import start_handler, chat_content_handler, check_schedule import schedule -from task import do_task +from task import do_task, flush_redis import threading -schedule.every().day.at('23:30').do(do_task).tag('task') -# schedule.every(1).minutes.do(do_task).tag('task') +schedule.every().day.at('11:00').do(do_task) +schedule.every().day.at('18:00').do(do_task) +schedule.every().day.at('23:30').do(do_task) +schedule.every().day.at('23:59').do(flush_redis) +# schedule.every(1).minutes.do(do_task) threading.Thread(target=check_schedule).start() diff --git a/task.py b/task.py index 449c7c2..4d6fac5 100644 --- a/task.py +++ b/task.py @@ -127,5 +127,9 @@ def do_task(): except Exception as e: print(e) continue + + +def flush_redis(): + r = connector.get_connection() r.flushall() print("已清空数据库")