-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathconfig.py
40 lines (32 loc) · 1.3 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from colorama import Fore
import requests
import yaml
class Config:
def read(self):
try:
file = open("./config/config.yaml", 'r', encoding='utf8')
except FileNotFoundError:
print(Fore.RED + 'Error: config.yaml file not found, rename EXAMPLE-config.yaml to config.yaml inside /config folder' + Fore.RESET)
exit()
with file as s:
stream = s.read()
return yaml.safe_load(stream)
def readGitHubExample(self):
data = requests.get(
url='https://raw.githubusercontent.com/newerton/bombcrypto-bot/main/config/EXAMPLE-config.yaml', timeout=2)
try:
configExample = yaml.safe_load(data.text)
except FileNotFoundError:
self.log.console(
'Config example file not found in GitHub', emoji='💥', color='red')
configExample = None
return configExample
def accounts(self):
try:
file = open("./config/accounts.yaml", 'r', encoding='utf8')
except FileNotFoundError:
print(Fore.RED + 'Error: accounts.yaml file not found, rename EXAMPLE-accounts.yaml to accounts.yaml inside /config folder' + Fore.RESET)
exit()
with file as s:
stream = s.read()
return yaml.safe_load(stream)