Skip to content

Commit

Permalink
Merge pull request #302 from AmiyaBot/V6-dev
Browse files Browse the repository at this point in the history
V6 dev
  • Loading branch information
vivien8261 authored Dec 30, 2024
2 parents df1fee7 + 6f4237c commit 5607778
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/publish.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.5.7
v6.5.8
2 changes: 1 addition & 1 deletion .github/workflows/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
with:
context: .
push: true
tags: amiyabot/amiyabot:2.0.2, amiyabot/amiyabot:latest
tags: amiyabot/amiyabot:6.5.8, amiyabot/amiyabot:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config/cos.yaml
config/remote.yaml
config/penetration.yaml
main*.py
start.zsh

*.pyc
*.spec
Expand Down
18 changes: 16 additions & 2 deletions core/config/remote.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import requests
from dataclasses import dataclass, field
from core.util import init_config_file


@dataclass
class Remote:
cos: str = 'https://cos.amiyabot.com'
plugin: str = 'https://server.amiyabot.com:10001'
plugin: str = 'https://cdn.amiyabot.com'
console: str = 'http://106.52.139.57:8000'

def __init__(self):
try:
res = requests.get(f'{self.plugin}/api/v1/remote')
data = res.json()
if res.status_code != 200 or not 'code' in data:
return
if data['code'] == 200:
self.cos = data['data']['cos']
self.plugin = data['data']['plugin']
self.console = data['data']['console']
except:
pass


@dataclass
Expand All @@ -15,7 +29,7 @@ class RemoteConfig:


def init(file: str) -> RemoteConfig:
return init_config_file(file, RemoteConfig)
return init_config_file(file, RemoteConfig, True)


remote_config = init('config/remote.yaml')
9 changes: 6 additions & 3 deletions core/util/yamlManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ def create_yaml(cls, path: str, data: dict, overwrite: bool = False):
return True


def init_config_file(file: str, build_cls):
def init_config_file(file: str, build_cls, refresh=False):
config = {}
if os.path.exists(file):
config = YamlManager.read_yaml(file, _dict=True)
config = YamlManager.read_yaml(file, _dict=True, _refresh=refresh)

YamlManager.create_yaml(file, merge_dict(config, asdict(build_cls())), True)
if not refresh:
YamlManager.create_yaml(file, merge_dict(config, asdict(build_cls())), True)
else:
YamlManager.create_yaml(file, asdict(build_cls()), True)
return YamlManager.read_yaml(file)

0 comments on commit 5607778

Please sign in to comment.