markdown
This commit is contained in:
parent
5b87f555fa
commit
f48e458f55
@ -66,7 +66,7 @@ export default class slack extends EventEmitter {
|
||||
return this.server.wss.socket.send(JSON.stringify({
|
||||
type: "message",
|
||||
channel: channel,
|
||||
text: text
|
||||
text: this.format(text)
|
||||
}));
|
||||
}
|
||||
|
||||
@ -92,4 +92,16 @@ export default class slack extends EventEmitter {
|
||||
};
|
||||
}
|
||||
|
||||
format(msg) {
|
||||
return msg.toString()
|
||||
.split("<").join("<")
|
||||
.split(">").join(">")
|
||||
.split("&").join("&")
|
||||
.replace(/\[b\](.*?)\[\/b\]/g, "*$1*") // bold
|
||||
.replace(/\[s\](.*?)\[\/s\]/g, "~$1~") // strike
|
||||
.replace(/\[i\](.*?)\[\/i\]/g, "_$1_") // italic
|
||||
.replace(/\[color=(.*?)](.*?)\[\/color\]/g, "$2")
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user