More tags and add paste providers. Also more analysis
This commit is contained in:
parent
86c545cb45
commit
c39ed8e49c
10 changed files with 240 additions and 89 deletions
19
src/logproviders/0x0.ts
Normal file
19
src/logproviders/0x0.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
const reg = /https\:\/\/0x0.st\/[^ ]*/;
|
||||
|
||||
export async function read0x0(s: string): Promise<null | string> {
|
||||
const r = s.match(reg);
|
||||
if (r == null || !r[0]) return null;
|
||||
const link = r[0];
|
||||
let log: string;
|
||||
try {
|
||||
const f = await fetch(link);
|
||||
if (f.status != 200) {
|
||||
throw 'nope';
|
||||
}
|
||||
log = await f.text();
|
||||
} catch (err) {
|
||||
console.log('Log analyze fail', err);
|
||||
return null;
|
||||
}
|
||||
return log;
|
||||
}
|
21
src/logproviders/haste.ts
Normal file
21
src/logproviders/haste.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
const reg = /https\:\/\/hst.sh\/[\w]*/;
|
||||
|
||||
export async function readHastebin(s: string): Promise<string | null> {
|
||||
const r = s.match(reg);
|
||||
if (r == null || !r[0]) return null;
|
||||
const link = r[0];
|
||||
const id = link.replace('https://hst.sh/', '');
|
||||
if (!id) return null;
|
||||
let log: string;
|
||||
try {
|
||||
const f = await fetch(`https://hst.sh/raw/${id}`);
|
||||
if (f.status != 200) {
|
||||
throw 'nope';
|
||||
}
|
||||
log = await f.text();
|
||||
} catch (err) {
|
||||
console.log('Log analyze fail', err);
|
||||
return null;
|
||||
}
|
||||
return log;
|
||||
}
|
22
src/logproviders/mclogs.ts
Normal file
22
src/logproviders/mclogs.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
const reg = /https\:\/\/mclo.gs\/[^ ]*/;
|
||||
|
||||
export async function readMcLogs(s: string): Promise<null | string> {
|
||||
const r = s.match(reg);
|
||||
if (r == null || !r[0]) return null;
|
||||
const link = r[0];
|
||||
const id = link.replace('https://mclo.gs/', '');
|
||||
if (!id) return null;
|
||||
const apiUrl = 'https://api.mclo.gs/1/raw/' + id;
|
||||
let log: string;
|
||||
try {
|
||||
const f = await fetch(apiUrl);
|
||||
if (f.status != 200) {
|
||||
throw 'nope';
|
||||
}
|
||||
log = await f.text();
|
||||
} catch (err) {
|
||||
console.log('Log analyze fail', err);
|
||||
return null;
|
||||
}
|
||||
return log;
|
||||
}
|
30
src/logproviders/pastegg.ts
Normal file
30
src/logproviders/pastegg.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
const reg = /https\:\/\/paste.gg\/p\/[\w]*\/[\w]*/;
|
||||
|
||||
export async function readPasteGG(s: string): Promise<null | string> {
|
||||
const r = s.match(reg);
|
||||
if (r == null || !r[0]) return null;
|
||||
const link = r[0];
|
||||
const id = link.replace(/https\:\/\/paste.gg\/p\/[\w]*\//, '');
|
||||
if (!id) return null;
|
||||
let log: string;
|
||||
try {
|
||||
const pasteJson = await (
|
||||
await fetch('https://api.paste.gg/v1/pastes/' + id)
|
||||
).json();
|
||||
if (pasteJson.status != 'success') throw 'up';
|
||||
const pasteData = await (
|
||||
await fetch(
|
||||
'https://api.paste.gg/v1/pastes/' +
|
||||
id +
|
||||
'/files/' +
|
||||
pasteJson.result.files[0].id
|
||||
)
|
||||
).json();
|
||||
if (pasteData.status != 'success') throw 'up';
|
||||
return pasteData.result.content.value;
|
||||
} catch (err) {
|
||||
console.log('Log analyze fail', err);
|
||||
return null;
|
||||
}
|
||||
return log;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue