Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
feat(plugins): show !commands in admin plugin tab
Gabe Kangas0fbded101875
diff --git a/services/plugins/manager.go b/services/plugins/manager.goindex 893d8a48bc..325534fa56 100644--- a/services/plugins/manager.go+++ b/services/plugins/manager.go@@ -352,6 +352,10 @@ type DiscoveredEntry struct {LastError string `json:"lastError,omitempty"`DiscoveredAt time.Time `json:"discoveredAt"`AdminPages []AdminPage `json:"adminPages,omitempty"`+ // Commands lists the plugin's chat commands for the admin details view.+ // Derived by the SDK and reported via register(), so it's only known once+ // the plugin is loaded — empty for discovered-but-not-loaded plugins.+ Commands []CommandInfo `json:"commands,omitempty"`}// ScanInterval is how often the manager re-scans the plugins directory.@@ -474,6 +478,9 @@ func (m *Manager) List() []DiscoveredEntry {entry.Loaded = isLoadedif isLoaded {entry.AutoDisabled = l.IsDisabled()+ // Command metadata comes from register(), so it's only available+ // once the plugin is loaded.+ entry.Commands = l.Manifest.Commands}out = append(out, entry)}diff --git a/web/components/admin/plugins/PluginDetail.tsx b/web/components/admin/plugins/PluginDetail.tsxindex 9f66a3b649..4e49f7f8fc 100644--- a/web/components/admin/plugins/PluginDetail.tsx+++ b/web/components/admin/plugins/PluginDetail.tsx@@ -3,7 +3,7 @@ import { Alert, Space, Spin, Table, Tabs, Tag, Typography } from 'antd';import { useTranslation } from 'next-export-i18n';import dynamic from 'next/dynamic';import ReactMarkdown from 'react-markdown';-import { Plugin, PluginPermission } from '../../../interfaces/plugin';+import { Plugin, PluginCommand, PluginPermission } from '../../../interfaces/plugin';import { Localization } from '../../../types/localization';import { fetchText, pluginInstructionsUrl } from '../../../utils/apis';import { permissionDescriptionKey } from './permissionDescriptions';@@ -254,6 +254,70 @@ export const PluginDetail = ({ plugin }: PluginDetailProps) => {[permissionRows, pendingSet, t],);+ // Chat commands the plugin registered (reported via register(), so only+ // present once the plugin is loaded). Shown as its own tab when non-empty.+ const commandRows = useMemo(+ () =>+ (plugin.commands ?? []).map((cmd: PluginCommand) => ({+ key: `${cmd.prefix ?? '!'}${cmd.name}`,+ command: `${cmd.prefix ?? '!'}${cmd.name}`,+ description: cmd.description ?? '',+ usage: cmd.usage,+ modOnly: !!cmd.modOnly,+ })),+ [plugin.commands],+ );++ const commandsTab = useMemo(+ () =>+ commandRows.length === 0+ ? null+ : {+ key: '__commands',+ label: t(Localization.Admin.Plugins.commandsTab),+ children: (+ <Table+ dataSource={commandRows}+ pagination={false}+ size="middle"+ columns={[+ {+ title: t(Localization.Admin.Plugins.commandColumnHeader),+ dataIndex: 'command',+ key: 'command',+ width: 220,+ render: (v: string, row: { modOnly: boolean }) => (+ <Space size={6}>+ <code>{v}</code>+ {row.modOnly && (+ <Tag color="blue">{t(Localization.Admin.Plugins.modOnlyTag)}</Tag>+ )}+ </Space>+ ),+ },+ {+ title: t(Localization.Admin.Plugins.descriptionColumnHeader),+ dataIndex: 'description',+ key: 'description',+ render: (v: string, row: { usage?: string }) =>+ row.usage ? (+ <Space direction="vertical" size={2}>+ <span>{v}</span>+ <Text type="secondary">+ <code>{row.usage}</code>+ </Text>+ </Space>+ ) : (+ v+ ),+ },+ ]}+ />+ ),+ },+ [commandRows, t],+ );+const pageTabs = useMemo(() =>uniquePages.map(page => {@@ -304,12 +368,12 @@ export const PluginDetail = ({ plugin }: PluginDetailProps) => {);const tabs = useMemo(() => {- const base = [...pageTabs, permissionsTab];+ const base = [...pageTabs, permissionsTab, ...(commandsTab ? [commandsTab] : [])];// Instructions sits as the second tab: after the first admin page (or// after Permissions when the plugin declares no admin pages), so the// primary page stays the landing tab.return instructionsTab ? [base[0], instructionsTab, ...base.slice(1)] : base;- }, [instructionsTab, pageTabs, permissionsTab]);+ }, [instructionsTab, pageTabs, permissionsTab, commandsTab]);return (<div>diff --git a/web/i18n/en/translation.json b/web/i18n/en/translation.jsonindex dc52ea1355..6fc7ac3c09 100644--- a/web/i18n/en/translation.json+++ b/web/i18n/en/translation.json@@ -188,11 +188,14 @@"overview": "All plugins","configure": "Configure","permissionsTab": "Permissions",+ "commandsTab": "Commands","instructionsTab": "Instructions","instructionsLoadError": "Could not load this plugin's instructions.","permissionColumnHeader": "Permission",+ "commandColumnHeader": "Command","descriptionColumnHeader": "Description","allowedHostsLabel": "Allowed hosts:",+ "modOnlyTag": "mods only","noPermissionsTitle": "No permissions","noPermissionsDescription": "This plugin does not declare any permissions in its manifest.","notFoundTitle": "Plugin not found",diff --git a/web/interfaces/plugin.ts b/web/interfaces/plugin.tsindex 7a383a1890..07ec4671ee 100644--- a/web/interfaces/plugin.ts+++ b/web/interfaces/plugin.ts@@ -80,6 +80,23 @@ export interface Plugin {lastError?: string;discoveredAt: string;adminPages?: PluginAdminPage[];+ // commands lists the plugin's chat commands, derived by the SDK and+ // reported via register(). Only populated once the plugin is loaded+ // (commands aren't in the static manifest). Shown in a Commands tab on the+ // details page and aggregated by the host for the unified !help.+ commands?: PluginCommand[];+}++// PluginCommand is one chat command a plugin advertises, mirroring+// services/plugins.CommandInfo. Informational: the plugin's own router does+// the matching; this drives the admin Commands tab and the host's !help.+export interface PluginCommand {+ name: string;+ prefix?: string;+ description?: string;+ usage?: string;+ aliases?: string[];+ modOnly?: boolean;}// PluginAdminPage is a single admin-only page declared in a plugin'sdiff --git a/web/types/localization.ts b/web/types/localization.tsindex d51e6df9f2..179dcc38a5 100644--- a/web/types/localization.ts+++ b/web/types/localization.ts@@ -452,11 +452,14 @@ export const Localization = {pluginErrorTitle: 'Admin.Plugins.pluginErrorTitle',configure: 'Admin.Plugins.configure',permissionsTab: 'Admin.Plugins.permissionsTab',+ commandsTab: 'Admin.Plugins.commandsTab',instructionsTab: 'Admin.Plugins.instructionsTab',instructionsLoadError: 'Admin.Plugins.instructionsLoadError',permissionColumnHeader: 'Admin.Plugins.permissionColumnHeader',+ commandColumnHeader: 'Admin.Plugins.commandColumnHeader',descriptionColumnHeader: 'Admin.Plugins.descriptionColumnHeader',allowedHostsLabel: 'Admin.Plugins.allowedHostsLabel',+ modOnlyTag: 'Admin.Plugins.modOnlyTag',noPermissionsTitle: 'Admin.Plugins.noPermissionsTitle',noPermissionsDescription: 'Admin.Plugins.noPermissionsDescription',notFoundTitle: 'Admin.Plugins.notFoundTitle',