[extend] Functionality of skipping schedule (#4)
[patch] Ignore words length smaller than 1
This commit is contained in:
parent
46c2af8125
commit
822679869f
@ -9,6 +9,9 @@ EXCLUSIVE_MODE = False
|
||||
# 配置私有模式群组id列表(不私有请忽略) 例如:[-1001324252532, -100112415423]
|
||||
EXCLUSIVE_LIST = []
|
||||
|
||||
# 跳过定时词云的群组
|
||||
SKIP_SCHEDULE_GROUP = []
|
||||
|
||||
# 主动触发命令仅管理员有效 False:否 True:是
|
||||
RANK_COMMAND_MODE = True
|
||||
|
||||
|
9
task.py
9
task.py
@ -8,7 +8,7 @@ import telegram
|
||||
import time
|
||||
import os
|
||||
import connector
|
||||
from config import TOKEN, FRONT, CHANNEL
|
||||
from config import TOKEN, FRONT, CHANNEL, SKIP_SCHEDULE_GROUP
|
||||
|
||||
bot = telegram.Bot(token=TOKEN)
|
||||
|
||||
@ -29,7 +29,10 @@ def schedule_task():
|
||||
for group in group_list:
|
||||
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:
|
||||
print("群组:{} | 词云数据分析生成失败,请查看报错信息".format(group))
|
||||
print(e)
|
||||
@ -132,7 +135,7 @@ def generate(group):
|
||||
# print(word + "\t" + flag)
|
||||
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)
|
||||
# print(word_list)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user