mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-11 00:32:43 +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/telegram/api.js
Normal file
11
plugin-src/client/channels/telegram/api.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import { TOKEN_BOT_ENDPOINTS, createTokenChannelApi } from '../shared/token-api.js';
|
||||
|
||||
export const TELEGRAM_RPC_CHANNEL = '/telegram';
|
||||
export const TELEGRAM_ENDPOINTS = TOKEN_BOT_ENDPOINTS;
|
||||
|
||||
const api = createTokenChannelApi('Telegram', ' Bot API 长轮询');
|
||||
|
||||
export const unwrapRpcResult = api.unwrapRpcResult;
|
||||
export const normalizeSnapshot = api.normalizeSnapshot;
|
||||
export const presentError = api.presentError;
|
||||
export { api as telegramClientApi };
|
||||
25
plugin-src/client/channels/telegram/index.js
Normal file
25
plugin-src/client/channels/telegram/index.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { TelegramLogoGlyph } from '../../channel-logos.js';
|
||||
import { createTokenChannelSettings } from '../shared/token-channel.js';
|
||||
import {
|
||||
TELEGRAM_ENDPOINTS,
|
||||
telegramClientApi,
|
||||
} from './api.js';
|
||||
import { installTelegramStyles } from './styles.js';
|
||||
|
||||
const channel = createTokenChannelSettings({
|
||||
channel: 'Telegram',
|
||||
endpoints: TELEGRAM_ENDPOINTS,
|
||||
api: telegramClientApi,
|
||||
LogoGlyph: TelegramLogoGlyph,
|
||||
installStyles: installTelegramStyles,
|
||||
pageClass: 'dtg-page',
|
||||
avatarClass: 'dtg-avatar',
|
||||
connectionLabel: 'Bot API 长轮询',
|
||||
tokenPlaceholder: '填写 @BotFather 生成的 Bot Token',
|
||||
emptyTitle: '接入 Telegram 机器人',
|
||||
emptyDescription: '先通过 @BotFather 获取 Bot Token,再在这里完成接入。',
|
||||
platformLabel: 'Telegram',
|
||||
});
|
||||
|
||||
export const TelegramSettingsTab = channel.SettingsTab;
|
||||
export const TelegramAccountCard = channel.AccountCard;
|
||||
19
plugin-src/client/channels/telegram/styles.js
Normal file
19
plugin-src/client/channels/telegram/styles.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
export const TELEGRAM_STYLE_ID = 'xmanrui-dsh-im-telegram-settings';
|
||||
|
||||
const CSS = String.raw`
|
||||
.dtg-page { --ddt-accent: #229ed9; --ddt-accent-deep: #1687bd; --ddt-accent-wash: #eaf7fd; }
|
||||
.dtg-avatar { color: #fff; background: #229ed9; }
|
||||
.dtg-avatar svg { display: block; }
|
||||
`;
|
||||
|
||||
export function installTelegramStyles() {
|
||||
if (typeof document === 'undefined') return () => {};
|
||||
const existing = document.querySelector(`style[data-plugin-css="${TELEGRAM_STYLE_ID}"]`);
|
||||
if (existing) return () => {};
|
||||
const style = document.createElement('style');
|
||||
style.dataset.plugin = '@xmanrui/dsh-im';
|
||||
style.dataset.pluginCss = TELEGRAM_STYLE_ID;
|
||||
style.textContent = CSS;
|
||||
document.head.appendChild(style);
|
||||
return () => style.remove();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue