mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-07-06 18:01:18 +02:00
Update mesh_bot.py
This commit is contained in:
+6
-5
@@ -494,15 +494,16 @@ def handle_history(nodeid, deviceID, lheard=False):
|
|||||||
if prettyTime < 60:
|
if prettyTime < 60:
|
||||||
prettyTime = str(prettyTime) + "m"
|
prettyTime = str(prettyTime) + "m"
|
||||||
elif prettyTime < 1440:
|
elif prettyTime < 1440:
|
||||||
prettyTime = str(prettyTime/60) + "h"
|
prettyTime = str(round(prettyTime/60)) + "h"
|
||||||
else:
|
else:
|
||||||
prettyTime = str(prettyTime/1440) + "d"
|
prettyTime = str(round(prettyTime/1440)) + "d"
|
||||||
|
|
||||||
# history display output
|
# history display output
|
||||||
if nodeid in bbs_admin_list and not cmdHistory[i]['nodeID'] in lheardCmdIgnoreNode:
|
if nodeid in bbs_admin_list and not cmdHistory[i]['nodeID'] in lheardCmdIgnoreNode:
|
||||||
msg += f"{get_name_from_number(nodeid,'short',deviceID)}:cmd:{cmdHistory[i]['cmd']}/{prettyTime} ago.\n"
|
msg += f"{get_name_from_number(nodeid,'short',deviceID)}:cmd:{cmdHistory[i]['cmd']}/{prettyTime} ago.\n"
|
||||||
elif cmdHistory[i]['nodeID'] == nodeid and not cmdHistory[i]['nodeID'] in lheardCmdIgnoreNode:
|
elif cmdHistory[i]['nodeID'] == nodeid and not cmdHistory[i]['nodeID'] in lheardCmdIgnoreNode:
|
||||||
msg += f"{get_name_from_number(nodeid,'short',deviceID)}:cmd:{cmdHistory[i]['cmd']}/{prettyTime} ago.\n"
|
msg += f"{get_name_from_number(nodeid,'short',deviceID)}:cmd:{cmdHistory[i]['cmd']}/{prettyTime} ago.\n"
|
||||||
|
# message for output of the last commands
|
||||||
msg = msg.rstrip()
|
msg = msg.rstrip()
|
||||||
# only return the last 4 commands
|
# only return the last 4 commands
|
||||||
if len(msg) > 0:
|
if len(msg) > 0:
|
||||||
@@ -517,16 +518,16 @@ def handle_history(nodeid, deviceID, lheard=False):
|
|||||||
if prettyTime < 60:
|
if prettyTime < 60:
|
||||||
prettyTime = str(prettyTime) + "m"
|
prettyTime = str(prettyTime) + "m"
|
||||||
elif prettyTime < 1440:
|
elif prettyTime < 1440:
|
||||||
prettyTime = str(prettyTime/60) + "h"
|
prettyTime = str(round(prettyTime/60)) + "h"
|
||||||
else:
|
else:
|
||||||
prettyTime = str(prettyTime/1440) + "d"
|
prettyTime = str(round(prettyTime/1440)) + "d"
|
||||||
|
|
||||||
if not cmdHistorySorted[i]['nodeID'] in lheardCmdIgnoreNode:
|
if not cmdHistorySorted[i]['nodeID'] in lheardCmdIgnoreNode:
|
||||||
# add line to a new list for display
|
# add line to a new list for display
|
||||||
nodeName = get_name_from_number(cmdHistorySorted[i]['nodeID'], 'short', deviceID)
|
nodeName = get_name_from_number(cmdHistorySorted[i]['nodeID'], 'short', deviceID)
|
||||||
if not any(d[0] == nodeName for d in buffer):
|
if not any(d[0] == nodeName for d in buffer):
|
||||||
buffer.append((nodeName, prettyTime))
|
buffer.append((nodeName, prettyTime))
|
||||||
# truncate buffer list to 4 users
|
# message for output of the last users of the bot
|
||||||
if len(buffer) > 4:
|
if len(buffer) > 4:
|
||||||
buffer = buffer[-4:]
|
buffer = buffer[-4:]
|
||||||
# create the message from the buffer list
|
# create the message from the buffer list
|
||||||
|
|||||||
Reference in New Issue
Block a user