nothere990 commited on
Commit
99a7487
·
1 Parent(s): 36a7fa8
bot/__init__.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from hydrogram import Client
2
  from logging import getLogger
3
  from logging.config import dictConfig
@@ -6,6 +7,8 @@ from .config import Telegram, LOGGER_CONFIG_JSON
6
  dictConfig(LOGGER_CONFIG_JSON)
7
 
8
  version = 1.8
 
 
9
  logger = getLogger('bot')
10
 
11
  TelegramBot = Client(
 
1
+ import time
2
  from hydrogram import Client
3
  from logging import getLogger
4
  from logging.config import dictConfig
 
7
  dictConfig(LOGGER_CONFIG_JSON)
8
 
9
  version = 1.8
10
+ StartTime = time.time()
11
+
12
  logger = getLogger('bot')
13
 
14
  TelegramBot = Client(
bot/server/main.py CHANGED
@@ -1,9 +1,10 @@
1
  from quart import Blueprint, Response, request, render_template, redirect
2
  from math import ceil
 
3
  from re import match as re_match
4
  from .error import abort
5
- from bot import TelegramBot
6
- from bot.config import Telegram, Server
7
  from bot.modules.telegram import get_message, get_file_properties
8
 
9
  bp = Blueprint('main', __name__)
@@ -11,6 +12,15 @@ bp = Blueprint('main', __name__)
11
  @bp.route('/')
12
  async def home():
13
  return redirect(f'https://t.me/{Telegram.BOT_USERNAME}')
 
 
 
 
 
 
 
 
 
14
 
15
  @bp.route('/dl/<int:file_id>')
16
  async def transmit_file(file_id):
 
1
  from quart import Blueprint, Response, request, render_template, redirect
2
  from math import ceil
3
+ import time
4
  from re import match as re_match
5
  from .error import abort
6
+ from bot import TelegramBot, StartTime, utils
7
+ from bot.config import Telegram, Server, BOT_USERNAME
8
  from bot.modules.telegram import get_message, get_file_properties
9
 
10
  bp = Blueprint('main', __name__)
 
12
  @bp.route('/')
13
  async def home():
14
  return redirect(f'https://t.me/{Telegram.BOT_USERNAME}')
15
+
16
+
17
+ @bp.route('/status')
18
+ async def status():
19
+ return jsonify({
20
+ "status": "running",
21
+ "uptime": utils.get_readable_time(time.time() - StartTime),
22
+ "telegram_bot": "@" + BOT_USERNAME,
23
+ })
24
 
25
  @bp.route('/dl/<int:file_id>')
26
  async def transmit_file(file_id):
bot/utils/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .time_format import get_readable_time
bot/utils/time_format.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def get_readable_time(seconds: int) -> str:
2
+ count = 0
3
+ readable_time = ""
4
+ time_list = []
5
+ time_suffix_list = ["s", "m", "h", " days"]
6
+ while count < 4:
7
+ count += 1
8
+ if count < 3:
9
+ remainder, result = divmod(seconds, 60)
10
+ else:
11
+ remainder, result = divmod(seconds, 24)
12
+ if seconds == 0 and remainder == 0:
13
+ break
14
+ time_list.append(int(result))
15
+ seconds = int(remainder)
16
+ for x in range(len(time_list)):
17
+ time_list[x] = str(time_list[x]) + time_suffix_list[x]
18
+ if len(time_list) == 4:
19
+ readable_time += time_list.pop() + ", "
20
+ time_list.reverse()
21
+ readable_time += ": ".join(time_list)
22
+ return readable_time