buttons fix
All checks were successful
fetch npm modules / f0ck the f0cker (push) Successful in 37s

This commit is contained in:
Flummi 2023-05-02 02:27:35 +02:00
parent 85d683ca31
commit 8e02892df0
3 changed files with 23 additions and 8 deletions

View File

@ -110,7 +110,7 @@ export default async bot => {
if(!id) if(!id)
return; return;
if(!(await lib.getTags(id)).filter(tag => tag.id == 1).length) { if(!await lib.hasTag(id, 1)) {
// insert // insert
await db` await db`
insert into "tags_assign" ${ insert into "tags_assign" ${
@ -121,6 +121,13 @@ export default async bot => {
}) })
} }
`; `;
if(await lib.hasTag(id, 2)) {
await db`
delete from "tags_assign"
where tag_id = 2
and item_id = ${id}
`;
}
} }
else { else {
// delete // delete
@ -134,8 +141,8 @@ export default async bot => {
return await e.editMessageText(e.raw.chat.id, e.raw.message_id, e.message, { return await e.editMessageText(e.raw.chat.id, e.raw.message_id, e.message, {
reply_markup: JSON.stringify({ reply_markup: JSON.stringify({
inline_keyboard: [[ inline_keyboard: [[
{ text: '✓ sfw', callback_data: `b_sfw:${id}` }, { text: (await lib.hasTag(id, 1) ? '✓ ' : '') + 'sfw', callback_data: `b_sfw:${id}` },
{ text: 'nsfw', callback_data: `b_nsfw:${id}` }, { text: (await lib.hasTag(id, 2) ? '✓ ' : '') + 'nsfw', callback_data: `b_nsfw:${id}` },
{ text: 'tags', callback_data: `b_tags:${id}` }, { text: 'tags', callback_data: `b_tags:${id}` },
{ text: '❌ delete', callback_data: `b_delete:${id}` } { text: '❌ delete', callback_data: `b_delete:${id}` }
], [ ], [
@ -149,7 +156,7 @@ export default async bot => {
if(!id) if(!id)
return; return;
if(!(await lib.getTags(id)).filter(tag => tag.id == 2).length) { if(!await lib.hasTag(id, 2)) {
// insert // insert
await db` await db`
insert into "tags_assign" ${ insert into "tags_assign" ${
@ -160,6 +167,13 @@ export default async bot => {
}) })
} }
`; `;
if(await lib.hasTag(id, 1)) {
await db`
delete from "tags_assign"
where tag_id = 1
and item_id = ${id}
`;
}
} }
else { else {
// delete // delete
@ -173,8 +187,8 @@ export default async bot => {
return await e.editMessageText(e.raw.chat.id, e.raw.message_id, e.message, { return await e.editMessageText(e.raw.chat.id, e.raw.message_id, e.message, {
reply_markup: JSON.stringify({ reply_markup: JSON.stringify({
inline_keyboard: [[ inline_keyboard: [[
{ text: 'sfw', callback_data: `b_sfw:${id}` }, { text: (await lib.hasTag(id, 1) ? '✓ ' : '') + 'sfw', callback_data: `b_sfw:${id}` },
{ text: '✓ nsfw', callback_data: `b_nsfw:${id}` }, { text: (await lib.hasTag(id, 2) ? '✓ ' : '') + 'nsfw', callback_data: `b_nsfw:${id}` },
{ text: 'tags', callback_data: `b_tags:${id}` }, { text: 'tags', callback_data: `b_tags:${id}` },
{ text: '❌ delete', callback_data: `b_delete:${id}` } { text: '❌ delete', callback_data: `b_delete:${id}` }
], [ ], [

View File

@ -9,6 +9,7 @@ let context = vm.createContext({
bot: null, bot: null,
admins: null, admins: null,
fetch: fetch, fetch: fetch,
lib: lib,
a: null, a: null,
resolve: null resolve: null

View File

@ -209,8 +209,8 @@ export default async bot => {
await e.reply(outputmsgtg, { await e.reply(outputmsgtg, {
reply_markup: JSON.stringify({ reply_markup: JSON.stringify({
inline_keyboard: [[ inline_keyboard: [[
{ text: 'sfw', callback_data: `b_sfw:${itemid}` }, { text: (await lib.hasTag(itemid, 1) ? '✓ ' : '') + 'sfw', callback_data: `b_sfw:${itemid}` },
{ text: 'nsfw', callback_data: `b_nsfw:${itemid}` }, { text: (await lib.hasTag(itemid, 2) ? '✓ ' : '') + 'nsfw', callback_data: `b_nsfw:${itemid}` },
{ text: 'tags', callback_data: `b_tags:${itemid}` }, { text: 'tags', callback_data: `b_tags:${itemid}` },
{ text: '❌ delete', callback_data: `b_delete:${itemid}` } { text: '❌ delete', callback_data: `b_delete:${itemid}` }
], [ ], [