-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from Cassius0924/feat-discord-message-forwarding
- Loading branch information
Showing
13 changed files
with
242 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
default_language_version: | ||
python: python3.8 | ||
|
||
python: python3.8 | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.1.14 | ||
hooks: | ||
- id: ruff | ||
- id: ruff-format | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
name: isort (python) | ||
- repo: https://github.com/PyCQA/bandit | ||
rev: 1.7.7 | ||
hooks: | ||
- id: bandit | ||
args: ['-c', 'pyproject.toml'] | ||
|
||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.1.14 | ||
hooks: | ||
- id: ruff | ||
- id: ruff-format | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
name: isort (python) | ||
- repo: https://github.com/PyCQA/bandit | ||
rev: 1.7.7 | ||
hooks: | ||
- id: bandit | ||
args: ['-c', 'pyproject.toml'] | ||
additional_dependencies: ["bandit[toml]"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
wechatter/config/parsers/discord_message_forwarding_rule_list_parser.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Dict, List, Tuple | ||
|
||
|
||
def parse_discord_message_forwarding_rule_list(rule_list: List) -> Tuple[Dict, Dict]: | ||
""" | ||
解析消息转发规则列表 | ||
:param rule_list: 消息转发规则列表 | ||
:return: 转发规则元组,第一个元素为全局转发规则,第二个元素为特定转发规则 | ||
""" | ||
all_message_rule = { | ||
"is_none": True, | ||
"from_list_exclude": [], | ||
"webhook_url": "", | ||
} | ||
specific_message_rules = {} | ||
for rule in rule_list: | ||
if "%ALL" in rule["from_list"]: | ||
all_message_rule["is_none"] = False | ||
all_message_rule["from_list_exclude"].extend( | ||
rule.get("from_list_exclude", []) | ||
) | ||
all_message_rule["webhook_url"] = rule["webhook_url"] | ||
else: | ||
for from_name in rule["from_list"]: | ||
if from_name not in specific_message_rules: | ||
specific_message_rules[from_name] = { | ||
"webhook_url": [], | ||
} | ||
specific_message_rules[from_name]["webhook_url"] = rule["webhook_url"] | ||
return all_message_rule, specific_message_rules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.