Add filters
This commit is contained in:
parent
c75da89032
commit
73b5319c60
34
FR2T/fr2t.py
34
FR2T/fr2t.py
@ -170,25 +170,34 @@ def handleRSS(rss, url, telegram, db, user_agent):
|
||||
exec(tmp_func)
|
||||
result[rule["dest"]] = loc["tmp_return"]
|
||||
|
||||
template = Template(rss["text"])
|
||||
send = True
|
||||
|
||||
args = dict(**result, **content, rss_name=rss["name"], rss_url=rss["url"])
|
||||
escapeAll(telegram["parse_mode"], args)
|
||||
if rss.get("filters"):
|
||||
for filter in rss["filters"]:
|
||||
obj = objParser(content, filter["obj"])
|
||||
if re.search(filter["matcher"], obj):
|
||||
send = False
|
||||
|
||||
text = template.render(args)
|
||||
if send:
|
||||
template = Template(rss["text"])
|
||||
|
||||
id1_hash = hashlib.md5(url.encode()).hexdigest()
|
||||
args = dict(**result, **content, rss_name=rss["name"], rss_url=rss["url"])
|
||||
escapeAll(telegram["parse_mode"], args)
|
||||
|
||||
id2 = content.get("id") or content.get("guid") or content.get("link")
|
||||
id2_hash = hashlib.md5(id2.encode()).hexdigest()
|
||||
text = template.render(args)
|
||||
|
||||
id = id1_hash + id2_hash
|
||||
id1_hash = hashlib.md5(url.encode()).hexdigest()
|
||||
|
||||
tmp_tg = copy.deepcopy(telegram)
|
||||
if rss.get("telegram"):
|
||||
tmp_tg.update(rss["telegram"])
|
||||
id2 = content.get("id") or content.get("guid") or content.get("link")
|
||||
id2_hash = hashlib.md5(id2.encode()).hexdigest()
|
||||
|
||||
handleText(rss["name"], id, text, tmp_tg, db)
|
||||
id = id1_hash + id2_hash
|
||||
|
||||
tmp_tg = copy.deepcopy(telegram)
|
||||
if rss.get("telegram"):
|
||||
tmp_tg.update(rss["telegram"])
|
||||
|
||||
handleText(rss["name"], id, text, tmp_tg, db)
|
||||
|
||||
|
||||
def handleText(name, id, text, tg, db):
|
||||
@ -197,7 +206,6 @@ def handleText(name, id, text, tg, db):
|
||||
text_posted = db[name].find_one({"text": text_hash})
|
||||
|
||||
if not text_posted:
|
||||
time.sleep(1)
|
||||
|
||||
id_posted = db[name].find_one({"id": id})
|
||||
if id_posted:
|
||||
|
@ -9,6 +9,9 @@ def objParser(obj: dict, url: str):
|
||||
paths = url.split(".")
|
||||
|
||||
for p in paths:
|
||||
if p.isdigit():
|
||||
p = int(p)
|
||||
|
||||
obj = obj[p]
|
||||
|
||||
return obj
|
||||
|
@ -108,7 +108,36 @@ rss:
|
||||
|
||||
💡 直达链接:{{ link }}
|
||||
|
||||
\#Apocalypsor的动漫订阅 \#{{ tag[2] }}
|
||||
\#Apocalypsor的动漫订阅 \#{{ tag[2] }}
|
||||
|
||||
- name: Github 订阅
|
||||
url:
|
||||
- https://github.com/Fndroid/clash_for_windows_pkg/releases.atom
|
||||
- https://github.com/Dreamacro/clash/commits/dev.atom
|
||||
- https://github.com/geekdada/surgio/commits/master.atom
|
||||
- https://github.com/DivineEngine/Profiles/commits/master.atom
|
||||
- https://github.com/Apocalypsor/My-Scoop-Bucket/commits/master.atom
|
||||
- https://github.com/blackmatrix7/ios_rule_script/commits/master.atom
|
||||
- https://github.com/fluid-dev/hexo-theme-fluid/releases.atom
|
||||
- https://github.com/cloudreve/Cloudreve/releases.atom
|
||||
- https://github.com/WangNingkai/OLAINDEX/commits/6.0.atom
|
||||
- https://github.com/miniflux/v2/releases.atom
|
||||
telegram:
|
||||
disable_web_page_preview: true
|
||||
rules:
|
||||
- obj: content.0.base
|
||||
type: regex
|
||||
matcher: https:\/\/github.com\/(.+?)\/(.+?)\/.+
|
||||
dest: repo
|
||||
filters:
|
||||
- obj: title
|
||||
matcher: Last updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}
|
||||
text: |
|
||||
🌀 项目更新:*{{ repo[1] }}/{{ repo[2] }}*
|
||||
|
||||
🐎 更新内容:[{{ title }}]({{ link }})
|
||||
|
||||
\#Apocalypsor的Github人订阅 \#{{ repo[2] }}
|
||||
|
||||
- name: 少数派
|
||||
url: https://sspai.com/feed
|
||||
|
Loading…
Reference in New Issue
Block a user