-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
128 lines (109 loc) · 2.77 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
'''
Author: k1rk and charge
Copyright: Zeus Selfbot (c) inc.
'''
# -- standard libraries -- #
import os
import sys
import json
from typing import Optional, Dict, List
from pathlib import Path
# -- 3rd party libararies -- #
from pydantic import BaseModel
# -- base classes that are used to validate the config -- #
class Token(BaseModel):
token: str
class Embeds(BaseModel):
title = 'Buy Zeus for yourself today!'
description = 'Advanced Customizable Selfbot'
author = 'Authors: k1rk & Charge'
author_url: Optional[str] = None
footer = 'Zeus Selfbot Inc. (c)'
footer_url: Optional[str] = None
image_url: Optional[str] = None
link: Optional[str] = None
thumbnail: Optional[str] = None
delete_after = 5
color = 0x000000
class Bot(BaseModel):
name = 'Zeus Selfbot'
prefix = '.'
token: str
presence = False
sniper = False
delete = False
log = False
class Presence(BaseModel):
state = 'Zeus - Coming Soon'
details = 'Advanced Selfbot'
hover_big = 'DM .k#1999 or charge#0666'
hover_small = 'Zeus Selfbot'
class Logging(BaseModel):
keywords: List[str]
user_ids: List[int]
guild_ids: List[int]
# -- main class for holding the config -- #
class Config:
log = None
rp = None
token = None
embeds = None
bot = None
# -- Main class used to load the config -- #
class Loader:
'''
class that opens json config
loads it in and validates that each value
is correct
'''
def __init__(self, filename):
self.filename = filename
@classmethod
def die(cls, info, e):
print(
f'Zeus Selfbot (c)\n'
f'Info: {info if info else "nil"}\n'
f'Error: {getattr(e, "message", repr(e)) if e else "nil"}',
file=sys.stderr
)
sys.exit(-1)
def get_config(self):
# check if file is there
if not self.filename.exists():
Loader.die(
f'Config File: {self.filename}, Could not be found in local dir',
None
)
# attempt to open the file
try:
with open(self.filename, 'r') as cf:
config = json.load(cf)
except Exception as e:
Loader.die(
f'Could Not Open File and or Read File Into Json Format',
e
)
# return config
return config
def load_config(self):
# grab json
data = self.get_config()
# check that base keys exist
if any(
data.get(x) is None for x in (
'logging', 'embeds',
'presence', 'bot'
)
):
Loader.die(
f'Missing Key In Json Config File: [{self.filename}]',
None
)
# fill out config
config = Config()
config.embeds = Embeds(**data['embeds'])
config.bot = Bot(**data['bot'])
config.rp = Presence(**data['presence'])
config.log = Logging(**data['logging'])
# return new config
return config