mirror of https://github.com/thaldrin/thaldrin.git
utils
This commit is contained in:
parent
528a579e43
commit
91fd17606e
|
@ -0,0 +1,3 @@
|
||||||
|
import Lingua from "../modules/lingua";
|
||||||
|
|
||||||
|
export default new Lingua()
|
|
@ -0,0 +1,6 @@
|
||||||
|
import Modulus from "../modules/modulus/src/index";
|
||||||
|
|
||||||
|
let modulus = new Modulus('http://localhost');
|
||||||
|
// let modulus = new Modulus();
|
||||||
|
|
||||||
|
export default modulus
|
|
@ -0,0 +1,56 @@
|
||||||
|
// Initial code taken from @Cynosphere, rewritten by me
|
||||||
|
|
||||||
|
const Regex =
|
||||||
|
/(?:\s|^)(gh|gl|yt|tw|npm|tv|bc|bcu|wc|sc|bot|fa)\/([a-zA-Z0-9-_.#@/!]*)/g;
|
||||||
|
|
||||||
|
const Links: { [value: string]: string } = {
|
||||||
|
"gh": "https://github.com/$link$",
|
||||||
|
"gl": "https://gitlab.com/$link$",
|
||||||
|
"yt": "https://youtu.be/$link$",
|
||||||
|
"tw": "https://twitter.com/$link$",
|
||||||
|
"npm": "https://npm.im/$link$",
|
||||||
|
"tv": "https://twitch.tv/$link$",
|
||||||
|
"bc": "https://$link$.bandcamp.com/",
|
||||||
|
"bcu": "https://bandcamp.com/$link$",
|
||||||
|
"wc": "https://werewolf.codes/$link$",
|
||||||
|
"sc": "https://soundcloud.com/$link$",
|
||||||
|
fa: "https://furaffinity.net/$link$",
|
||||||
|
// "fav": "https://furaffinity.net/view/$link$",
|
||||||
|
// "fau": "https://furaffinity.net/user/$link$",
|
||||||
|
"bot": "https://discordapp.com/oauth2/authorize?client_id=$link$&scope=bot",
|
||||||
|
};
|
||||||
|
const SiteNames = {
|
||||||
|
gh: "Github",
|
||||||
|
gl: "Gitlab",
|
||||||
|
gd: "Gitdab",
|
||||||
|
yt: "Youtube",
|
||||||
|
tw: "Twitter",
|
||||||
|
npm: "NPM",
|
||||||
|
tv: "Twitch",
|
||||||
|
fa: "FurAffinity",
|
||||||
|
// fav: "FurAffinity Post",
|
||||||
|
// fau: "FurAffinity User",
|
||||||
|
bc: "Bandcamp Band",
|
||||||
|
bcu: "Bandcamp User",
|
||||||
|
sc: "Soundcloud",
|
||||||
|
bot: "Bot Invites",
|
||||||
|
wc: "werewolf.codes",
|
||||||
|
};
|
||||||
|
|
||||||
|
export default async function Shortlink(content: string) {
|
||||||
|
let Possible: string[] = [];
|
||||||
|
let res = content.match(Regex);
|
||||||
|
if (!res) return;
|
||||||
|
res = res.map((x) => (x.startsWith(" ") ? x.substring(1) : x));
|
||||||
|
for (const Shortlink in res) {
|
||||||
|
for (const Link in Links) {
|
||||||
|
let content = res[Shortlink];
|
||||||
|
if (!content.startsWith(Link)) continue;
|
||||||
|
content = content.replace(Link + "/", "");
|
||||||
|
content = Links[Link].replace("$link$", content);
|
||||||
|
Possible.push(`<${content}>`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// @ts-ignore
|
||||||
|
return Possible;
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
import sauce from "@thaldrin/sourcefinder"
|
||||||
|
import pkg from "../../package.json"
|
||||||
|
|
||||||
|
let saucefinder = new sauce(`${pkg.name}/v${pkg.version} (https://t8.pm/sourcefinder)`)
|
||||||
|
|
||||||
|
export default saucefinder
|
Loading…
Reference in New Issue