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)
message = "<br />".join(lines)
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
db.log_chat_message(data)
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.
"""
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:
return
try:
@ -81,11 +84,7 @@ def handle_dice(data):
msg += " +"
msg += " " + str(diceMod)
msg += " = " + str(total) + "</b>"
date = int(time.time())
name = "Server"
data = {"message": msg, "name": name, "date": date, "room": room}
#emit("message", data, room=room)
message(data)
return msg
@socketio.on("new_post")

View File

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