Skip to content

Commit

Permalink
fix subgroup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Toperlock authored Jan 5, 2024
1 parent 992284d commit 9085274
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def process_subscribes(subscribes):
add_prefix(_nodes, subscribe)
add_emoji(_nodes, subscribe)
if subscribe.get('subgroup'):
subscribe['tag'] = subscribe['subgroup']
subscribe['tag'] = subscribe['tag'] + '-' + subscribe['subgroup'] + '-' + 'subgroup'
if not nodes.get(subscribe['tag']):
nodes[subscribe['tag']] = []
nodes[subscribe['tag']] += _nodes
Expand Down Expand Up @@ -396,17 +396,17 @@ def combin_to_config(config, data):
config_outbounds = config["outbounds"] if config.get("outbounds") else None
i = 0
for group in data:
if 'tag' not in group:
if 'subgroup' in group:
i += 1
for out in config_outbounds:
if out.get("outbounds"):
if out['tag'] == 'proxy':
if '{all}' in out["outbounds"]:
index_of_all = out["outbounds"].index('{all}')
out["outbounds"][index_of_all] = group
out["outbounds"][index_of_all] = (group.rsplit("-", 1)[0]).rsplit("-", 1)[-1]
else:
out["outbounds"].insert(i + 1, group)
new_outbound = {'tag': group, 'type': 'selector', 'outbounds': ['{' + group + '}']}
out["outbounds"].insert(i + 1, (group.rsplit("-", 1)[0]).rsplit("-", 1)[-1])
new_outbound = {'tag': (group.rsplit("-", 1)[0]).rsplit("-", 1)[-1], 'type': 'selector', 'outbounds': ['{' + group + '}']}
config_outbounds.insert(-4, new_outbound)
else:
for out in config_outbounds:
Expand Down

0 comments on commit 9085274

Please sign in to comment.