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,10 +6,8 @@ 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())
|
|
||||||
.then(res => {
|
|
||||||
e.args[0] = e.args[0] || e.user.nick;
|
e.args[0] = e.args[0] || e.user.nick;
|
||||||
let players = new Map()
|
let players = new Map()
|
||||||
, alias = {};
|
, alias = {};
|
||||||
|
@ -49,8 +47,6 @@ export default async bot => {
|
||||||
if(!p)
|
if(!p)
|
||||||
return e.reply("user / rang doesn't exist. D:");
|
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}`);
|
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())
|
|
||||||
.then(data => {
|
|
||||||
if(data.result_type === "no_results")
|
if(data.result_type === "no_results")
|
||||||
return e.reply("Term not found");
|
return e.reply("Term not found");
|
||||||
if(!data.list[index-1])
|
if(!data.list[index-1])
|
||||||
return e.reply("Index not found");
|
return e.reply("Index not found");
|
||||||
const res = data.list[index-1];
|
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, "")}`);
|
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