Skip to content

Commit 99ebd7b

Browse files
committed
Cpu graph is now sent daily automatically
1 parent 070e631 commit 99ebd7b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

app/handlers/basic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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())

app/handlers/schedule.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from app.services.clock import Clock
88
from app.graph.graph_24hr import graph_cpu_load
99
from app.database.readb import read_latest_24hr
10+
from aiogram.types import FSInputFile
1011

1112
owner_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!")

0 commit comments

Comments
 (0)