使用 discourse-chat-integration 插件设置 Telegram 集成

howto 介绍如何设置 Discourse 随附的 discourse-chat-integration 中的 Telegram 提供程序。

启用插件

discourse-chat-integration 插件已与 Discourse 捆绑。如果您尚未启用,请按照 主插件说明 进行启用。

设置 Telegram

  1. Telegram 的“Botfather” :robot: 交流并设置一个新的机器人。 此处有详细说明
  2. 确保复制 BotFather 提供的 令牌 (token)。它看起来会像这样:
    110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
    

设置 Discourse

  1. 在您的站点设置中,将您之前获得的 令牌 (token) 粘贴到 chat integration telegram access token 设置中,然后保存。

  2. 启用 chat_integration_telegram_enabled 设置,然后保存。

  3. 转到 插件 选项卡,然后转到 聊天集成

  4. 转到 Telegram 选项卡

    • 注意: 如果 Telegram 选项卡不可见,则表示连接到其 API 时出现问题。您应该检查站点日志,然后通过重新启用 chat_integration_telegram_enabled 设置来重试。

添加频道

  1. 将您的机器人添加到 Telegram 上的群聊中(或仅与它开始私聊)。

  2. 向机器人发送任何消息(或在已添加机器人的群聊中发送任何消息)。您应该会收到包含聊天 ID 的消息。您也可以发送以 /getchatid 开头的消息。

  3. 复制聊天 ID。 如果前面有一个负号,请务必包含它——这非常重要!

  4. 转到您的 Discourse 管理面板,插件聊天集成Telegram

  5. 点击 添加频道

  6. 为频道输入一个名称(这仅在 Discourse 管理面板中显示,可以是任何名称)

  7. 将之前的 聊天 ID 粘贴到框中,然后点击 保存频道

  8. 使用您刚刚创建的频道的 测试 按钮来检查一切是否正常。您应该会看到类似以下的内容:

  9. 根据 discourse-chat-integration 说明,为您的频道设置一些“规则”。

  10. 享受所有通知 :allthethings:

在广播频道中使用

要向 Telegram 广播频道发送通知,请将机器人添加为频道管理员,然后发送消息

/getchatid

以获取聊天 ID。然后按照上述说明在 Discourse 上进行设置。对于公共频道,您也可以使用 @channelname 格式(例如 @myforumchannel)代替数字聊天 ID。

在广播频道中,您不能使用斜杠命令来管理规则。

斜杠命令

您可以使用“斜杠命令”从 Telegram 控制规则。检查 chat integration telegram enable slash commands 站点设置是否已启用。请注意,这会授予能够在群聊中发布消息的任何人编辑规则的权限。

要了解如何使用它们,只需发送 /help(如果在群聊中,则发送 /help@my-forum-bot),机器人将向您发送帮助消息。

设置命令自动完成(不是必需的,但会让使用变得容易得多)

  1. Telegram BotFather :robot: 交流
  2. 选择您的机器人,点击 编辑机器人,然后点击 编辑命令
  3. 复制并粘贴此命令列表
    watch - [category] [tag:name] | notify this channel for new topics and new replies matching rule
    follow - [category] [tag:name] | notify this channel for new topics matching rule
    mute - [category] [tag:name] | block notifications to this channel for posts matching rule
    remove - [rule number] | remove a rule (see /status for numbers)
    status - list all rules for this channel
    help - display a help message
    
  4. 您应该收到成功消息 :slight_smile:

其他机器人自定义

Telegram BotFather :robot: 交流,自定义您机器人的名称、描述和图标。您应该保持“群组隐私 (Group Privacy)”启用,否则机器人将尝试响应群聊中的每一条消息。

27 个赞

Isn’t possible to allow users to subscribe to any public category? Without asking an admin to add their id to the whitelist?

1 个赞

Not currently. It is possibly something that could be added (this is how Slack works), but given there is no concept of “organisations” on telegram, we would need to be careful that only public-facing categories are visible.

For per-user stuff you could try the telegram-notifications-plugin

1 个赞

But that means two different bots :sweat_smile:
Anyway, thanks for such good plugins :+1:

1 个赞

I’ve set it up, and it works with bot itself. However, when I set it up for public channel and try to test, an error “422 No Reason Phrase” occurs.
Could someone help me out?

Where does this error occur? In telegram, or in the “test” dialog in the Discourse admin panel?

Hi! I don’t see any submenu in the admin panel to manage Telegram settings

But i got my chat ID through the bot.

Hello,
Can you tell me what different Telegram notifications using the discourse-chat-integration plugin and Telegram Notifications Plugin (discourse-telegram-notifications)

Check the very top of this topic: Telegram Notifications Plugin (discourse-telegram-notifications) (the part with the :warning: next to it)

2 个赞

Whenever ppl reply the telegram bot message, it keeps informing the current chat id, telling ppl to configure something different on the admin panel.

I have the actual msg in portuguese:

Este chat está configurado WTTD Fórum. Configure-o no painel de administração. (ID do bate-papo:-1001093143218)

Google translated:

This chat is configured WTTD Forum. Configure it in the administration panel. (Chat ID: -1001093143218)

It’s quite annoying.

Also I’ve disabled chat integration telegram enable slash commands however still replies the command list.

Is there a way to make the bot ignore any reply?

where can we Add the channel in discourse? we don’t find nothing… caht bot is active and we get also the Chat-ID, thanks in advance

1 个赞

After enabling the telegram site settings, head to your admin panel, click “plugins” at the top, then “chat integration” on the left.

3 个赞

Hello, i don’t know is it ok right now, but after setting up bot in admin and adding bot to channel nothing happened.

Did you try using the “test channel” button. Did you get any errors?

1 个赞

test channel button works, but i expect ‘welcome’ message like in guide.

I’m not sure which guide you are talking about. The chat-integration plugin doesn’t send a welcome message.

Once you have configured the channel, you need to add some “rules”. Then, topics/posts you make on your discourse forum will appear in Telegram.

1 个赞

I’m talking about this instruction.

1 个赞

Ah, I see. Try sending a message in the group, including the bot’s username (like @myforumbot). Then it should respond with that message.

3 个赞

I’ve configured everything successfully, except that whenever a new member leaves/adds into the telegram group which has the ‘chat integration bot’ as one of this groups member, I receive this msg in the telegram group:

New rule: /[watch|follow|mute] [category] [tag:name]
(you must specify a rule type and at least one category or tag)

  • watch – notify this channel for new topics and new replies
  • follow – notify this channel for new topics
  • mute – block notifications to this channel

Remove rule: /remove [rule number]
([rule number] can be found by running /status)

List rules: /status

Help: /help

This msg has started irritating every time a member is added or removed into/from the telegram group.
And if I create a telegram broadcast/channel and add the chat integration bot into that, this problem doesn’t arise therein.