Skip to content

Commit

Permalink
apply latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Techbot121 authored and Meta Construct committed Nov 17, 2023
1 parent 45a5ff3 commit b5fe828
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions app/services/gamebridge/payloads/ErrorPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as responseSchema from "./structures/ErrorResponse.json";
import { APIEmbed } from "discord.js";
import { ErrorRequest, ErrorResponse } from "./structures";
import { GameServer } from "..";
import { getOrFetchLuaFile } from "@/utils";
import { getOrFetchGmodFile } from "@/utils";
import Payload from "./Payload";
import dayjs from "dayjs";

Expand All @@ -27,9 +27,8 @@ export default class ErrorPayload extends Payload {
const lines = hook_error.errormsg.split(/\r?\n/);
const err = lines[0];
const path = err.split(":")[0];
const linenr = err.split(":")[1];
const stack = lines.splice(2).map((l, i) => `${i + 1}. ${l}`);
const file = await getOrFetchLuaFile(path, Number(linenr));
const file = await getOrFetchGmodFile(path);
const embeds: APIEmbed[] = [];
const embed = {
title: hook_error.name,
Expand Down
17 changes: 9 additions & 8 deletions app/services/webapp/api/gmod-error-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AddonURIS, getOrFetchLuaFile } from "@/utils";
import { AddonURIS, getOrFetchGmodFile } from "@/utils";
import { GameBridge, GameServer, Player } from "../../gamebridge";
import { WebApp } from "..";
import Discord from "discord.js";
Expand Down Expand Up @@ -29,19 +29,20 @@ type StackMatchGroups = {
ext?: string;
filename?: string;
fn: string;
lino: string;
fpath?: string;
lineno: string;
nick?: string;
partialsteamid?: string;
path?: string;
runnables?: string;
rfilename?: string;
runnables?: string;
stacknr: string;
steamid: string;
steamnick?: string;
};

const megaRex =
/(?<stacknr>\d+)\. (?<fn>\S+) - (?<runnables>RunString|LuaCmd|LUACMD)?(\[(?<steamid>STEAM_\d:\d:\d+)\](?<steamnick>.+))?(<(?<partialsteamid>\d:\d:\d+)\|(?<nick>.+?)>)?(<(?<rfilename>[^:]+)>)?(<(?<cmdname>.+):(?<cmdrealm>.+)>)?(?<engine>\[C\])?(?<path>(?:lua|gamemodes)\/(?<addon>[-_.A-Za-z0-9]+?)(?:\/.*)?\/(?<filename>[-_.A-Za-z0-9]+)\.(?<ext>lua))?:(?<lino>-?\d+)/g;
/(?<stacknr>\d+)\. (?<fn>\S+) - (?<runnables>RunString|LuaCmd|LUACMD)?(\[(?<steamid>STEAM_\d:\d:\d+)\](?<steamnick>.+))?(<(?<partialsteamid>\d:\d:\d+)\|(?<nick>.+?)>)?(<(?<rfilename>[^:]+)>)?(<(?<cmdname>.+):(?<cmdrealm>.+)>)?(?<engine>\[C\])?(?<fpath>(?<path>(?:lua|gamemodes)\/(?<addon>[-_.A-Za-z0-9]+?)(?:\/.*)?\/(?<filename>[-_.A-Za-z0-9]+)\.(?<ext>lua)):-?(?<lineno>\d+))?/g;

const SuperReplacer = (_: string, ...args: any[]) => {
const groups = args.at(-1) as StackMatchGroups;
Expand Down Expand Up @@ -69,10 +70,10 @@ const SuperReplacer = (_: string, ...args: any[]) => {
? "mta_gamemode"
: groups.addon
]
? `[${groups.path}](${AddonURIS[groups.addon] + groups.path}#L${groups.lino})`
? `[${groups.path}](${AddonURIS[groups.addon] + groups.path}#L${groups.lineno})`
: groups.path
: groups.engine
}:${groups.lino}`;
}:${groups.lineno}`;
};

const gamemodes = ["sandbox_modded", "mta", "jazztronauts"]; //proper gamemode support when???
Expand Down Expand Up @@ -235,8 +236,8 @@ export default (webApp: WebApp): void => {
);
if (filematch.length > 0) {
const smg = filematch[0].groups as StackMatchGroups;
if (!smg.path) return;
await getOrFetchLuaFile(smg.path, Number(smg.lino), smg.addon).then(res => {
if (!smg.fpath) return;
await getOrFetchGmodFile(smg.fpath).then(res => {
if (res && smg.filename) {
payload.files = [
{
Expand Down

0 comments on commit b5fe828

Please sign in to comment.