343.6. producer 示例

以下是如何通过 Telegram Bot API 发送消息到 Telegram Bot API 的消息。

在 Java DSL 中

from("direct:start").to("telegram:bots/123456789:insertYourAuthorizationTokenHere");

或在 Spring XML 中

<route>
    <from uri="direct:start"/>
    <to uri="telegram:bots/123456789:insertYourAuthorizationTokenHere"/>
<route>

代码 123456789:insertYourAuthorizationTokenHere 是与 Bot 对应的 授权令牌

在使用制作者端点而不指定 chat id 选项时,会使用消息正文或标题中包含的信息来识别目标 chat。以下消息正文用于制作者端点(类型为 OutgoingXXXMessage 的消息属于软件包 org.apache.camel.component.telegram.model

Java 类型描述

OutgoingTextMessage

向聊天中发送文本信息

OutgoingPhotoMessage

将照片(JPG、PNG)发送到聊天

OutgoingAudioMessage

将 mp3 音频发送到一个聊天

OutgoingVideoMessage

将 mp4 视频发送到聊天

OutgoingDocumentMessage

将文件发送到聊天(任何介质类型)

byte[]

发送支持的任何介质类型。它要求将 CamelTelegramMediaType 标头设置为适当的介质类型

字符串

向聊天发送文本信息。它会自动转换为 OutgoingTextMessage