-
Notifications
You must be signed in to change notification settings - Fork 2
/
TBOsmiumLib.py
162 lines (110 loc) · 3.37 KB
/
TBOsmiumLib.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#####################################################
# TBOsmiumLib version v1.1.0 by AnonymousHacker1279 #
#####################################################
EMBED_FEATURES = {
"title": "",
"description": "",
"image_url": "",
"footer": "",
"color": 0,
"thumbnail_url": "",
"author": {
"name": "",
"url": "",
"image_url": ""
},
"fields": {
"count": 0,
"entries": {}
}
}
PASSED_ARGUMENTS = []
# Internal functions
def __purge_embed_dict__():
global EMBED_FEATURES
EMBED_FEATURES = {
"title": "",
"description": "",
"image_url": "",
"footer": "",
"color": 0,
"thumbnail_url": "",
"author": {
"name": "",
"url": "",
"image_url": ""
},
"fields": {
"count": 0,
"entries": {}
}
}
def __purge_arguments_list__():
global PASSED_ARGUMENTS
PASSED_ARGUMENTS = []
def set_embed_title(title: str) -> str:
EMBED_FEATURES["title"] = title
return title
def get_embed_title() -> str:
return EMBED_FEATURES["title"]
def set_embed_description(description: str) -> str:
EMBED_FEATURES["description"] = description
return description
def get_embed_description() -> str:
return EMBED_FEATURES["description"]
def set_embed_image(image_url: str) -> str:
stripped_url = strip_chevrons_from_url(image_url)
EMBED_FEATURES["image_url"] = stripped_url
return stripped_url
def get_embed_image() -> str:
return EMBED_FEATURES["image_url"]
def set_embed_footer(footer: str) -> str:
EMBED_FEATURES["footer"] = footer
return footer
def get_embed_footer() -> str:
return EMBED_FEATURES["footer"]
def set_embed_color(decimal_code: int) -> int:
EMBED_FEATURES["color"] = decimal_code
return decimal_code
def get_embed_color() -> int:
return EMBED_FEATURES["color"]
def set_embed_thumbnail(image_url: str) -> str:
stripped_url = strip_chevrons_from_url(image_url)
EMBED_FEATURES["thumbnail_url"] = stripped_url
return stripped_url
def get_embed_thumbnail() -> str:
return EMBED_FEATURES["thumbnail_url"]
def set_embed_author(author_name: str, author_url: str = "", image_url: str = "") -> dict[str, str, str]:
stripped_author_url = strip_chevrons_from_url(author_url)
stripped_image_url = strip_chevrons_from_url(image_url)
EMBED_FEATURES["author"]["name"] = author_name
EMBED_FEATURES["author"]["url"] = stripped_author_url
EMBED_FEATURES["author"]["image_url"] = stripped_image_url
return EMBED_FEATURES["author"]
def get_embed_author() -> dict[str, str, str]:
return EMBED_FEATURES["author"]
def add_embed_field(name: str, value: str, inline: bool = True) -> [str, str, bool]:
EMBED_FEATURES["fields"]["entries"][name] = {
"value": value,
"inline": inline
}
EMBED_FEATURES["fields"]["count"] = EMBED_FEATURES["fields"]["count"] + 1
return name, value, inline
def remove_embed_field(name: str):
if EMBED_FEATURES["fields"]["count"] != 0:
EMBED_FEATURES["fields"]["entries"].pop(name)
EMBED_FEATURES["fields"]["count"] = EMBED_FEATURES["fields"]["count"] - 1
def get_embed_field_count() -> int:
return EMBED_FEATURES["fields"]["count"]
def get_arguments() -> list:
return PASSED_ARGUMENTS
# Helper functions go here
def get_version() -> str:
return "v1.1.0"
def strip_chevrons_from_url(url: str) -> str:
return url.lstrip('<').rstrip('>')
def hex_to_decimal(hex_code: str) -> int:
hex_code = hex_code.lstrip('#')
return int(hex_code, 16)
def rgb_to_decimal(r: int, g: int, b: int) -> int:
return (r << 16) + (g << 8) + b