[extend] Functionality of skipping schedule (#4)

[patch] Ignore words length smaller than 1
This commit is contained in:
Sam 2021-10-02 21:34:04 +08:00 committed by GitHub
parent 46c2af8125
commit 822679869f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -9,6 +9,9 @@ EXCLUSIVE_MODE = False
# 配置私有模式群组id列表不私有请忽略 例如:[-1001324252532, -100112415423] # 配置私有模式群组id列表不私有请忽略 例如:[-1001324252532, -100112415423]
EXCLUSIVE_LIST = [] EXCLUSIVE_LIST = []
# 跳过定时词云的群组
SKIP_SCHEDULE_GROUP = []
# 主动触发命令仅管理员有效 False:否 True:是 # 主动触发命令仅管理员有效 False:否 True:是
RANK_COMMAND_MODE = True RANK_COMMAND_MODE = True

View File

@ -8,7 +8,7 @@ import telegram
import time import time
import os import os
import connector import connector
from config import TOKEN, FRONT, CHANNEL from config import TOKEN, FRONT, CHANNEL, SKIP_SCHEDULE_GROUP
bot = telegram.Bot(token=TOKEN) bot = telegram.Bot(token=TOKEN)
@ -29,7 +29,10 @@ def schedule_task():
for group in group_list: for group in group_list:
try: try:
# 向任务队列中添加任务 # 向任务队列中添加任务
task_queue.put(group) if int(group) not in SKIP_SCHEDULE_GROUP:
task_queue.put(group)
else:
print(f"已跳过群组 {group} 的定时任务执行。")
except Exception as e: except Exception as e:
print("群组:{} | 词云数据分析生成失败,请查看报错信息".format(group)) print("群组:{} | 词云数据分析生成失败,请查看报错信息".format(group))
print(e) print(e)
@ -132,7 +135,7 @@ def generate(group):
# print(word + "\t" + flag) # print(word + "\t" + flag)
if flag in ["n", "nr", "nz", "PER", "f", "ns", "LOC", "s", "nt", "ORG", "nw"]: if flag in ["n", "nr", "nz", "PER", "f", "ns", "LOC", "s", "nt", "ORG", "nw"]:
# 判断该词是否有效,不为空格 # 判断该词是否有效,不为空格
if re.match(r"^\s+?$", word) is None: if re.match(r"^\s+?$", word) is None and len(word) > 1:
word_list.append(word) word_list.append(word)
# print(word_list) # print(word_list)