This commit is contained in:
SpudGunMan
2024-08-04 01:23:16 -07:00
parent 78d957a9ae
commit 53a2fb88b3
4 changed files with 22 additions and 11 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi
bot_response = "No messages in history"
elif "bbshelp" in message.lower():
bot_response = bbs_help()
elif "cmd" in message.lower():
elif "cmd" in message.lower() or "cmd?" in message.lower():
bot_response = help_message
elif "sun" in message.lower():
location = get_node_location(message_from_id, deviceID)
+8 -6
View File
@@ -3,7 +3,7 @@ import configparser
# messages
NO_DATA_NOGPS = "No location data: does your device have GPS?"
ERROR_FETCHING_DATA = "error fetching data"
WELCOME_MSG = 'MeshBot, here for you like a friend who is not. Try sending: ping @foo or, cmd'
WELCOME_MSG = 'MeshBot, here for you like a friend who is not. Try sending: ping @foo or, cmd? for more'
MOTD = 'Thanks for using MeshBOT! Have a good day!'
NO_ALERTS = "No weather alerts found."
@@ -11,13 +11,17 @@ NO_ALERTS = "No weather alerts found."
MESSAGE_CHUNK_SIZE = 160 # message chunk size for sending at high success rate
SITREP_NODE_COUNT = 3 # number of nodes to report in the sitrep
msg_history = [] # message history for the store and forward feature
bbs_ban_list = [] # list of banned users
bbs_admin_list = [] # list of admin users
repeater_channels = [] # list of channels to listen on for repeater mode
bbs_ban_list = [] # list of banned users, imported from config
bbs_admin_list = [] # list of admin users, imported from config
repeater_channels = [] # list of channels to listen on for repeater mode, imported from config
antiSpam = True # anti-spam feature to prevent flooding public channel
ping_enabled = True # ping feature to respond to pings, ack's etc.
sitrep_enabled = True # sitrep feature to respond to sitreps
lastHamLibAlert = 0 # last alert from hamlib
max_retry_count1 = 4 # max retry count for interface 1
max_retry_count2 = 4 # max retry count for interface 2
retry_int1 = False
retry_int2 = False
# Read the config file, if it does not exist, create basic config file
config = configparser.ConfigParser()
@@ -41,8 +45,6 @@ interface1_type = config['interface'].get('type', 'serial')
port1 = config['interface'].get('port', '')
hostname1 = config['interface'].get('hostname', '')
mac1 = config['interface'].get('mac', '')
retry_int1 = False
retry_int2 = False
# interface2 settings
if 'interface2' in config:
+12 -3
View File
@@ -10,7 +10,7 @@ import asyncio
from modules.settings import *
# Global Variables
trap_list = ("cmd",) # default trap list
trap_list = ("cmd","cmd?") # default trap list
help_message = "CMD?:"
asyncLoop = asyncio.new_event_loop()
@@ -388,12 +388,13 @@ async def handleSignalWatcher():
pass
async def retry_interface(nodeID=1):
global interface1, interface2, retry_int1, retry_int2
global interface1, interface2, retry_int1, retry_int2, max_retry_count1, max_retry_count2
# retry connecting to the interface
# add a check to see if the interface is already open or trying to open
if nodeID==1:
if interface1 is not None:
retry_int1 = True
max_retry_count1 -= 1
try:
interface1.close()
except Exception as e:
@@ -401,13 +402,21 @@ async def retry_interface(nodeID=1):
if nodeID==2:
if interface2 is not None:
retry_int2 = True
max_retry_count2 -= 1
try:
interface2.close()
except Exception as e:
print(f"{log_timestamp()} System: Error closing interface2: {e}")
# wait 15 seconds before retrying
print(f"{log_timestamp()} System: Retrying interface in 15 seconds")
if max_retry_count1 == 0:
print(f"{log_timestamp()} System: Max retry count reached for interface1")
exit_handler()
if max_retry_count2 == 0:
print(f"{log_timestamp()} System: Max retry count reached for interface2")
exit_handler()
# wait 15 seconds before retrying
await asyncio.sleep(15)
# retry the interface
+1 -1
View File
@@ -38,7 +38,7 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi
bot_response = "MOTD Set to: " + MOTD
else:
bot_response = MOTD
elif "cmd" in message.lower():
elif "cmd" in message.lower() or "cmd?" in message.lower():
bot_response = help_message
elif "lheard" in message.lower() or "sitrep" in message.lower():
bot_response = "Last heard:\n" + str(get_node_list(1))