File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ async def list_commands(message: types.Message):
2121 "/start - Starts the bot.\n "
2222 "/help - lists all of the available commands.\n "
2323 "/now - Show server's live stats.\n "
24+ "/cpu_graph - Shows graph of CPU % over the last 24 hrs."
2425 )
2526
2627 @dp .message (~ IsOwner ())
Original file line number Diff line number Diff line change 77from app .services .clock import Clock
88from app .graph .graph_24hr import graph_cpu_load
99from app .database .readb import read_latest_24hr
10+ from aiogram .types import FSInputFile
1011
1112owner_id = int (os .getenv ("OWNER_ID" ))
1213
@@ -15,5 +16,18 @@ async def send_report_24hr(bot: Bot):
1516 print ("Waiting for 24 hr clock" )
1617 await Clock .daily_event .wait ()
1718 Clock .daily_event .clear ()
18- # cpu_load_graph = graph_cpu_load(read_latest_24hr())
19- await bot .send_message (chat_id = owner_id , text = "24-hour report triggered!" )
19+
20+ latest = await read_latest_24hr ()
21+ graph_cpu_load (latest )
22+
23+ base_dir = os .path .dirname (os .path .dirname (os .path .abspath (__file__ )))
24+ img_path = os .path .join (base_dir , 'graph' , 'cpu_load.png' )
25+
26+ if not os .path .exists (img_path ):
27+ await bot .send_message (chat_id = owner_id , text = f"Error: Graph file not found at { img_path } " )
28+ return
29+
30+ img = FSInputFile (img_path )
31+ await bot .send_photo (chat_id = owner_id , photo = img , caption = "Graph over the last 24 hrs" )
32+
33+ #await bot.send_message(chat_id=owner_id, text="24-hour report triggered!")
You can’t perform that action at this time.
0 commit comments