mirror of
https://github.com/TheCommsChannel/TC2-BBS-mesh.git
synced 2025-03-05 20:51:53 -08:00
commit
7c3f3a3f92
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
import psutil
|
||||||
|
|
||||||
from config_init import initialize_config
|
from config_init import initialize_config
|
||||||
from db_operations import (
|
from db_operations import (
|
||||||
|
@ -47,9 +48,9 @@ def handle_help_command(sender_id, interface, state=None):
|
||||||
"[B]ulletin Menu",
|
"[B]ulletin Menu",
|
||||||
"[S]tats Menu",
|
"[S]tats Menu",
|
||||||
"[F]ortune",
|
"[F]ortune",
|
||||||
"[W]all of Shame",
|
#"[W]all of Shame",
|
||||||
"[C]hannel Directory",
|
#"[C]hannel Directory",
|
||||||
"EXIT: Exit current menu",
|
#"EXIT: Exit current menu",
|
||||||
"[H]elp"
|
"[H]elp"
|
||||||
]
|
]
|
||||||
if state and 'command' in state:
|
if state and 'command' in state:
|
||||||
|
@ -70,17 +71,16 @@ def handle_help_command(sender_id, interface, state=None):
|
||||||
]
|
]
|
||||||
elif current_command == 'STATS':
|
elif current_command == 'STATS':
|
||||||
commands = [
|
commands = [
|
||||||
"[0]Total Nodes",
|
"[0]Mesh Stats",
|
||||||
"[1]Total HW Models",
|
"[1]Server Stats",
|
||||||
"[2]Total Roles",
|
"[2]Exit Stats Menu"
|
||||||
"[3]Back"
|
|
||||||
]
|
]
|
||||||
response = title + "Available commands:\n" + "\n".join(commands)
|
response = title + "Available commands:\n" + "\n".join(commands)
|
||||||
send_message(response, sender_id, interface)
|
send_message(response, sender_id, interface)
|
||||||
|
|
||||||
|
|
||||||
def handle_stats_command(sender_id, interface):
|
def handle_stats_command(sender_id, interface):
|
||||||
response = "What stats would you like to view?\n\n[0]Node Numbers\n[1]Hardware\n[2]Roles\n[3]Main Menu"
|
response = "What stats would you like to view?\n\n[0]Mesh Stats\n[1]Server Stats\n[2]Exit Stats Menu"
|
||||||
send_message(response, sender_id, interface)
|
send_message(response, sender_id, interface)
|
||||||
update_user_state(sender_id, {'command': 'STATS', 'step': 1})
|
update_user_state(sender_id, {'command': 'STATS', 'step': 1})
|
||||||
|
|
||||||
|
@ -100,12 +100,29 @@ def handle_fortune_command(sender_id, interface):
|
||||||
|
|
||||||
|
|
||||||
def handle_stats_steps(sender_id, message, step, interface, bbs_nodes):
|
def handle_stats_steps(sender_id, message, step, interface, bbs_nodes):
|
||||||
if step == 1:
|
if step == 1:
|
||||||
choice = message.upper()
|
choice = int(message)
|
||||||
if choice == '3':
|
if choice == 2:
|
||||||
|
handle_help_command(sender_id, interface)
|
||||||
|
return
|
||||||
|
if choice == 0:
|
||||||
|
response = "What stats would you like to view?\n\n[0]Node Numbers\n[1]Hardware\n[2]Roles\n[3]Main Menu"
|
||||||
|
send_message(response, sender_id, interface)
|
||||||
|
update_user_state(sender_id, {'command': 'STATS', 'step': 2})
|
||||||
|
if choice == 1:
|
||||||
|
psutil.cpu_percent()
|
||||||
|
time.sleep(0.1)
|
||||||
|
cpu = str(psutil.cpu_percent()/psutil.cpu_count())
|
||||||
|
response = "CPU: " + cpu + "%"
|
||||||
|
send_message(response, sender_id, interface)
|
||||||
|
handle_stats_command(sender_id, interface)
|
||||||
|
return
|
||||||
|
|
||||||
|
elif step == 2:
|
||||||
|
choice = int(message)
|
||||||
|
if choice == 3:
|
||||||
handle_help_command(sender_id, interface)
|
handle_help_command(sender_id, interface)
|
||||||
return
|
return
|
||||||
choice = int(choice)
|
|
||||||
if choice == 0:
|
if choice == 0:
|
||||||
response = "Select time period for total nodes:\n\n[0]ALL\n[1]Last 24 Hours\n[2]Last 8 Hours\n[3]Last Hour"
|
response = "Select time period for total nodes:\n\n[0]ALL\n[1]Last 24 Hours\n[2]Last 8 Hours\n[3]Last Hour"
|
||||||
send_message(response, sender_id, interface)
|
send_message(response, sender_id, interface)
|
||||||
|
@ -127,7 +144,7 @@ def handle_stats_steps(sender_id, message, step, interface, bbs_nodes):
|
||||||
send_message(response, sender_id, interface)
|
send_message(response, sender_id, interface)
|
||||||
handle_stats_command(sender_id, interface)
|
handle_stats_command(sender_id, interface)
|
||||||
|
|
||||||
elif step == 2:
|
elif step == 3:
|
||||||
choice = int(message)
|
choice = int(message)
|
||||||
current_time = int(time.time())
|
current_time = int(time.time())
|
||||||
if choice == 0:
|
if choice == 0:
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
meshtastic
|
meshtastic
|
||||||
pypubsub
|
pypubsub
|
||||||
|
psutil
|
Loading…
Reference in a new issue