{#if !loaded}{:else} {#if activeTab === 'telegram'} {#if showForm} {#if error}
{error}
{/if}
form.icon = v} />
{#if !editing}
{/if}
{/if} {#if bots.length === 0 && !showForm} {:else}
{#each bots as bot}

{bot.name}

{#if bot.bot_username} @{bot.bot_username} {/if} {bot.update_mode === 'webhook' ? t('telegramBot.webhook') : t('telegramBot.polling')}

{bot.token_preview}

editBot(bot)} /> remove(bot.id)} variant="danger" />
{#if expandedSection[bot.id] === 'chats'}
{#if chatsLoading[bot.id]}

{t('common.loading')}

{:else if (chats[bot.id] || []).length === 0}

{t('telegramBot.noChats')}

{:else}
{#each chats[bot.id] as chat}
copyChatId(e, chat.chat_id)} title={t('telegramBot.clickToCopy')} role="button" tabindex="0">
{chat.title || chat.username || 'Unknown'} {chatTypeLabel(chat.type)} {chat.chat_id}
testChat(e, bot.id, chat.chat_id)} disabled={chatTesting[`${bot.id}_${chat.chat_id}`]} /> { e.stopPropagation(); deleteChat(bot.id, chat.id); }} variant="danger" />
{/each}
{/if}
{/if} {#if expandedSection[bot.id] === 'listeners'}
{#if botListenerLoading[bot.id]}

{t('common.loading')}

{:else if (botListenerStatus[bot.id] || []).length === 0}

{t('commandTracker.noListeners')}

{:else}
{#each botListenerStatus[bot.id] as trk}
{trk.name} {trk.enabled ? t('commandTracker.enabled') : t('commandTracker.disabled')}
{t('common.edit')}
{/each}
{/if}

{t('telegramBot.updateMode')}

{#if bot.update_mode === 'polling'} {t('telegramBot.pollingActive')} {/if} {#if bot.update_mode === 'webhook'} {#if webhookStatus[bot.id]} {@const ws = webhookStatus[bot.id]} {ws.url ? t('telegramBot.webhookActive') : t('telegramBot.webhookNotSet')} {#if ws.pending_update_count > 0} ({ws.pending_update_count} {t('telegramBot.pendingUpdates')}) {/if} {#if ws.last_error_message} {t('telegramBot.webhookError')}: {ws.last_error_message} {/if} {:else} {/if} {/if} {#if !settings.external_url && bot.update_mode === 'webhook'} {t('telegramBot.noExternalDomain')} {/if}
{/if}
{/each}
{/if} confirmDelete?.onconfirm()} oncancel={() => confirmDelete = null} /> {/if} {#if activeTab === 'email'} {#if showEmailForm} {#if error}
{error}
{/if}
emailForm.icon = v} />
{/if} {#if emailBots.length === 0 && !showEmailForm} {:else}
{#each emailBots as bot}

{bot.name}

{bot.email} {bot.smtp_host}:{bot.smtp_port} {#if bot.smtp_use_tls} TLS {/if}
testEmailBot(bot.id)} disabled={emailTesting[bot.id]} /> editEmailBot(bot)} /> removeEmail(bot.id)} variant="danger" />
{/each}
{/if} confirmDeleteEmail?.onconfirm()} oncancel={() => confirmDeleteEmail = null} /> {/if} {#if activeTab === 'matrix'} {#if showMatrixForm} {#if error}
{error}
{/if}
matrixForm.icon = v} />
{/if} {#if matrixBots.length === 0 && !showMatrixForm} {:else}
{#each matrixBots as bot}

{bot.name}

{bot.homeserver_url} {#if bot.display_name} {bot.display_name} {/if}
testMatrixBot(bot.id)} disabled={matrixTesting[bot.id]} /> editMatrixBot(bot)} /> removeMatrix(bot.id)} variant="danger" />
{/each}
{/if} confirmDeleteMatrix?.onconfirm()} oncancel={() => confirmDeleteMatrix = null} /> {/if} {/if}