diff --git a/src/index.js b/src/index.js
index 49ff2ab..be4a1a7 100644
--- a/src/index.js
+++ b/src/index.js
@@ -4,7 +4,18 @@ function id(e) { return document.getElementById(e) }
ipcRenderer.on("msg", (event, arg) => {
let ul = document.createElement("ul")
ul.classList.add("msg")
- ul.textContent = arg.msg.author.username + "#" + arg.msg.author.discriminator + ": " + arg.msg.content
+ let ct = arg.msg.content
+ let mt = ct.match(/.*#[0-9]{4}/)
+ if(mt) {
+ mt = mt[0]
+ mt = mt.split("@")
+ let sp = []
+ mt.forEach(e => {
+ if(e) sp.push(`@${e}`)
+ })
+ ct = ct.replace(/@.*#\d{4}/, sp.join(" "))
+ }
+ ul.innerHTML = arg.msg.author.username + "#" + arg.msg.author.discriminator + ": " + ct
ul.setAttribute("data-channel", arg.msg.channel)
id("msgdisplay").appendChild(ul)
id('msgdisplay').scrollTop = id('msgdisplay').scrollHeight
@@ -12,6 +23,10 @@ ipcRenderer.on("msg", (event, arg) => {
let gids, gna = [], ccids = [], cna = [];
ipcRenderer.on("gids", (event, arg) => {
+ let nn = document.createElement('option')
+ nn.setAttribute("value", "none")
+ nn.innerText = "none"
+ id('guilds').appendChild(nn)
arg.forEach(e => {
let opt = document.createElement("option")
opt.setAttribute("value", e.name)
@@ -20,17 +35,20 @@ ipcRenderer.on("gids", (event, arg) => {
gna.push(e.name)
})
gids = arg
- console.log(gna)
})
let currentchannel;
id('guilds').addEventListener('change', e => {
- // let r = e.target.innerText.split("\n")
- // let guild = gids[r.indexOf(e.target.value)] // is guild ig
- // let guild = gids[gna.indexOf(e.target.value)].id
+ if(e.target.value === "none") {
+ id('channels').innerHTML = ''
+ id('msgdisplay').innerText = ''
+ return;
+ }
+ id('msgdisplay').innerText = ''
let idx = gna.indexOf(e.target.value)
ipcRenderer.send("rcids", idx)
})
+id('channels').addEventListener("change", () => id('msgdisplay').innerText = '')
ipcRenderer.on("cids", (event, arg) => {
id('channels').innerHTML = ''
@@ -44,8 +62,16 @@ ipcRenderer.on("cids", (event, arg) => {
})
})
+id('bot-secret').addEventListener("keypress", e => {
+ if(e.keyCode != 13) return;
+ ipcRenderer.send("startbot", e.target.value)
+ id('bs').style.display = "none"
+ document.querySelector('.container').style.display = "block"
+})
+
id("msgin").addEventListener("keypress", e => {
if (e.keyCode !== 13) return;
+ if(id("channels").value === "")
currentchannel = ccids[cna.indexOf(id('channels').value)]
ipcRenderer.send("msgin", {
msg: id("msgin").value,
diff --git a/src/ps.js b/src/ps.js
index e19ba36..37de444 100644
--- a/src/ps.js
+++ b/src/ps.js
@@ -12,6 +12,8 @@ let lastmessage;
let isLoggedIn = false
let gids = []
let cids = []
+let tagx = /.*#[0-9]{4}/
+let uidx = /<@!\d+>/
exports.init = function(win, tok) {
window = win;
@@ -29,6 +31,13 @@ exports.init = function(win, tok) {
});
client.login(tok);
ipcMain.on("msgin", (event, arg) => {
+ if(arg.msg.toString().match(tagx)) {
+ // is ping
+ let un = arg.msg.toString().match(tagx)[0].toString().split("#")[0].replace("@", '')
+ let g = client.channels.cache.get(arg.channel).guild.members.cache.filter(x => x.user.username === un).array()
+ arg.msg = arg.msg.replace(tagx, g[0].user)
+ }
+ if(arg.msg.toString().includes("/shrug")) arg.msg = arg.msg.replace("/shrug", "¯\_(ツ)_/¯")
client.channels.cache.get(arg.channel).send(arg.msg)
})
// channels.cache.filter(c => c.type === "text")
@@ -44,8 +53,16 @@ exports.init = function(win, tok) {
function process(msg) {
if(settings.mode === "user") {
+ let ct = msg.content
+ if(msg.mentions) {
+ let mts = msg.mentions.users.array()
+ mts.forEach(e => {
+ let i = `@${e.username}#${e.discriminator}`
+ ct = ct.replace(uidx, i)
+ })
+ }
let m = {
- content: msg.content,
+ content: ct,
author: msg.author,
channel: msg.channel.id
}
diff --git a/src/style.css b/src/style.css
index 5b35364..c6ce01f 100644
--- a/src/style.css
+++ b/src/style.css
@@ -8,4 +8,6 @@ body { }
overflow-y: scroll;
position:relative;
bottom:0;
-}
\ No newline at end of file
+}
+
+.png { color:red; }
\ No newline at end of file