-
Notifications
You must be signed in to change notification settings - Fork 0
/
ialivetext.py
91 lines (81 loc) · 3.08 KB
/
ialivetext.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
import math
import time
import heroku3
import requests
from ...Config import Config
from .utils import get_readable_time
Heroku = heroku3.from_key(Config.HEROKU_API_KEY)
heroku_api = "https://api.heroku.com"
# UniBorg Telegram
# Copyright (C) 2020 @UniBorg
# This code is licensed under
# the "you can't use this for anything - public or private,
# unless you know the two prime factors to the number below" license
# 543935563961418342898620676239017231876605452284544942043082635399903451854594062955
# വിവരണം അടിച്ചുമാറ്റിക്കൊണ്ട് പോകുന്നവർ
# ക്രെഡിറ്റ് വെച്ചാൽ സന്തോഷമേ ഉള്ളു..!
# uniborg
def check_data_base_heal_th():
# https://stackoverflow.com/a/41961968
is_database_working = False
output = "No Database is set"
if not Config.DB_URI:
return is_database_working, output
from ...sql_helper import SESSION
try:
# to check database we will execute raw query
SESSION.execute("SELECT 1")
except Exception as e:
output = f"❌ {e}"
is_database_working = False
else:
output = "Functioning"
is_database_working = True
return is_database_working, output
async def zedalive(StartTime):
_, check_sgnirts = check_data_base_heal_th()
sudo = "Enabled" if Config.SUDO_USERS else "Disabled"
uptime = await get_readable_time((time.time() - StartTime))
try:
useragent = (
"Mozilla/5.0 (Linux; Android 10; SM-G975F) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/80.0.3987.149 Mobile Safari/537.36"
)
user_id = Heroku.account().id
headers = {
"User-Agent": useragent,
"Authorization": f"Bearer {Config.HEROKU_API_KEY}",
"Accept": "application/vnd.heroku+json; version=3.account-quotas",
}
path = f"/accounts/{user_id}/actions/get-quota"
r = requests.get(heroku_api + path, headers=headers)
result = r.json()
quota = result["account_quota"]
quota_used = result["quota_used"]
# Used
remaining_quota = quota - quota_used
math.floor(remaining_quota / quota * 100)
minutes_remaining = remaining_quota / 60
hours = math.floor(minutes_remaining / 60)
minutes = math.floor(minutes_remaining % 60)
# Current
App = result["apps"]
try:
App[0]["quota_used"]
except IndexError:
AppQuotaUsed = 0
else:
AppQuotaUsed = App[0]["quota_used"] / 60
math.floor(App[0]["quota_used"] * 100 / quota)
AppHours = math.floor(AppQuotaUsed / 60)
AppMinutes = math.floor(AppQuotaUsed % 60)
dyno = f"{AppHours}h {AppMinutes}m/{hours}h {minutes}m"
except Exception as e:
dyno = e
return f"🖤༄ ZThon Stats ༄🖤\
\n\nღ Database : {check_sgnirts}\
\nღ Sudo : {sudo}\
\nღ Uptime : {uptime}\
\nღ Dyno : {dyno}\
"