Patches like its 1999 (#318)

* new-pool-time

studyUp!

* patch-NONE

* fix loop
This commit is contained in:
Kelly
2026-06-06 13:35:42 -07:00
committed by GitHub
parent 3906c93874
commit fde22f75ea
6 changed files with 4822 additions and 1951 deletions
+1799 -601
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+10 -4
View File
@@ -1041,15 +1041,17 @@ def handleHamtest(message, nodeID, deviceID):
global hamtestTracker
index = 0
msg = ''
response = message.split(' ')
response = message.strip().split()
for i in range(len(hamtestTracker)):
if hamtestTracker[i]['nodeID'] == nodeID:
if hamtestTracker[i].get('nodeID') == nodeID:
hamtestTracker[i]["last_played"] = time.time()
index = i+1
if 'cmd' not in hamtestTracker[i]:
hamtestTracker[i]['cmd'] = 'playing'
index = i + 1
break
if not index:
hamtestTracker.append({"nodeID": nodeID,"last_played": time.time()})
hamtestTracker.append({"nodeID": nodeID, "cmd": "new", "last_played": time.time()})
if "end" in response[0].lower():
msg = hamtest.endGame(nodeID)
@@ -2190,6 +2192,10 @@ def onReceive(packet, interface):
else:
# message is not for us to respond to
# but if the sender is already playing a game, continue it.
if games_enabled and checkPlayingGame(message_from_id, message_string, rxNode, channel_number):
return
# ignore the message but add it to the message history list
if my_settings.zuluTime:
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
+30 -3
View File
@@ -65,7 +65,7 @@ class HamTest:
self.game[id]['question'] = question['question']
self.game[id]['answers'] = question['answers']
self.game[id]['correct'] = question['correct']
self.game[id]['correct'] = self.get_correct_index(question)
self.game[id]['qId'] = question['id']
self.game[id]['total'] -= 1
@@ -77,11 +77,38 @@ class HamTest:
for i, answer in enumerate(self.game[id]['answers']):
msg += f"{chr(65+i)}. {answer}\n"
return msg
def get_correct_index(self, question):
if question.get('correct_letter'):
letter = str(question['correct_letter']).strip().upper()
if len(letter) == 1 and 'A' <= letter <= 'D':
return ord(letter) - 65
if question.get('correct') is not None:
try:
return int(question['correct'])
except (ValueError, TypeError):
pass
return 0
def parse_answer(self, answer):
if not isinstance(answer, str):
return None
normalized = answer.strip().upper()
if normalized in ['A', 'B', 'C', 'D']:
return ord(normalized) - 65
if normalized.isdigit():
idx = int(normalized) - 1
if 0 <= idx < 4:
return idx
return None
def answer(self, id, answer):
if id not in self.game:
return "No game in progress"
if self.game[id]['correct'] == ord(answer.upper()) - 65:
answer_index = self.parse_answer(answer)
if answer_index is None:
return "Please answer with A, B, C, or D."
if self.game[id]['correct'] == answer_index:
self.game[id]['score'] += 1
return f"Correct👍\n" + self.nextQuestion(id)
else:
+2 -2
View File
@@ -1875,8 +1875,8 @@ def consumeMetadata(packet, rxNode=0, channel=-1):
routing_data = packet['decoded']['routing']
# Meshtastic Python/client can surface this field as errorReason or error_reason.
error_reason = routing_data.get('errorReason', routing_data.get('error_reason', ''))
if error_reason:
error_reason = str(routing_data.get('errorReason', routing_data.get('error_reason', ''))).strip()
if error_reason and error_reason.upper() != 'NONE':
requester_node = packet.get('from', nodeID)
requester_id = packet.get('fromId', '')
target_node = packet.get('to', 0)