aboutsummarybugs & patchesrefslogtreecommitdiffstats
path: root/src/discord_image_bridge/_values.py
blob: 89e3c05137f1c628a072948c0467a43c17674af3 (about) (plain)
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
import os

__all__ = [
		"API_VERSION",
		"BASEURL",
		"TOKEN",
		"HOMEPAGE",
		"VERSION",
		"USERAGENT",
		]


API_VERSION=10
BASEURL="https://discord.com/api/v%d/"%API_VERSION

TOKEN=os.getenv("DISCORD_TOKEN")

from importlib.metadata import distribution as _distribution

_dist=_distribution(__package__)

# try to determine package homepage
_urls={}
for _value in _dist.metadata.get_all("Project-URL"):
	_name,_url=_value.split(", ")
	_urls[_name]=_url

for _possible in ["Homepage","Repository","Documentation"]:
	if _possible in _urls:
		HOMEPAGE=_urls[_possible]
		break
else:
	HOMEPAGE=_urls.values()[0]

del _possible, _urls, _value, _name, _url, _distribution # clean up

VERSION=_dist.version

del _dist

USERAGENT="DiscordBot (%s, %s)"%(HOMEPAGE, VERSION)