mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-08-28 05:14:12 +00:00
feat: enhance radio and admin configuration settings
Added new configuration options for radio health monitoring and alerting in config.ini.example, including radio_offline_threshold, radio_offline_alert_enabled, and radio_offline_alert_email. Introduced an [Admin] section with settings for a local admin API, including enabled, port, and token fields. Updated related files to reflect these changes, improving the organization and functionality of the configuration structure.
This commit is contained in:
+17
-1
@@ -50,6 +50,15 @@ radio_zombie_alert_enabled = false
|
||||
# Optional zombie alert recipients (comma-separated; empty = nightly recipients)
|
||||
radio_zombie_alert_email =
|
||||
|
||||
# Consecutive send timeouts before entering radio-offline state
|
||||
radio_offline_threshold = 3
|
||||
|
||||
# Send immediate radio-offline alert email (uses Notifications SMTP settings)
|
||||
radio_offline_alert_enabled = false
|
||||
|
||||
# Optional radio-offline alert recipients (comma-separated; empty = nightly recipients)
|
||||
radio_offline_alert_email =
|
||||
|
||||
[Bot]
|
||||
# Bot name for identification and logging
|
||||
bot_name = MeshCoreBot
|
||||
@@ -185,6 +194,13 @@ service_restart_backoff_seconds = 300
|
||||
# Max seconds to wait for a channel message send before timing out (default: 30)
|
||||
send_timeout_seconds = 30
|
||||
|
||||
[Admin]
|
||||
# Local admin API (binds to 127.0.0.1)
|
||||
enabled = false
|
||||
port = 5001
|
||||
# Required when enabled
|
||||
token =
|
||||
|
||||
[Channels]
|
||||
# Channels to monitor (comma-separated)
|
||||
# Bot will only respond to messages on these channels
|
||||
@@ -1718,7 +1734,7 @@ enabled = false
|
||||
|
||||
# Channels to post alerts to (comma-separated).
|
||||
# Prefer this option if you want multiple channels.
|
||||
channels = #general
|
||||
channels = #mybotchannel
|
||||
|
||||
# Fallback single channel option (used only when channels= is not set).
|
||||
# channel = #general
|
||||
|
||||
@@ -48,6 +48,15 @@ serial_port = /dev/ttyUSB0
|
||||
# Connection timeout in seconds
|
||||
timeout = 30
|
||||
|
||||
# Radio health / alert defaults
|
||||
radio_probe_interval_seconds = 300
|
||||
radio_probe_fail_threshold = 3
|
||||
radio_zombie_alert_enabled = false
|
||||
radio_zombie_alert_email =
|
||||
radio_offline_threshold = 3
|
||||
radio_offline_alert_enabled = false
|
||||
radio_offline_alert_email =
|
||||
|
||||
[Bot]
|
||||
# Bot name for identification and logging
|
||||
bot_name = MeshCoreBot
|
||||
@@ -157,6 +166,12 @@ db_path = meshcore_bot.db
|
||||
# Local plugins directory (optional). Default: local. See config.ini.example.
|
||||
#local_dir_path = local
|
||||
|
||||
[Admin]
|
||||
# Local admin API (127.0.0.1 only)
|
||||
enabled = false
|
||||
port = 5001
|
||||
token =
|
||||
|
||||
[Localization]
|
||||
# Language code for bot responses (en, es, es-MX, es-ES, fr, de, ja, etc.)
|
||||
# Default: en (English)
|
||||
|
||||
@@ -7,6 +7,13 @@
|
||||
connection_type = serial
|
||||
serial_port = /dev/ttyUSB0
|
||||
timeout = 30
|
||||
radio_probe_interval_seconds = 300
|
||||
radio_probe_fail_threshold = 3
|
||||
radio_zombie_alert_enabled = false
|
||||
radio_zombie_alert_email =
|
||||
radio_offline_threshold = 3
|
||||
radio_offline_alert_enabled = false
|
||||
radio_offline_alert_email =
|
||||
|
||||
[Bot]
|
||||
bot_name = MeshCoreBot
|
||||
@@ -19,6 +26,11 @@ bot_tx_rate_limit_seconds = 1.0
|
||||
per_user_rate_limit_seconds = 30
|
||||
per_user_rate_limit_enabled = true
|
||||
|
||||
[Admin]
|
||||
enabled = false
|
||||
port = 5001
|
||||
token =
|
||||
|
||||
[Channels]
|
||||
monitor_channels = general,test,emergency
|
||||
respond_to_dms = true
|
||||
|
||||
+5
-1
@@ -390,7 +390,11 @@ class MeshCoreBot:
|
||||
self._send_consecutive_failures: int = (
|
||||
getattr(self, '_send_consecutive_failures', 0) + 1
|
||||
)
|
||||
threshold = self.config.getint('Bot', 'radio_offline_threshold', fallback=3)
|
||||
threshold = self.config.getint(
|
||||
'Connection',
|
||||
'radio_offline_threshold',
|
||||
fallback=self.config.getint('Bot', 'radio_offline_threshold', fallback=3),
|
||||
)
|
||||
if self._send_consecutive_failures >= threshold and not self.is_radio_offline:
|
||||
self._radio_offline = True
|
||||
since = _dt.datetime.utcnow().isoformat()
|
||||
|
||||
+10
-2
@@ -1144,7 +1144,11 @@ class MessageScheduler:
|
||||
import ssl as _ssl
|
||||
from email.message import EmailMessage
|
||||
|
||||
alert_enabled = self.bot.config.getboolean('Bot', 'radio_offline_alert_enabled', fallback=True)
|
||||
alert_enabled = self.bot.config.getboolean(
|
||||
'Connection',
|
||||
'radio_offline_alert_enabled',
|
||||
fallback=self.bot.config.getboolean('Bot', 'radio_offline_alert_enabled', fallback=False),
|
||||
)
|
||||
if not alert_enabled:
|
||||
return
|
||||
|
||||
@@ -1155,7 +1159,11 @@ class MessageScheduler:
|
||||
from_name = self._get_notif('from_name') or 'MeshCore Bot'
|
||||
from_email = self._get_notif('from_email')
|
||||
|
||||
alert_email_cfg = self.bot.config.get('Bot', 'radio_offline_alert_email', fallback='').strip()
|
||||
alert_email_cfg = self.bot.config.get(
|
||||
'Connection',
|
||||
'radio_offline_alert_email',
|
||||
fallback=self.bot.config.get('Bot', 'radio_offline_alert_email', fallback=''),
|
||||
).strip()
|
||||
if alert_email_cfg:
|
||||
recipients = [r.strip() for r in alert_email_cfg.split(',') if r.strip()]
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user