mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-11 15:53:17 +08:00
Add Telegram and Discord IM channels
This commit is contained in:
parent
7123fce47a
commit
cb74e1c4c7
66 changed files with 8579 additions and 1910 deletions
11
plugin-src/client/channels/discord/api.js
Normal file
11
plugin-src/client/channels/discord/api.js
Normal 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 };
|
||||
25
plugin-src/client/channels/discord/index.js
Normal file
25
plugin-src/client/channels/discord/index.js
Normal 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;
|
||||
19
plugin-src/client/channels/discord/styles.js
Normal file
19
plugin-src/client/channels/discord/styles.js
Normal 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue