mirror of
https://github.com/SpudGunMan/meshing-around.git
synced 2026-08-04 07:52:35 +02:00
Update mesh_bot.py
This commit is contained in:
+6
-2
@@ -332,12 +332,15 @@ def send_message(message, ch, nodeid):
|
||||
# if message over 160 characters, split it into multiple messages
|
||||
if len(message) > 160:
|
||||
print (f"{log_timestamp()} System: Splitting Message, Message Length: {len(message)}")
|
||||
#message_list = [message[i:i+160] for i in range(0, len(message), 160)]
|
||||
# smarter word split
|
||||
# split the message into 160 character chunks
|
||||
|
||||
#message = message.replace('\n', ' NEWLINE ') # replace newlines with NEWLINE to keep them in split chunks
|
||||
|
||||
split_message = message.split()
|
||||
line = ''
|
||||
split_len = 160
|
||||
message_list = []
|
||||
|
||||
for word in split_message:
|
||||
if len(line+word)<split_len:
|
||||
line += word + ' '
|
||||
@@ -345,6 +348,7 @@ def send_message(message, ch, nodeid):
|
||||
message_list.append(line)
|
||||
line = word + ' '
|
||||
message_list.append(line) # needed add contents of the last 'line' into the list
|
||||
#message_list = [x.replace('NEWLINE', '\n') for x in message_list] # put back the newlines
|
||||
|
||||
for m in message_list:
|
||||
if nodeid == 0:
|
||||
|
||||
Reference in New Issue
Block a user