roll results get added to the poster's message instead of sent in new message

This commit is contained in:
iou1name 2018-07-05 18:17:36 -04:00
parent 8479ac8c3f
commit 75a62ea7e8
2 changed files with 32 additions and 10 deletions

View File

@ -47,21 +47,24 @@ def message(data):
lines.append(line) lines.append(line)
message = "<br />".join(lines) message = "<br />".join(lines)
message = tools.handle_img(message) message = tools.handle_img(message)
if message.startswith("/dice") or message.startswith("/roll"):
roll_msg = handle_dice(data)
message += '<hr class="msgSrvHr" />' + roll_msg
data["message"] = message data["message"] = message
db.log_chat_message(data) db.log_chat_message(data)
emit("message", data, room=room) emit("message", data, room=room)
if message.startswith("/dice") or message.startswith("/roll"):
handle_dice(data)
def handle_dice(data): def handle_dice(message):
""" """
Handle /dice or /roll messages. Handle /dice or /roll messages.
""" """
room = data["room"] room = data["room"]
reg = re.search(r"(\d+)d(\d+)([+-]\d+)?", data['message']) reg = re.search(r"(\d+)d(\d+)([+-]\d+)?", message)
if not reg: if not reg:
return return
try: try:
@ -81,11 +84,7 @@ def handle_dice(data):
msg += " +" msg += " +"
msg += " " + str(diceMod) msg += " " + str(diceMod)
msg += " = " + str(total) + "</b>" msg += " = " + str(total) + "</b>"
date = int(time.time()) return msg
name = "Server"
data = {"message": msg, "name": name, "date": date, "room": room}
#emit("message", data, room=room)
message(data)
@socketio.on("new_post") @socketio.on("new_post")

View File

@ -3,6 +3,10 @@ img {
max-height:100%; max-height:100%;
} }
h3 {
margin: 0px;
}
.header { .header {
position: fixed; position: fixed;
top: 0; top: 0;
@ -18,6 +22,10 @@ img {
display: inline; display: inline;
} }
.header a {
text-decoration: none;
}
#headerHidden { #headerHidden {
width: auto; width: auto;
} }
@ -57,7 +65,7 @@ img {
padding: 0; padding: 0;
margin: 0; margin: 0;
background-color: #f1f1f1; background-color: #f1f1f1;
height: 200px; height: 100%;
} }
.QMPostTab { .QMPostTab {
@ -88,6 +96,10 @@ img {
max-width: 100%; max-width: 100%;
} }
.tooltip {
border-bottom: 1px dotted black;
}
#chatPane { #chatPane {
height: 100%; height: 100%;
width: 30%; width: 30%;
@ -99,6 +111,7 @@ img {
#chatWindow { #chatWindow {
border: 1px solid #ccc; border: 1px solid #ccc;
padding: 0.25em;
overflow: auto; overflow: auto;
flex: 1; flex: 1;
} }
@ -108,6 +121,16 @@ img {
word-wrap: break-word; word-wrap: break-word;
} }
.msgSrvHr {
width: 95%;
margin-top: 0.2em;
margin-bottom: 0.2em;
margin-left: auto;
margin-right: auto;
border: 0;
border-bottom: 1px solid #ccc;
}
#messageTextDiv { #messageTextDiv {
padding-bottom: 10px; padding-bottom: 10px;
width: 100%; width: 100%;