asyncify
This commit is contained in:
parent
6472112aa1
commit
fe936b8cd6
|
@ -5,15 +5,13 @@ export default async bot => {
|
||||||
name: "chatbot",
|
name: "chatbot",
|
||||||
call: /^(?![!./[])(.*uw(e|i).*)/i,
|
call: /^(?![!./[])(.*uw(e|i).*)/i,
|
||||||
set: "uwe",
|
set: "uwe",
|
||||||
f: e => {
|
f: async e => {
|
||||||
const chat = e.message
|
const res = await cleverbot.ask(e.message
|
||||||
.replace(/uw(e|i)/gi, "")
|
.replace(/uw(e|i)/gi, "")
|
||||||
.split("?")
|
.split("?")
|
||||||
.join("");
|
.join("")
|
||||||
cleverbot.ask(chat)
|
);
|
||||||
.then(res => {
|
e.reply(res.response);
|
||||||
e.reply(res.response);
|
|
||||||
}).catch(console.error);
|
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
import sql from "../sql";
|
|
||||||
import { getLevel } from "../admin";
|
|
||||||
|
|
||||||
export default async bot => {
|
export default async bot => {
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
|
@ -40,72 +37,5 @@ export default async bot => {
|
||||||
e.reply(`changed nick to ${e.args[0]}`);
|
e.reply(`changed nick to ${e.args[0]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
name: "level",
|
|
||||||
call: /^\!level .*/i,
|
|
||||||
level: 0,
|
|
||||||
active: false,
|
|
||||||
clients: ["irc"],
|
|
||||||
f: e => {
|
|
||||||
if(e.self.me.nickname.toLowerCase() === e.args.shift().toLowerCase()) {
|
|
||||||
//const args = e.message.split(' ');
|
|
||||||
e.message = e.args.join("");
|
|
||||||
console.log(e.message);
|
|
||||||
if (Number.isInteger(parseInt(e.args[2]))) {
|
|
||||||
if (e.user.level.level >= 100) {
|
|
||||||
const name = e.args[1].replace('@', '');
|
|
||||||
const level = Math.min(Math.max(0, e.args[2]), 100);
|
|
||||||
|
|
||||||
//if (name.toLowerCase() != bot.me.toLowerCase()) {
|
|
||||||
if (e._user.hasi(name)) {
|
|
||||||
const user = e._user.geti(name);
|
|
||||||
if (user.registered) { // check if user is registered
|
|
||||||
const userlevel = getLevel(e.network, user).level;
|
|
||||||
if(userlevel > 0) { // check if user is admin
|
|
||||||
if(level <= 0) {
|
|
||||||
sql.any("delete from admins where account = lower(?) and network = lower(?)", [user.account, e.network])
|
|
||||||
.then(rows => {
|
|
||||||
loadAdmins();
|
|
||||||
return e.reply(`deleted user ${user.nickname}`);
|
|
||||||
}).catch(err => console.log("delete", err))
|
|
||||||
}
|
|
||||||
else if(level !== userlevel) {
|
|
||||||
sql.any("update admins set level = ? where account = ? and network = ?", [level, user.account, e.network])
|
|
||||||
.then(rows => {
|
|
||||||
loadAdmins();
|
|
||||||
return e.reply(`changed user [b]${user.nickname}[/b] (${userlevel} -> ${level})`);
|
|
||||||
}).catch(err => console.log("update", err))
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return e.reply("no changes");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql.any("insert into admins (prefix, account, level, network) values (lower(?), lower(?), ?, lower(?))", [user.prefix, user.account, level, e.network])
|
|
||||||
.then(rows => {
|
|
||||||
loadAdmins();
|
|
||||||
return e.reply(`added new user [b]${user.nickname}[/b] with level ${level}`);
|
|
||||||
}).catch(err => console.log("add", err))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return e.reply(`user [b]${name}[/b] isn't registered`);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return e.reply(`user not found`);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return e.reply("no permission, min level 100 required");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let user = (!(user = e.message.match(/^\!level(?: +@(.*))?/i)[1])) ? e.user.nick : user.trim();
|
|
||||||
if(e._user.hasi(user)) {
|
|
||||||
const level = getLevel(e.network, e._user.geti(user));
|
|
||||||
e.reply(`level from ${user}: ${level.level} (${level.verified ? "verified" : "unverified"})`);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
e.reply(`user not found`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,51 +6,47 @@ export default async bot => {
|
||||||
name: "irpg",
|
name: "irpg",
|
||||||
call: /^\.irpg/i,
|
call: /^\.irpg/i,
|
||||||
set: "uwe",
|
set: "uwe",
|
||||||
f: e => {
|
f: async e => {
|
||||||
fetch("https://f0ck.me/irpg/db.php")
|
const res = await (await fetch("https://f0ck.me/irpg/db.php")).text();
|
||||||
.then(res => res.text())
|
e.args[0] = e.args[0] || e.user.nick;
|
||||||
.then(res => {
|
let players = new Map()
|
||||||
e.args[0] = e.args[0] || e.user.nick;
|
, alias = {};
|
||||||
let players = new Map()
|
res
|
||||||
, alias = {};
|
.split("\n").join``
|
||||||
res
|
.match(/\<tr\>(.*?)\<\/tr\>/gsi)
|
||||||
.split("\n").join``
|
.map((l, i) => `<td>${i}</td>${l}`.match(/\<td.*?\>(.*?)\<\/td\>/gsi))
|
||||||
.match(/\<tr\>(.*?)\<\/tr\>/gsi)
|
.map(l => l?l.map(m => m
|
||||||
.map((l, i) => `<td>${i}</td>${l}`.match(/\<td.*?\>(.*?)\<\/td\>/gsi))
|
.replace("<td>", "")
|
||||||
.map(l => l?l.map(m => m
|
.replace("<td nowrap>", "")
|
||||||
.replace("<td>", "")
|
.replace("</td>", "")
|
||||||
.replace("<td nowrap>", "")
|
):false)
|
||||||
.replace("</td>", "")
|
.splice(1)
|
||||||
):false)
|
.forEach(p => { // 6 archangel!archangel@pomf.space
|
||||||
.splice(1)
|
const nick = p[6].split("!")[0].toLowerCase();
|
||||||
.forEach(p => { // 6 archangel!archangel@pomf.space
|
players.set(p[1].toLowerCase(), {
|
||||||
const nick = p[6].split("!")[0].toLowerCase();
|
rang: parseInt(p[0]),
|
||||||
players.set(p[1].toLowerCase(), {
|
name: p[1],
|
||||||
rang: parseInt(p[0]),
|
level: parseInt(p[2]),
|
||||||
name: p[1],
|
class: p[4],
|
||||||
level: parseInt(p[2]),
|
ttl: p[5],
|
||||||
class: p[4],
|
online: p[7] === "Yes",
|
||||||
ttl: p[5],
|
nick: nick,
|
||||||
online: p[7] === "Yes",
|
itemsum: parseInt(p[31])
|
||||||
nick: nick,
|
});
|
||||||
itemsum: parseInt(p[31])
|
if(nick !== p[1].toLowerCase())
|
||||||
});
|
alias[nick] = p[1].toLowerCase();
|
||||||
if(nick !== p[1].toLowerCase())
|
});
|
||||||
alias[nick] = p[1].toLowerCase();
|
e.args[0] = (e.args[0].toLowerCase() in alias)?alias[e.args[0].toLowerCase()]:e.args[0];
|
||||||
});
|
let p = players.has(e.args[0].toLowerCase())?players.get(e.args[0].toLowerCase()):false;
|
||||||
e.args[0] = (e.args[0].toLowerCase() in alias)?alias[e.args[0].toLowerCase()]:e.args[0];
|
let tmp = e.args[0].match(/#\d+/);
|
||||||
let p = players.has(e.args[0].toLowerCase())?players.get(e.args[0].toLowerCase()):false;
|
if(tmp) {
|
||||||
let tmp = e.args[0].match(/#\d+/);
|
tmp = parseInt(tmp[0].slice(1)) - 1;
|
||||||
if(tmp) {
|
if(tmp >= 0 && tmp <= players.size - 1)
|
||||||
tmp = parseInt(tmp[0].slice(1)) - 1;
|
p = [...players.entries()][tmp][1];
|
||||||
if(tmp >= 0 && tmp <= players.size - 1)
|
}
|
||||||
p = [...players.entries()][tmp][1];
|
if(!p)
|
||||||
}
|
return e.reply("user / rang doesn't exist. D:");
|
||||||
if(!p)
|
e.reply(`(${p.rang} / ${players.size}) [b]${p.name}[/b], the [b]${p.class}[/b] is ${p.online?"[color=green]online[/color]":"[color=red]offline[/color]"}: level: ${p.level}, next level in ${p.ttl}. Itemsum: ${p.itemsum}`);
|
||||||
return e.reply("user / rang doesn't exist. D:");
|
|
||||||
e.reply(`(${p.rang} / ${players.size}) [b]${p.name}[/b], the [b]${p.class}[/b] is ${p.online?"[color=green]online[/color]":"[color=red]offline[/color]"}: level: ${p.level}, next level in ${p.ttl}. Itemsum: ${p.itemsum}`);
|
|
||||||
})
|
|
||||||
.catch(err => console.log(err));
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,17 +18,14 @@ export default async bot => {
|
||||||
name: "mcmaniac_add",
|
name: "mcmaniac_add",
|
||||||
call: /Mc.*iaC/,
|
call: /Mc.*iaC/,
|
||||||
set: "nxy",
|
set: "nxy",
|
||||||
f: e => {
|
f: async e => {
|
||||||
const match = e.message.match(/(Mc\S+iaC?)/)[0];
|
await sql.any(_query_add, [e.message.match(/(Mc\S+iaC?)/)[0]]);
|
||||||
sql.any(_query_add, [match])
|
|
||||||
.then()
|
|
||||||
.catch(err => {});
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: "mcmaniac_get",
|
name: "mcmaniac_get",
|
||||||
call: /^(\.|\/)mcmaniac/i,
|
call: /^(\.|\/)mcmaniac/i,
|
||||||
set: "nxy",
|
set: "nxy",
|
||||||
f: e => {
|
f: async e => {
|
||||||
const args = e.message.trim().substring(10);
|
const args = e.message.trim().substring(10);
|
||||||
let order = "id asc"
|
let order = "id asc"
|
||||||
, offset
|
, offset
|
||||||
|
@ -52,13 +49,9 @@ export default async bot => {
|
||||||
query = query
|
query = query
|
||||||
.split("{order}").join(order)
|
.split("{order}").join(order)
|
||||||
.split("{offset}").join(offset);
|
.split("{offset}").join(offset);
|
||||||
sql.any(query)
|
|
||||||
.then(rows => {
|
const rows = await sql.any(query);
|
||||||
e.reply(`[${rows[0].rank}/${rows[0].total}] ${rows[0].item}`);
|
e.reply(`[${rows[0].rank}/${rows[0].total}] ${rows[0].item}`);
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,22 +12,19 @@ export default async bot => {
|
||||||
text: "Searches for a term on Urbandict and returns first result",
|
text: "Searches for a term on Urbandict and returns first result",
|
||||||
usage: "[b].ud[/b] [i]<term>[/i] [i](<index>)[/i]"
|
usage: "[b].ud[/b] [i]<term>[/i] [i](<index>)[/i]"
|
||||||
},
|
},
|
||||||
f: e => {
|
f: async e => {
|
||||||
let index = 1;
|
let index = 1;
|
||||||
if(!isNaN(e.args[e.args.length - 1]) && e.args.length > 1)
|
if(!isNaN(e.args[e.args.length - 1]) && e.args.length > 1)
|
||||||
index = parseInt(e.args.pop());
|
index = parseInt(e.args.pop());
|
||||||
const term = e.args.join(" ").trim().toLowerCase();
|
const term = e.args.join(" ").trim().toLowerCase();
|
||||||
|
|
||||||
fetch(`${url}?term=${term}`)
|
const data = await (await fetch(`${url}?term=${term}`)).json();
|
||||||
.then(res => res.json())
|
if(data.result_type === "no_results")
|
||||||
.then(data => {
|
return e.reply("Term not found");
|
||||||
if(data.result_type === "no_results")
|
if(!data.list[index-1])
|
||||||
return e.reply("Term not found");
|
return e.reply("Index not found");
|
||||||
if(!data.list[index-1])
|
const res = data.list[index-1];
|
||||||
return e.reply("Index not found");
|
e.reply(`[${index}/${data.list.length}] [b]${res.word}[/b]: ${res.definition.replace(/\r\n/g, "")} - ${res.example.replace(/\r\n/g, "")}`);
|
||||||
const res = data.list[index-1];
|
|
||||||
e.reply(`[${index}/${data.list.length}] [b]${res.word}[/b]: ${res.definition.replace(/\r\n/g, "")} - ${res.example.replace(/\r\n/g, "")}`);
|
|
||||||
}).catch(err => console.log(err));
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user