fixed waifu/husbando for tg
This commit is contained in:
parent
20c5ea20de
commit
b8bc1c28b0
|
@ -179,18 +179,21 @@ export default bot => {
|
||||||
bot._trigger.set("waifu_husbando", new bot.trigger({
|
bot._trigger.set("waifu_husbando", new bot.trigger({
|
||||||
call: /^(\.|\/)(waifu|husbando)/i,
|
call: /^(\.|\/)(waifu|husbando)/i,
|
||||||
f: e => {
|
f: e => {
|
||||||
let nick = e.args[0] || e.user.nick;
|
let nick = e.args[0] || (e.type === "tg"?e.user.username || e.user.nick:e.user.nick)
|
||||||
let mode = e.cmd;
|
let mode = e.cmd;
|
||||||
|
nick = nick.split("@").join("");
|
||||||
|
|
||||||
if(e.args.length > 0 && e.args[0].charAt(0) === "=") {
|
if(e.args.length > 0 && e.args[0].charAt(0) === "=") {
|
||||||
let tmp = e.args[0].slice(1);
|
let tmp = e.args[0].slice(1);
|
||||||
sql.any(`insert into nxy_users (nick, ${mode}) values (lower($1), $2) on conflict (nick) do update set ${mode} = excluded.${mode}`, [e.user.nick, tmp])
|
sql.any(
|
||||||
|
`insert into nxy_users (nick, ${mode}) values (lower($1), $2) on conflict (nick) do update set ${mode} = excluded.${mode}`, [
|
||||||
|
(e.type === "tg"?e.user.username || e.user.nick:e.user.nick),
|
||||||
|
tmp
|
||||||
|
])
|
||||||
.then(rows => {
|
.then(rows => {
|
||||||
e.reply(`${mode.charAt(0).toUpperCase()+mode.slice(1)} set to: [b]${tmp}[/b]`)
|
e.reply(`${mode.charAt(0).toUpperCase()+mode.slice(1)} set to: [b]${tmp}[/b]`)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => console.log(err));
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sql.any(`select ${mode} from nxy_users where lower(nick) = lower($1) limit 1`, [nick])
|
sql.any(`select ${mode} from nxy_users where lower(nick) = lower($1) limit 1`, [nick])
|
||||||
|
@ -199,9 +202,7 @@ export default bot => {
|
||||||
return e.reply(`[b]${mode.charAt(0).toUpperCase() + mode.slice(1)}[/b]: none`);
|
return e.reply(`[b]${mode.charAt(0).toUpperCase() + mode.slice(1)}[/b]: none`);
|
||||||
e.reply(`${mode.charAt(0).toUpperCase() + mode.slice(1)}: [b]${rows[0][mode]}[/b]`);
|
e.reply(`${mode.charAt(0).toUpperCase() + mode.slice(1)}: [b]${rows[0][mode]}[/b]`);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => console.log(err));
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user