mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-10-30 01:32:22 +00:00
When a channel message had no RF log row yet, the handler stored it in pending_messages, slept 100 ms, then looked up find_recent_rf_data(payload["pubkey_prefix"]) through correlate_message_with_rf_data. Nothing else read the list: try_correlate_pending_messages only set a "processed" flag nobody checked, and cleanup_old_messages pruned it, both on every received packet. The wait and the second lookup stay, now written out directly. Results only differ where the list misbehaved (found by codex review): two messages entering the wait in the same millisecond with the same packet prefix shared one entry, so both got the second one's row, and now each gets its own; with message_correlation_timeout under 0.1 s the entry could be pruned during the wait, skipping the second lookup; and a non-string pubkey_prefix made the per-packet scan raise, logged as "Error handling RF log data". The list's DEBUG lines are gone with it. The list, its four methods and PendingMessageEntry were public names, so this goes in as its own change rather than a refactor. message_correlation_timeout is still read: it bounds how old an RF row can be and still match a channel message by its contents (#255). The example configs described it as a wait time; the comment now says what it does. New tests cover the wait (a row logged during it is found; no wait without enhanced correlation or for scope lookups). They pass against the previous code and one fails without the wait.
558 lines
22 KiB
Plaintext
558 lines
22 KiB
Plaintext
####################################################################################################
|
|
# #
|
|
# Minimal Configuration Example #
|
|
# #
|
|
# This is a minimal configuration file that enables only the core testing commands: #
|
|
# - ping: Simple connectivity test #
|
|
# - version (ver): Show running bot version #
|
|
# - test (t): Connection info with optional phrase #
|
|
# - path (p): Decode hex path data to show repeaters #
|
|
# - prefix: Look up repeaters by two-character prefix #
|
|
# - multitest (mt): Listen for multiple path variations #
|
|
# #
|
|
# All other commands and service plugins are explicitly disabled. This configuration is #
|
|
# intended for users who only want basic testing functionality without additional features. #
|
|
# #
|
|
# To use this configuration: #
|
|
# 1. Copy this file to config.ini #
|
|
# 2. Update the [Connection] section with your device settings #
|
|
# 3. Update the [Bot] section with your bot name and location #
|
|
# 4. Adjust other settings as needed #
|
|
# #
|
|
# To enable additional commands, set enabled = true in the appropriate command section below. #
|
|
# - Some disabled commands will require additional configuration options found in #
|
|
# config.ini.example to enable #
|
|
# #
|
|
####################################################################################################
|
|
|
|
[Connection]
|
|
# Connection type: serial, ble, or tcp
|
|
# Only keys for the active type are used; others are ignored (see config.ini.example).
|
|
connection_type = serial
|
|
|
|
# serial
|
|
serial_port = /dev/ttyUSB0
|
|
|
|
# ble — uncomment when connection_type = ble (empty ble_device_name = auto-detect)
|
|
#ble_device_name =
|
|
|
|
# tcp — uncomment when connection_type = tcp
|
|
#hostname = 192.168.1.60
|
|
#tcp_port = 5000
|
|
|
|
# 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
|
|
|
|
# RF Data Correlation Settings
|
|
# Time window for correlating RF data with messages (seconds)
|
|
rf_data_timeout = 15.0
|
|
|
|
# Oldest RF log row (seconds) a channel message can be matched to by its contents
|
|
message_correlation_timeout = 10.0
|
|
|
|
# Enable enhanced correlation strategies
|
|
enable_enhanced_correlation = true
|
|
|
|
# Bot node ID (leave empty for auto-assignment)
|
|
node_id =
|
|
|
|
# Respond to channel messages when the bot is mentioned via @[bot_name]
|
|
# Controls how the bot handles @[bot_name] mentions in channel messages:
|
|
# also - Default. Mention is stripped when present, but commands also work without a mention.
|
|
# Lets "@[BotName] ping" and "ping" both work.
|
|
# only - Bot only responds to channel messages that include @[bot_name].
|
|
# Messages without a mention are silently ignored.
|
|
# false - Mentions not handled; bot responds to all matching commands as before.
|
|
# DMs are always processed normally regardless of this setting.
|
|
respond_to_mentions = also
|
|
|
|
# Enable/disable bot responses
|
|
# true: Bot will respond to keywords and commands
|
|
# false: Bot will only listen and log messages
|
|
enabled = true
|
|
|
|
# Passive mode (only listen, don't respond)
|
|
# true: Bot will not send any messages
|
|
# false: Bot will respond normally
|
|
passive_mode = false
|
|
|
|
# Rate limiting in seconds between messages
|
|
# Prevents spam by limiting how often the bot can send messages
|
|
rate_limit_seconds = 10
|
|
|
|
# Bot transmission rate limit in seconds between bot messages
|
|
# Prevents bot from overwhelming the mesh network
|
|
bot_tx_rate_limit_seconds = 1.0
|
|
|
|
# Per-user rate limit: minimum seconds between bot replies to the same user
|
|
# User key: public key when available, else sender name
|
|
per_user_rate_limit_seconds = 30
|
|
per_user_rate_limit_enabled = true
|
|
|
|
# Transmission delay in milliseconds before sending messages
|
|
# Helps prevent message collisions on the mesh network
|
|
# Recommended: 100-500ms for busy networks, 0 for quiet networks
|
|
tx_delay_ms = 250
|
|
|
|
# DM retry settings for improved reliability (meshcore-2.1.6+)
|
|
# Maximum number of retry attempts for failed DM sends
|
|
dm_max_retries = 3
|
|
|
|
# Maximum flood attempts (when path reset is needed)
|
|
dm_max_flood_attempts = 2
|
|
|
|
# Number of attempts before switching to flood mode
|
|
dm_flood_after = 2
|
|
|
|
# Shortest time in seconds to wait for a DM's ACK on each attempt. The radio's
|
|
# own estimate is built from airtime and hop count with little fixed allowance,
|
|
# so on fast presets a zero-hop attempt can wait barely a second, shorter than
|
|
# the ACK takes to come back, and a delivered DM is reported as failed. An ACK
|
|
# still ends the wait at once; this only delays giving up on a DM that is never
|
|
# acknowledged. 0 uses the radio's estimate alone; at most 60.
|
|
dm_min_ack_timeout = 8
|
|
|
|
# Timezone for bot operations
|
|
# Use standard timezone names (e.g., America/New_York, Europe/London, UTC)
|
|
# Leave empty to use system timezone
|
|
timezone =
|
|
|
|
# Bot location for geographic proximity calculations and astronomical data
|
|
# Default latitude for bot location (decimal degrees)
|
|
# Example: 40.7128 for New York City, 48.50 for Victoria BC
|
|
bot_latitude = 40.7128
|
|
|
|
# Default longitude for bot location (decimal degrees)
|
|
# Example: -74.0060 for New York City, -123.00 for Victoria BC
|
|
bot_longitude = -74.0060
|
|
|
|
# Maximum number of channels to fetch from MeshCore node
|
|
# MeshCore supports up to 40 channels (default: 40)
|
|
# Set to a lower value if you want to limit channel fetching for performance
|
|
max_channels = 12
|
|
|
|
# Interval-based advertising settings
|
|
# Send periodic flood adverts at specified intervals
|
|
# 0: Disabled (default)
|
|
# >0: Send flood advert every N hours
|
|
advert_interval_hours = 0
|
|
|
|
# Send startup advert when bot finishes initializing
|
|
# false: No startup advert (default)
|
|
# zero-hop: Send local broadcast advert
|
|
# flood: Send network-wide flood advert
|
|
startup_advert = false
|
|
|
|
# Auto-manage contact list when new contacts are discovered
|
|
# device: Device handles auto-addition using standard auto-discovery mode, bot manages contact list capacity (purge old contacts when near limits) (default)
|
|
# bot: Bot automatically adds new companion contacts to device, bot manages contact list capacity (purge old contacts when near limits)
|
|
# false: Manual mode - no automatic actions, use !repeater commands to manage contacts
|
|
auto_manage_contacts = device
|
|
|
|
# Database path for main bot database
|
|
# Default: meshcore_bot.db
|
|
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)
|
|
# The bot will use translations from translations/{language}.json
|
|
# Supports locale codes:
|
|
# - Simple codes: en, es, fr, de, ja
|
|
# - Locale codes: es-MX (Mexican Spanish), es-ES (Spain Spanish), fr-CA (Canadian French)
|
|
# If locale-specific file not found, falls back to base language (e.g., es.json)
|
|
# If translation file is missing or key not found, falls back to English
|
|
language = en
|
|
|
|
# Path to translation files directory (relative to bot root)
|
|
# Default: translations/
|
|
translation_path = translations/
|
|
|
|
# Reply in the sender's language when detectable (default: false).
|
|
# Install the optional detector for longer messages: pip install meshcore-bot[lang]
|
|
auto_detect_language = false
|
|
|
|
[Admin_ACL]
|
|
# Admin Access Control List (ACL) for restricted commands
|
|
# Only users with public keys listed here can execute admin commands
|
|
#
|
|
# SECURITY IMPORTANT:
|
|
# - Public keys MUST be exactly 64 hexadecimal characters (ed25519 format)
|
|
# - Invalid formats will be rejected with error logs
|
|
# - Empty or whitespace-only values disable admin access
|
|
# - Keys are case-insensitive (normalized to lowercase)
|
|
#
|
|
# Format: comma-separated list of 64-character hex public keys (without spaces)
|
|
# Example: f5d2b56d19b24412756933e917d4632e088cdd5daeadc9002feca73bf5d2b56d,1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
|
|
#
|
|
# IMPORTANT: Leave blank to disable all admin commands. Set your actual admin pubkey(s) here.
|
|
admin_pubkeys =
|
|
|
|
# Commands that require admin access (comma-separated)
|
|
# These commands will only work for users in the admin_pubkeys list
|
|
# reload: Reload configuration without restarting (radio settings cannot be changed)
|
|
admin_commands = repeater,webviewer,reload,channelpause
|
|
|
|
[Keywords]
|
|
# Available placeholders (message-based):
|
|
# {sender} - Name/ID of message sender
|
|
# {connection_info} - Path info, SNR, and RSSI combined (e.g., "01,5f (2 hops) | SNR: 15 dB | RSSI: -120 dBm")
|
|
# {snr} - Signal-to-noise ratio in dB
|
|
# {rssi} - Received signal strength indicator in dBm
|
|
# {timestamp} - Message timestamp in HH:MM:SS format
|
|
# {path} - Message routing path (e.g., "01,5f (2 hops)")
|
|
# {hops} - Total hop count only (e.g., "2" or "0"); same value as in path/connection_info
|
|
# {hops_label} - Same as hops with word "hop"/"hops" and pluralization (e.g., "1 hop", "2 hops", or "?" when unknown)
|
|
# {path_distance} - Total distance between all hops in path with locations (e.g., "123.4km (3 segs, 1 no-loc)")
|
|
# {firstlast_distance} - Distance between first and last repeater in path (e.g., "45.6km" or empty if locations missing)
|
|
# {elapsed} - Elapsed time (e.g. 1234ms) or "Sync Device Clock" when device clock is invalid (use {elapsed} only; do not append ms)
|
|
test = "ack @[{sender}]{phrase_part} | {connection_info} | Received at: {timestamp}"
|
|
ping = "Pong!"
|
|
|
|
[Channels]
|
|
# Channels to monitor (comma-separated)
|
|
# Bot will only respond to messages on these channels
|
|
# Use exact channel names as configured on your MeshCore node
|
|
monitor_channels = general,test,emergency
|
|
|
|
# Enable DM responses
|
|
# true: Bot will respond to direct messages
|
|
# false: Bot will ignore direct messages
|
|
respond_to_dms = true
|
|
|
|
# Maximum hops for a message to get a response
|
|
# Code default when omitted: 64. This example uses 7 for a tighter local mesh.
|
|
max_response_hops = 7
|
|
|
|
# Optional: limit channel responses to certain keywords (e.g. help,ping,test).
|
|
# When set, only these triggers work in channels; DMs get all triggers.
|
|
# channel_keywords =
|
|
|
|
[Banned_Users]
|
|
# List of banned sender names (comma-separated). Matching is prefix (starts-with):
|
|
# "Awful Username" also matches "Awful Username 🍆". No bot responses in channels or DMs.
|
|
banned_users =
|
|
|
|
[Feed_Manager]
|
|
# Enable or disable RSS/API feed subscriptions (disabled by default)
|
|
feed_manager_enabled = false
|
|
# Allow private/internal feed URLs (default false for SSRF safety)
|
|
allow_private_urls = false
|
|
|
|
[Logging]
|
|
# Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
# DEBUG: Most verbose, shows all details
|
|
# INFO: Standard logging level
|
|
# WARNING: Only warnings and errors
|
|
# ERROR: Only errors
|
|
# CRITICAL: Only critical errors
|
|
log_level = INFO
|
|
|
|
# Log file path (leave empty for console/journald only)
|
|
# Bot and web viewer write to this file in addition to console when set.
|
|
# Empty: console only (captured by journald under systemd — preferred for services).
|
|
# systemd service installs use: /var/log/meshcore-bot/meshcore_bot.log
|
|
# Logs rotate at 5 MB with up to 3 backup files (e.g. meshcore_bot.log.1, .2, .3)
|
|
log_file = meshcore_bot.log
|
|
|
|
# Enable colored console output
|
|
# true: Use colors in console output
|
|
# false: Plain text output
|
|
colored_output = true
|
|
|
|
# MeshCore library log level (separate from bot log level)
|
|
# Controls debug output from the meshcore library itself
|
|
# Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
meshcore_log_level = INFO
|
|
|
|
####################################################################################################
|
|
# #
|
|
# Core Testing Commands Configuration #
|
|
# #
|
|
# This minimal configuration enables only the core testing commands: #
|
|
# - ping: Simple connectivity test #
|
|
# - version (ver): Show running bot version #
|
|
# - test (t): Connection info with optional phrase #
|
|
# - path (p): Decode hex path data to show repeaters #
|
|
# - prefix: Look up repeaters by two-character prefix #
|
|
# - multitest (mt): Listen for multiple path variations #
|
|
# - help: List available commands ('help <command>' for details) #
|
|
# #
|
|
####################################################################################################
|
|
|
|
[Ping_Command]
|
|
# Enable or disable the ping command
|
|
# true: Ping command is available
|
|
# false: Ping command is disabled
|
|
enabled = true
|
|
|
|
[Version_Command]
|
|
# Enable or disable the version command
|
|
# true: Version command is available (responds to 'version' or 'ver')
|
|
# false: Version command is disabled
|
|
enabled = true
|
|
|
|
[Test_Command]
|
|
# Enable or disable the test command
|
|
# true: Test command is available (responds to 'test' or 't')
|
|
# false: Test command is disabled
|
|
enabled = true
|
|
# Optional: overrides [Keywords] test; supports {field|pathbytes_min:2|prefix_if_nonempty: | Path Dist: } style filters (see config.ini.example [Test_Command])
|
|
# response_format =
|
|
|
|
[Path_Command]
|
|
# Enable or disable the path command
|
|
# true: Path command is available (responds to 'path', 'decode', 'route')
|
|
# false: Path command is disabled
|
|
enabled = true
|
|
|
|
# Enable "p" shortcut for path command (similar to "t" for test command)
|
|
# true: Respond to just "p" or "p <path_data>" as a shortcut for "path"
|
|
# false: Only respond to "path", "decode", or "route" keywords (default)
|
|
enable_p_shortcut = true
|
|
|
|
# Optional prefix on path replies: {sender}, {connection_info}, {path}, {hops}, {hops_label}, {timestamp}, {snr}, {rssi}
|
|
# reply_prefix = @[{sender}]
|
|
|
|
# Bytes per hop before DB repeater lookup (0/1 = off; 2 or 3 = gate weak paths to hex-only + tip)
|
|
# minimum_path_bytes = 0
|
|
|
|
# Geographic proximity calculation method
|
|
# simple: Use proximity to bot location (default)
|
|
# path: Use proximity to previous/next nodes in the path for more realistic routing
|
|
proximity_method = simple
|
|
|
|
# Enable path proximity fallback
|
|
# When path proximity can't be calculated (missing location data), fall back to simple proximity
|
|
# true: Fall back to bot location proximity when path data unavailable
|
|
# false: Show collision warning when path proximity unavailable
|
|
path_proximity_fallback = true
|
|
|
|
# Maximum range for geographic proximity guessing (kilometers)
|
|
# Repeaters beyond this distance will have reduced confidence or be rejected
|
|
# Set to 0 to disable range limiting
|
|
max_proximity_range = 200
|
|
|
|
# Maximum age for repeater data in path matching (days)
|
|
# Only include repeaters that have been heard within this many days
|
|
# Helps filter out stale or inactive repeaters from path decoding
|
|
# Set to 0 to disable age filtering
|
|
max_repeater_age_days = 14
|
|
|
|
# Recency vs Proximity weighting (0.0 to 1.0)
|
|
# Controls how much recency (when last heard) vs proximity (distance) matters
|
|
# 0.0 = 100% proximity (only distance matters)
|
|
# 1.0 = 100% recency (only when last heard matters)
|
|
# 0.4 = 40% recency, 60% proximity (default - balanced for path routing)
|
|
recency_weight = 0.4
|
|
|
|
[Prefix_Command]
|
|
# Enable or disable the prefix command
|
|
# true: Prefix command is available (responds to 'prefix', 'repeater', 'lookup')
|
|
# false: Prefix command is disabled
|
|
enabled = true
|
|
|
|
# Enable or disable repeater geolocation in prefix command
|
|
# true: Show city names with repeaters when location data is available
|
|
# false: Show only repeater names without location information
|
|
show_repeater_locations = true
|
|
|
|
# Use reverse geocoding for coordinates without city names
|
|
# true: Automatically look up city names from GPS coordinates
|
|
# false: Only show coordinates if no city name is available
|
|
use_reverse_geocoding = true
|
|
|
|
# Hide prefix source information
|
|
# true: Hide "Source: domain.com" line from prefix command output
|
|
# false: Show source information (default)
|
|
hide_source = false
|
|
|
|
# Prefix heard time window (days)
|
|
# Number of days to look back when showing prefix results (default command behavior)
|
|
# Only repeaters heard within this window will be shown by default
|
|
# Use "prefix XX all" to show all repeaters regardless of time
|
|
prefix_heard_days = 7
|
|
|
|
# Prefix free time window (days)
|
|
# Number of days to look back when determining which prefixes are "free"
|
|
# Only repeaters heard within this window will be considered as using a prefix
|
|
# Repeaters not heard in this window will be excluded from used prefixes list
|
|
prefix_free_days = 7
|
|
|
|
# Maximum range for prefix filtering (kilometers)
|
|
# Repeaters beyond this distance from bot location will be excluded from prefix lookups
|
|
# This prevents prefix collisions from far-away repeaters from affecting local prefix availability
|
|
# Set to 0 to disable range limiting
|
|
max_prefix_range = 200
|
|
|
|
[Multitest_Command]
|
|
# Enable or disable the multitest command
|
|
# true: Multitest command is available (responds to 'multitest' or 'mt')
|
|
# false: Multitest command is disabled
|
|
enabled = true
|
|
|
|
# Response format for multitest command results
|
|
# Available fields: {sender}, {path_count}, {paths}, {listening_duration}
|
|
# {sender}: Name/ID of message sender
|
|
# {path_count}: Number of unique paths found
|
|
# {paths}: Newline-separated list of paths
|
|
# {listening_duration}: Listening window duration in seconds
|
|
# Leave empty to use default format
|
|
# Example: "Found {path_count} unique path(s) for @[{sender}]:\n{paths}"
|
|
response_format = Found {path_count} unique path(s) for @[{sender}]:\n{paths}
|
|
|
|
[Help_Command]
|
|
# Enable or disable the help command
|
|
# true: Help command is available (responds to 'help'; 'help <command>' for details)
|
|
# false: Help command is disabled
|
|
# Recommended to leave enabled so users can discover the commands above.
|
|
enabled = true
|
|
|
|
####################################################################################################
|
|
# #
|
|
# All Other Commands Disabled #
|
|
# #
|
|
# The following commands are explicitly disabled in this minimal configuration. #
|
|
# To enable any of these commands, uncomment and set enabled = true in the appropriate section. #
|
|
# See config.ini.example for full options for each command. #
|
|
# #
|
|
####################################################################################################
|
|
|
|
[Cmd_Command]
|
|
# Enable or disable the cmd command
|
|
enabled = false
|
|
|
|
[Joke_Command]
|
|
enabled = false
|
|
|
|
[DadJoke_Command]
|
|
enabled = false
|
|
|
|
[Sports_Command]
|
|
enabled = false
|
|
|
|
[Worldcup_Command]
|
|
enabled = false
|
|
|
|
[Stats_Command]
|
|
enabled = false
|
|
|
|
[Hacker_Command]
|
|
enabled = false
|
|
|
|
[Greeter_Command]
|
|
# Enable or disable the greeter command
|
|
enabled = false
|
|
|
|
[Alert_Command]
|
|
enabled = false
|
|
|
|
[Announcements_Command]
|
|
# Enable or disable the announcements command
|
|
enabled = false
|
|
|
|
[Web_Viewer]
|
|
# Enable or disable the web data viewer
|
|
# Set web_viewer_password when host is not 127.0.0.1 (see config.ini.example)
|
|
enabled = false
|
|
|
|
[Wx_Command]
|
|
# Enable or disable the weather command
|
|
enabled = false
|
|
|
|
[Aqi_Command]
|
|
# Enable or disable the AQI command
|
|
enabled = false
|
|
|
|
[Sun_Command]
|
|
# Enable or disable the sun command
|
|
enabled = false
|
|
|
|
[Moon_Command]
|
|
# Enable or disable the moon command
|
|
enabled = false
|
|
|
|
[Solar_Command]
|
|
# Enable or disable the solar command
|
|
enabled = false
|
|
|
|
[Aurora_Command]
|
|
# Enable or disable the aurora command
|
|
enabled = false
|
|
|
|
[Solarforecast_Command]
|
|
# Enable or disable the solar forecast command
|
|
enabled = false
|
|
|
|
[Hfcond_Command]
|
|
# Enable or disable the HF conditions command
|
|
enabled = false
|
|
|
|
[Satpass_Command]
|
|
# Enable or disable the satellite pass command
|
|
enabled = false
|
|
|
|
[Catfact_Command]
|
|
# Enable or disable the catfact command
|
|
enabled = false
|
|
|
|
[Hello_Command]
|
|
# Enable or disable the hello command
|
|
enabled = false
|
|
|
|
[Channels_Command]
|
|
# Enable or disable the channels command
|
|
enabled = false
|
|
|
|
[Advert_Command]
|
|
# Enable or disable the advert command
|
|
enabled = false
|
|
|
|
[Dice_Command]
|
|
# Enable or disable the dice command
|
|
enabled = false
|
|
|
|
[Roll_Command]
|
|
# Enable or disable the roll command
|
|
enabled = false
|
|
|
|
[Magic8_Command]
|
|
# Enable or disable the magic 8 ball command
|
|
enabled = false
|
|
|
|
[Repeater_Command]
|
|
# Enable or disable the repeater command
|
|
enabled = false
|
|
|
|
[WebViewer_Command]
|
|
# Enable or disable the webviewer command
|
|
enabled = false
|
|
|
|
[Feed_Command]
|
|
# Enable or disable the feed command
|
|
enabled = false
|
|
# Allow private/internal feed URLs (default false for SSRF safety)
|
|
allow_private_urls = false
|