use os.linesep just in case
This commit is contained in:
parent
099953f96b
commit
6aee75c803
18
main.py
18
main.py
@ -36,7 +36,7 @@ config = {
|
|||||||
"print_status_after_insert" : True,
|
"print_status_after_insert" : True,
|
||||||
"output_buffer_timeout" : 0.05, # 50 milliseconds
|
"output_buffer_timeout" : 0.05, # 50 milliseconds
|
||||||
"default_history" : 100,
|
"default_history" : 100,
|
||||||
"fixed_width" : 78, # Need room for the pre-message decoration
|
"fixed_width" : 76, # Need room for the pre-message decoration
|
||||||
"tokenfile" : ".qcstoken"
|
"tokenfile" : ".qcstoken"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ def ws_onopen(ws):
|
|||||||
|
|
||||||
def main_loop():
|
def main_loop():
|
||||||
|
|
||||||
printr(Fore.GREEN + Style.BRIGHT + "\n-- Connected to live updates! --")
|
printr(Fore.GREEN + Style.BRIGHT + os.linesep + "-- Connected to live updates! --")
|
||||||
|
|
||||||
if not ws.current_room:
|
if not ws.current_room:
|
||||||
printr(Fore.YELLOW + "* You are not connected to any room! Press 'S' to search for a room! *")
|
printr(Fore.YELLOW + "* You are not connected to any room! Press 'S' to search for a room! *")
|
||||||
@ -220,7 +220,7 @@ def ws_onmessage(ws, message):
|
|||||||
for key,value in statuses.items():
|
for key,value in statuses.items():
|
||||||
key = int(key)
|
key = int(key)
|
||||||
user = contentapi.get_user_or_default(result["data"]["objects"]["user"], key)
|
user = contentapi.get_user_or_default(result["data"]["objects"]["user"], key)
|
||||||
userlist_output += "\n" + Style.BRIGHT + " " + ("%s" % (user["username"] + Style.DIM + " #%d" % key)) + Style.RESET_ALL + " - " + value
|
userlist_output += os.linesep + Style.BRIGHT + " " + ("%s" % (user["username"] + Style.DIM + " #%d" % key)) + Style.RESET_ALL + " - " + value
|
||||||
ws_print(ws, userlist_output)
|
ws_print(ws, userlist_output)
|
||||||
return
|
return
|
||||||
# Live updates are messages, edits, user updates, etc. Check the event list to see
|
# Live updates are messages, edits, user updates, etc. Check the event list to see
|
||||||
@ -244,10 +244,10 @@ def ws_onmessage(ws, message):
|
|||||||
# Produce the string output for a given message. Can be printed directly to console
|
# Produce the string output for a given message. Can be printed directly to console
|
||||||
def get_message_string(ws, message, user):
|
def get_message_string(ws, message, user):
|
||||||
result = (MSGPREFIX + Fore.CYAN + Style.BRIGHT + user["username"] + " " + Style.DIM + "#%d" % user["id"] +
|
result = (MSGPREFIX + Fore.CYAN + Style.BRIGHT + user["username"] + " " + Style.DIM + "#%d" % user["id"] +
|
||||||
Fore.MAGENTA + " " + message["createDate"] + " [%d]" % message["id"] + "\n" + Style.RESET_ALL)
|
Fore.MAGENTA + " " + message["createDate"] + " [%d]" % message["id"] + os.linesep + Style.RESET_ALL)
|
||||||
for t in textwrap.wrap(message["text"], width = ws.main_config["fixed_width"]):
|
for t in textwrap.wrap(message["text"], width = ws.main_config["fixed_width"]):
|
||||||
result += (MSGPREFIX + t + "\n")
|
result += (MSGPREFIX + t + os.linesep)
|
||||||
return result.rstrip("\n")
|
return result.rstrip(os.linesep)
|
||||||
|
|
||||||
|
|
||||||
# Produce a large string of output for all history in the current room. Can be printed directly to console
|
# Produce a large string of output for all history in the current room. Can be printed directly to console
|
||||||
@ -258,8 +258,8 @@ def get_message_history_string(ws):
|
|||||||
message_block = ""
|
message_block = ""
|
||||||
for message in reversed(result["objects"]["message"]):
|
for message in reversed(result["objects"]["message"]):
|
||||||
user = contentapi.get_user_or_default(users, message["createUserId"])
|
user = contentapi.get_user_or_default(users, message["createUserId"])
|
||||||
message_block += get_message_string(ws, message, user) + "\n"
|
message_block += get_message_string(ws, message, user) + os.linesep
|
||||||
return message_block.rstrip("\n")
|
return message_block.rstrip(os.linesep)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ def print_statusline(ws):
|
|||||||
room = "'" + (name[:(MAXTITLE - 3)] + '...' if len(name) > MAXTITLE else name) + "'"
|
room = "'" + (name[:(MAXTITLE - 3)] + '...' if len(name) > MAXTITLE else name) + "'"
|
||||||
else:
|
else:
|
||||||
room = Fore.RED + Style.DIM + "NONE" + Style.NORMAL + Fore.BLACK
|
room = Fore.RED + Style.DIM + "NONE" + Style.NORMAL + Fore.BLACK
|
||||||
print(Back.GREEN + Fore.BLACK + "\n " + ws.user_info["username"] + " - " + room + " CTRL: h s g u i c t q " + Style.RESET_ALL)
|
print(Back.GREEN + Fore.BLACK + os.linesep + " " + ws.user_info["username"] + " - " + room + " CTRL: h s g u i c t q " + Style.RESET_ALL)
|
||||||
|
|
||||||
|
|
||||||
# Print and then reset the style
|
# Print and then reset the style
|
||||||
|
Loading…
Reference in New Issue
Block a user