Add Telegram and Discord IM channels

This commit is contained in:
xmanrui 2026-08-16 14:47:16 +08:00
parent 7123fce47a
commit cb74e1c4c7
66 changed files with 8579 additions and 1910 deletions

View file

@ -0,0 +1,11 @@
import { TOKEN_BOT_ENDPOINTS, createTokenChannelApi } from '../shared/token-api.js';
export const DISCORD_RPC_CHANNEL = '/discord';
export const DISCORD_ENDPOINTS = TOKEN_BOT_ENDPOINTS;
const api = createTokenChannelApi('Discord', ' Gateway 长连接');
export const unwrapRpcResult = api.unwrapRpcResult;
export const normalizeSnapshot = api.normalizeSnapshot;
export const presentError = api.presentError;
export { api as discordClientApi };

View file

@ -0,0 +1,25 @@
import { DiscordLogoGlyph } from '../../channel-logos.js';
import { createTokenChannelSettings } from '../shared/token-channel.js';
import {
DISCORD_ENDPOINTS,
discordClientApi,
} from './api.js';
import { installDiscordStyles } from './styles.js';
const channel = createTokenChannelSettings({
channel: 'Discord',
endpoints: DISCORD_ENDPOINTS,
api: discordClientApi,
LogoGlyph: DiscordLogoGlyph,
installStyles: installDiscordStyles,
pageClass: 'ddc-page',
avatarClass: 'ddc-avatar',
connectionLabel: 'Gateway 长连接',
tokenPlaceholder: '填写 Discord Developer Portal 的 Bot Token',
emptyTitle: '接入 Discord 机器人',
emptyDescription: '先在 Developer Portal 创建 Bot 并邀请到服务器,再在这里完成接入。',
platformLabel: 'Discord Developer Portal',
});
export const DiscordSettingsTab = channel.SettingsTab;
export const DiscordAccountCard = channel.AccountCard;

View file

@ -0,0 +1,19 @@
export const DISCORD_STYLE_ID = 'xmanrui-dsh-im-discord-settings';
const CSS = String.raw`
.ddc-page { --ddt-accent: #5865f2; --ddt-accent-deep: #4752c4; --ddt-accent-wash: #eef0ff; }
.ddc-avatar { color: #fff; background: #5865f2; }
.ddc-avatar svg { display: block; }
`;
export function installDiscordStyles() {
if (typeof document === 'undefined') return () => {};
const existing = document.querySelector(`style[data-plugin-css="${DISCORD_STYLE_ID}"]`);
if (existing) return () => {};
const style = document.createElement('style');
style.dataset.plugin = '@xmanrui/dsh-im';
style.dataset.pluginCss = DISCORD_STYLE_ID;
style.textContent = CSS;
document.head.appendChild(style);
return () => style.remove();
}