Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/client/components/routing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export {
const RE_SERVER = /\/server\/([A-Z0-9]{26})/;
const RE_CHANNEL = /\/channel\/([A-Z0-9]{26})/;
const RE_MESSAGE_ID = /\/channel\/[A-Z0-9]{26}\/([A-Z0-9]{26})/;
const RE_BOT_ID = /\/bot\/([A-Z0-9]{26})/;

const RE_INVITE_EXACT = /^\/invite\/([\w\d]+)$/;
const RE_BOT_ID_EXACT = /^\/bot\/[A-Z0-9]{26}$/;

const RE_SERVER_EXACT = /^\/server\/([A-Z0-9]{26})$/;
const RE_CHANNEL_EXACT =
Expand Down Expand Up @@ -69,6 +71,16 @@ type GlobalParams = {
* Exact match for message?
*/
exactMessage: boolean;

/**
* Bot ID
*/
botId?: string;

/**
* Exact match for bot?
*/
exactBot: boolean;
};

/**
Expand All @@ -81,6 +93,7 @@ export function paramsFromPathname(pathname: string): GlobalParams {
exactServer: !!pathname.match(RE_SERVER_EXACT),
exactChannel: !!pathname.match(RE_CHANNEL_EXACT),
exactMessage: !!pathname.match(RE_MESSAGE_ID_EXACT),
exactBot: !!pathname.match(RE_BOT_ID_EXACT),
};

// Check for invite ID
Expand All @@ -107,6 +120,12 @@ export function paramsFromPathname(pathname: string): GlobalParams {
params.messageId = message[1];
}

// Check for bot ID
const bot = pathname.match(RE_BOT_ID);
if (bot) {
params.botId = bot[1];
}

return params;
}

Expand Down
7 changes: 6 additions & 1 deletion packages/client/src/interface/Discover.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createEffect, createMemo, createSignal, onCleanup } from "solid-js";

import { PublicChannelInvite } from "stoat.js";
import { PublicBot, PublicChannelInvite } from "stoat.js";
import { styled } from "styled-system/jsx";

import { useClient } from "@revolt/client";
Expand Down Expand Up @@ -63,6 +63,11 @@ export function Discover() {
type: "invite",
invite,
});
} else if (params.botId) {
client()
.api.get(`/bots/${params.botId as ""}/invite`)
.then((bot) => new PublicBot(client(), bot))
.then((bot) => openModal({ type: "add_bot", invite: bot }));
} else {
alert("Missing handler for " + data.url);
}
Expand Down
Loading