Compare commits
2 Commits
06813a87d4
...
82702d786a
Author | SHA1 | Date | |
---|---|---|---|
82702d786a | |||
|
155d496592 |
|
@ -1,3 +1,4 @@
|
||||||
|
import cfg from "../../inc/config.mjs";
|
||||||
import f0cklib from "../routeinc/f0cklib.mjs";
|
import f0cklib from "../routeinc/f0cklib.mjs";
|
||||||
|
|
||||||
export default (router, tpl) => {
|
export default (router, tpl) => {
|
||||||
|
@ -5,8 +6,8 @@ export default (router, tpl) => {
|
||||||
let referer = req.headers.referer ?? '';
|
let referer = req.headers.referer ?? '';
|
||||||
let opts = {};
|
let opts = {};
|
||||||
|
|
||||||
if(referer.match(/f0ck\.me/)) { // parse referer
|
if(referer.match(new RegExp(cfg.main.url.regex))) { // parse referer
|
||||||
referer = referer.split("f0ck.me")[1];
|
referer = referer.split(cfg.main.url.domain)[1];
|
||||||
const tmp = referer.match(/^\/?(?:\/tag\/(?<tag>.+?))?(?:\/user\/(?<user>.+?)\/(?<mode>f0cks|favs))?(?:\/(?<mime>image|audio|video))?(?:\/p\/(?<page>\d+))?(?:\/(?<itemid>\d+))?$/);
|
const tmp = referer.match(/^\/?(?:\/tag\/(?<tag>.+?))?(?:\/user\/(?<user>.+?)\/(?<mode>f0cks|favs))?(?:\/(?<mime>image|audio|video))?(?:\/p\/(?<page>\d+))?(?:\/(?<itemid>\d+))?$/);
|
||||||
if(tmp)
|
if(tmp)
|
||||||
opts = tmp.groups;
|
opts = tmp.groups;
|
||||||
|
@ -31,7 +32,7 @@ export default (router, tpl) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
res.redirect(`/${data.link}${data.link.length != 0 ? "/" : ""}${data.itemid}`);
|
res.redirect(`${data.link.main}${data.link.path}${data.itemid}`);
|
||||||
});
|
});
|
||||||
return router;
|
return router;
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default (router, tpl) => {
|
||||||
select count(*) as total
|
select count(*) as total
|
||||||
from "items"
|
from "items"
|
||||||
where src ilike ${'%' + tag.substring(4) + '%'}
|
where src ilike ${'%' + tag.substring(4) + '%'}
|
||||||
group by "items".id, "tags".tag
|
group by "items".id
|
||||||
`).length;
|
`).length;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -41,7 +41,8 @@ export default (router, tpl) => {
|
||||||
select *
|
select *
|
||||||
from "items"
|
from "items"
|
||||||
where src ilike ${'%' + tag.substring(4) + '%'}
|
where src ilike ${'%' + tag.substring(4) + '%'}
|
||||||
group by "items".id, "tags".tag
|
group by "items".id
|
||||||
|
order by "items".id desc
|
||||||
offset ${offset}
|
offset ${offset}
|
||||||
limit ${_eps}
|
limit ${_eps}
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default async bot => {
|
||||||
return e.reply("no f0cks given! lol D:");
|
return e.reply("no f0cks given! lol D:");
|
||||||
|
|
||||||
e.reply([
|
e.reply([
|
||||||
`${cfg.main.url}/${rows[0].id}`,
|
`${cfg.main.url.full}/${rows[0].id}`,
|
||||||
`user: ${rows[0].username} @ ${rows[0].usernetwork} ${rows[0].userchannel}`,
|
`user: ${rows[0].username} @ ${rows[0].usernetwork} ${rows[0].userchannel}`,
|
||||||
`~${lib.formatSize(rows[0].size)}`,
|
`~${lib.formatSize(rows[0].size)}`,
|
||||||
rows[0].mime,
|
rows[0].mime,
|
||||||
|
|
|
@ -24,7 +24,7 @@ export default async bot => {
|
||||||
if(rows.length === 0)
|
if(rows.length === 0)
|
||||||
return e.reply("nothing found, f0cker");
|
return e.reply("nothing found, f0cker");
|
||||||
|
|
||||||
return e.reply(`f0ckrnd: ${cfg.main.url}/${rows[0].id} by: ${rows[0].username} (${rows[0].mime}, ~${lib.formatSize(rows[0].size)})`);
|
return e.reply(`f0ckrnd: ${cfg.main.url.full}/${rows[0].id} by: ${rows[0].username} (${rows[0].mime}, ~${lib.formatSize(rows[0].size)})`);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,7 +51,7 @@ export default async bot => {
|
||||||
where src = ${link}
|
where src = ${link}
|
||||||
`;
|
`;
|
||||||
if(q_repost.length > 0)
|
if(q_repost.length > 0)
|
||||||
return e.reply(`repost motherf0cker (link): ${cfg.main.url}/${q_repost[0].id}`);
|
return e.reply(`repost motherf0cker (link): ${cfg.main.url.full}/${q_repost[0].id}`);
|
||||||
|
|
||||||
// generate uuid
|
// generate uuid
|
||||||
const uuid = (await db`
|
const uuid = (await db`
|
||||||
|
@ -120,7 +120,7 @@ export default async bot => {
|
||||||
where checksum = ${checksum}
|
where checksum = ${checksum}
|
||||||
`;
|
`;
|
||||||
if(q_repostc.length > 0)
|
if(q_repostc.length > 0)
|
||||||
return e.reply(`repost motherf0cker (checksum): ${cfg.main.url}/${q_repostc[0].id}`);
|
return e.reply(`repost motherf0cker (checksum): ${cfg.main.url.full}/${q_repostc[0].id}`);
|
||||||
|
|
||||||
await fs.promises.copyFile(`./tmp/${filename}`, `./public/b/${filename}`);
|
await fs.promises.copyFile(`./tmp/${filename}`, `./public/b/${filename}`);
|
||||||
await fs.promises.unlink(`./tmp/${filename}`).catch(_=>{});
|
await fs.promises.unlink(`./tmp/${filename}`).catch(_=>{});
|
||||||
|
@ -241,7 +241,7 @@ export default async bot => {
|
||||||
}
|
}
|
||||||
|
|
||||||
e.reply([
|
e.reply([
|
||||||
`[f0cked] link: ${cfg.main.url}/${itemid} | size: ${lib.formatSize(size)} | speed: ${speed}` + (tags.length > 0 ? ` | tags: ${tags.join(', ')}` : '')
|
`[f0cked] link: ${cfg.main.url.full}/${itemid} | size: ${lib.formatSize(size)} | speed: ${speed}` + (tags.length > 0 ? ` | tags: ${tags.join(', ')}` : '')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,8 +15,8 @@ export default async bot => {
|
||||||
return e.reply("lol no");
|
return e.reply("lol no");
|
||||||
const tags = (await lib.getTags(id)).map(t => t.tag);
|
const tags = (await lib.getTags(id)).map(t => t.tag);
|
||||||
if(tags.length === 0)
|
if(tags.length === 0)
|
||||||
return e.reply(`item ${cfg.main.url}/${id} has no tags!`);
|
return e.reply(`item ${cfg.main.url.full}/${id} has no tags!`);
|
||||||
return e.reply(`item ${cfg.main.url}/${id} is tagged as: ${tags.join(', ')}`);
|
return e.reply(`item ${cfg.main.url.full}/${id} is tagged as: ${tags.join(', ')}`);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: "tags add",
|
name: "tags add",
|
||||||
|
@ -73,8 +73,8 @@ export default async bot => {
|
||||||
|
|
||||||
const ntags = (await lib.getTags(id)).map(t => t.tag);
|
const ntags = (await lib.getTags(id)).map(t => t.tag);
|
||||||
if(ntags.length === 0)
|
if(ntags.length === 0)
|
||||||
return e.reply(`item ${cfg.main.url}/${id} has no tags!`);
|
return e.reply(`item ${cfg.main.url.full}/${id} has no tags!`);
|
||||||
return e.reply(`item ${cfg.main.url}/${id} is now tagged as: ${ntags.join(', ')}`);
|
return e.reply(`item ${cfg.main.url.full}/${id} is now tagged as: ${ntags.join(', ')}`);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: "tags remove",
|
name: "tags remove",
|
||||||
|
@ -126,8 +126,8 @@ export default async bot => {
|
||||||
|
|
||||||
const ntags = (await lib.getTags(id)).map(t => t.tag);
|
const ntags = (await lib.getTags(id)).map(t => t.tag);
|
||||||
if(ntags.length === 0)
|
if(ntags.length === 0)
|
||||||
return e.reply(`item ${cfg.main.url}/${id} has no tags!`);
|
return e.reply(`item ${cfg.main.url.full}/${id} has no tags!`);
|
||||||
return e.reply(`item ${cfg.main.url}/${id} is now tagged as: ${ntags.join(', ')}`);
|
return e.reply(`item ${cfg.main.url.full}/${id} is now tagged as: ${ntags.join(', ')}`);
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<td><a href="/tag/{!! line.tag !!}">{!! line.tag !!}</a></td>
|
<td><a href="/tag/{!! line.tag !!}">{!! line.tag !!}</a></td>
|
||||||
<td>{{ line.mime }}</td>
|
<td>{{ line.mime }}</td>
|
||||||
<td><a href="/user/{!! line.username !!}/f0cks/{{ line.id }}">{!! line.username !!}</a></td>
|
<td><a href="/user/{!! line.username !!}/f0cks/{{ line.id }}">{!! line.username !!}</a></td>
|
||||||
<td>{{ line.score.toFixed(2) }}</td>
|
<td>{{ line.score?.toFixed(2) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endeach
|
@endeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user