diff --git a/docs/.vitepress/sidebar.ts b/docs/.vitepress/sidebar.ts
index 1796841..e88eea9 100644
--- a/docs/.vitepress/sidebar.ts
+++ b/docs/.vitepress/sidebar.ts
@@ -32,6 +32,7 @@ export default {
items: [
{ text: '插件编写准备', link: '/plugin/start' },
{ text: '插件写法', link: '/plugin/create' },
+ { text: '调用 Telegram 接口', link: '/plugin/bot' },
],
},
],
diff --git a/docs/.vitepress/theme/components/ChatMessage.vue b/docs/.vitepress/theme/components/ChatMessage.vue
index d4ef44f..737eb3d 100644
--- a/docs/.vitepress/theme/components/ChatMessage.vue
+++ b/docs/.vitepress/theme/components/ChatMessage.vue
@@ -17,18 +17,18 @@ const colorMap = {
}
const avatarMap = {
- grambot: '',
- b: '',
+ GrambBot: '/icon_256px.jpg',
+ User: '/user.png',
}
const typeMap = {
- grambot: 'tip',
- b: 'danger',
+ GrambBot: 'tip',
+ User: 'danger',
}
const tagMap = {
- grambot: '机器人',
- b: '用户',
+ GrambBot: '机器人',
+ User: '用户',
}
const shown = ref(false)
diff --git a/docs/plugin/bot.md b/docs/plugin/bot.md
new file mode 100644
index 0000000..c29a819
--- /dev/null
+++ b/docs/plugin/bot.md
@@ -0,0 +1,34 @@
+# 调用 Telegram 接口
+
+在 GramBot 中,我们可以通过 Bot 对象来调用 Telegram 支持的平台 API,来完成更多的功能。
+
+## 获取 Bot 对象
+
+```python
+async def start(self, update: Update, context: CallbackContext):
+ bot = context.bot
+```
+
+## 调用 API
+
+```python
+# 向账号发送 你好
+await bot.send_message(777000, "你好")
+```
+
+```python
+@handler.command(command='start', block=False)
+async def start(self, update: Update, context: CallbackContext):
+ await update.effective_chat.send_message('hello world!')
+ await bot.send_message(update.effective_user.id, "你好")
+```
+
+
+/start
+hello world!
+你好
+
+
+## API 文档
+
+https://docs.python-telegram-bot.org/en/v20.6/telegram.bot.html
diff --git a/docs/plugin/create.md b/docs/plugin/create.md
index 9b8d91f..fb0ff84 100644
--- a/docs/plugin/create.md
+++ b/docs/plugin/create.md
@@ -90,6 +90,11 @@ contributors: ["luoshuijs", "zhxycn"]
await update.effective_chat.send_message('hello world!')
```
+
+/start
+hello world!
+
+
### 对于 `ConversationHandler`
由于 `ConversationHandler` 比较特殊,所以**一个 Plugin 类中只能存在一个 `ConversationHandler`**
@@ -112,11 +117,14 @@ class TestConversation(Plugin.Conversation, allow_reentry=True, block=False):
@handler.command(command='entry')
async def entry_point(self, update: Update, context: CallbackContext):
"""do something"""
+ await update.effective_chat.send_message('hello')
+ return STATE_A
@conversation.state(state=STATE_A)
@handler.message(filters=filters.TEXT)
async def state(self, update: Update, context: CallbackContext):
"""do something"""
+ await update.effective_chat.send_message('world!')
@conversation.fallback
@handler.message(filters=filters.TEXT)
@@ -129,6 +137,13 @@ class TestConversation(Plugin.Conversation, allow_reentry=True, block=False):
```
+
+/entry
+hello
+ok
+world!
+
+
### 对于 `Job`
1. 依然需要继承 `core.plugin.Plugin`
diff --git a/docs/public/user.png b/docs/public/user.png
new file mode 100644
index 0000000..1737541
Binary files /dev/null and b/docs/public/user.png differ