-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from simple-robot/dev/main
Release: v0.0.1-dev1
- Loading branch information
Showing
67 changed files
with
2,481 additions
and
267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
> 对应核心版本: [**v4.0.0-beta3**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-beta3) | ||
|
||
> [!warning] | ||
> **目前版本处于 `dev` 阶段,代表此版本是一个开发预览版,可能不稳定、可能随时发生更改、且不保证可用性。** | ||
|
||
我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-telegram/issues)或[协助](https://github.com/simple-robot/simbot-component-telegram/pulls), | ||
感谢您的贡献与支持! | ||
|
||
也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可! | ||
|
||
此版本在使用 `stdlib` 模块时,可以监听到所有的事件(因为Telegram所有的事件都在一个 `Update` 类型中,这还挺方便的): | ||
|
||
```Kotlin | ||
val bot = BotFactory.create(TOKEN) { | ||
coroutineContext = Dispatchers.IO | ||
|
||
// 可选地配置 engine,比如配置一个代理 | ||
apiClientEngine = CIO.create { | ||
proxy = ProxyBuilder.http("http://127.0.0.1:7790") | ||
} | ||
|
||
// 配置 longPolling 的值即代表启用主动拉取事件的形式,*类似于*其他组件中那种 ws 接收事件的方式。 | ||
// 不配置、配置为 `null` 则代表不启用。 | ||
longPolling = LongPolling( | ||
limit = 100, | ||
timeout = 10.minutes.inWholeSeconds.toInt(), | ||
allowedUpdates = setOf(UpdateValues.MESSAGE_NAME) | ||
) | ||
} | ||
|
||
// 使用 `subscribe` 订阅所有事件、根据类型(以及名称)订阅事件 | ||
bot.subscribe { event -> | ||
println("Event: $event") | ||
} | ||
|
||
// 使用 onXxx 根据某个具体事件的扩展来订阅事件,等同于订阅一个对应类型、名称的事件。 | ||
// 比如此处,订阅事件类型为 `Message` 且事件名为 `"message"` 的事件。 | ||
bot.onMessage { event, message -> | ||
println("event: ${event}") | ||
println("message: ${message}") | ||
} | ||
|
||
// 启动并挂起bot | ||
bot.start() | ||
bot.join() | ||
``` | ||
|
||
> [!note] | ||
> 如果不配置 `longPolling`,也就是只使用 Telegram 的 webhook 的形式接收事件, | ||
> 那么你需要自行启动一个 HTTP 服务,并将接收到的请求体的 JSON 字符串(或解析后的 `Update` 实体)提供给 bot。 | ||
> ```Kotlin | ||
``` | ||
|
||
核心组件模块(`core`模块)目前支持的事件: | ||
|
||
- `TelegramEvent` | ||
- `TelegramMessageRelatedEvent` | ||
- `TelegramMessageEvent` | ||
- `TelegramChatGroupMessageEvent` | ||
- `TelegramSuperGroupMessageEvent` | ||
- `TelegramChannelMessageEvent` | ||
- `TelegramPrivateMessageEvent` | ||
- `TelegramUnsupportedEvent` (一个兜底用的事件类型,可以借助此类型来监听到所有 `stdlib` 模块中的所有尚未提供专属类型的事件类型。) | ||
|
||
目前: | ||
- 发送/回复文本消息、直接借助API发送消息、直接转发消息 (`send/reply(MessageContent`)。 | ||
- 接收消息内的纯文本内容 (`MessageContent.plainText`) | ||
- **暂不支持**解析为 `Messages` (`MessageContent.messages`) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Publish Release | |
on: | ||
push: | ||
tags: | ||
- v*.**.** | ||
- v** | ||
|
||
env: | ||
IS_CI: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.run/runConfigurations/simbot-component-telegram [detekt].run.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="simbot-component-telegram [detekt]" type="GradleRunConfiguration" factoryName="Gradle"> | ||
<ExternalSystemSettings> | ||
<option name="executionName" /> | ||
<option name="externalProjectPath" value="$PROJECT_DIR$" /> | ||
<option name="externalSystemIdString" value="GRADLE" /> | ||
<option name="scriptParameters" value="" /> | ||
<option name="taskDescriptions"> | ||
<list /> | ||
</option> | ||
<option name="taskNames"> | ||
<list> | ||
<option value="detekt" /> | ||
</list> | ||
</option> | ||
<option name="vmOptions" /> | ||
</ExternalSystemSettings> | ||
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> | ||
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> | ||
<DebugAllEnabled>false</DebugAllEnabled> | ||
<RunAsTest>false</RunAsTest> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.