@koishijs/plugin-adapter-telegram
接入方法
- 搜索 @botfather(有个官方认证的符号)并进入聊天界面
- After entering
start
, a menu will appear. You can use commands to configure your bot here. - To create a bot, click
/newbot
and follow the instructions to finish the process of creation. - 使用
/setprivacy
关闭 Privacy Mode(设置为 DISABLED,不然机器人只能收到特定消息) - 创建完毕后,你会获得一个 token(请注意不要泄露),将其作为机器人配置项即可使用
参考文档:https://core.telegram.org/bots
TIP
如果启动机器人后发现收不到不带 /
的消息,这很可能是由于 Privacy Mode 未开启。如果开启后仍然收不到消息,请尝试将机器人从群组中移除后重新加入。
机器人选项
options.protocol
- 可选值: server, polling
要使用的协议类型。
options.token
- 类型:
string
机器人账户的令牌。
options.endpoint
- 类型:
string
- 默认值:
'https://api.telegram.org'
要连接的服务器地址。
options.proxyAgent
- 类型:
string
- 默认值:
app.config.request.proxyAgent
请求时默认使用的网络代理。
options.files.endpoint
- 类型:
string
- 默认值:
options.endpoint
文件请求的终结点。
options.files.local
- 类型:
boolean
- 默认值:
false
是否启用 Telegram Bot API 本地模式。
适配器选项
options.path
- 类型:
string
- 默认值:
'/telegram'
服务器监听的路径。
options.selfUrl
- 类型:
string
Koishi 服务暴露在公网的地址,会覆盖 app.config.selfUrl
的值。
内部 API
internal.addStickerToSet()
internal.answerCallbackQuery()
internal.answerInlineQuery()
internal.answerPreCheckoutQuery()
internal.answerShippingQuery()
internal.answerWebAppQuery()
internal.approveChatJoinRequest()
internal.banChatMember()
internal.banChatSenderChat()
internal.close()
internal.closeForumTopic()
internal.closeGeneralForumTopic()
internal.copyMessage()
internal.createChatInviteLink()
internal.createForumTopic()
internal.createInvoiceLink()
internal.createNewStickerSet()
internal.declineChatJoinRequest()
internal.deleteChatPhoto()
internal.deleteChatStickerSet()
internal.deleteForumTopic()
internal.deleteMessage()
internal.deleteMyCommands()
internal.deleteStickerFromSet()
internal.deleteWebhook()
internal.editChatInviteLink()
internal.editForumTopic()
internal.editGeneralForumTopic()
internal.editMessageCaption()
internal.editMessageLiveLocation()
internal.editMessageMedia()
internal.editMessageReplyMarkup()
internal.editMessageText()
internal.exportChatInviteLink()
internal.forwardMessage()
internal.getChat()
internal.getChatAdministrators()
internal.getChatMember()
internal.getChatMemberCount()
internal.getChatMenuButton()
internal.getCustomEmojiStickers()
internal.getFile()
internal.getForumTopicIconStickers()
internal.getGameHighScores()
internal.getMe()
internal.getMyCommands()
internal.getMyDefaultAdministratorRights()
internal.getStickerSet()
internal.getUpdates()
internal.getUserProfilePhotos()
internal.getWebhookInfo()
internal.hideGeneralForumTopic()
internal.leaveChat()
internal.logOut()
internal.pinChatMessage()
internal.promoteChatMember()
internal.reopenForumTopic()
internal.reopenGeneralForumTopic()
internal.restrictChatMember()
internal.revokeChatInviteLink()
internal.sendAnimation()
internal.sendAudio()
internal.sendChatAction()
internal.sendContact()
internal.sendDice()
internal.sendDocument()
internal.sendGame()
internal.sendInvoice()
internal.sendLocation()
internal.sendMediaGroup()
internal.sendMessage()
internal.sendPhoto()
internal.sendPoll()
internal.sendSticker()
internal.sendVenue()
internal.sendVideo()
internal.sendVideoNote()
internal.sendVoice()
internal.setChatAdministratorCustomTitle()
internal.setChatDescription()
internal.setChatMenuButton()
internal.setChatPermissions()
internal.setChatPhoto()
internal.setChatStickerSet()
internal.setChatTitle()
internal.setGameScore()
internal.setMyCommands()
internal.setMyDefaultAdministratorRights()
internal.setPassportDataErrors()
internal.setStickerPositionInSet()
internal.setStickerSetThumb()
internal.setWebhook()
internal.stopMessageLiveLocation()
internal.stopPoll()
internal.unbanChatMember()
internal.unbanChatSenderChat()
internal.unhideGeneralForumTopic()
internal.unpinAllChatMessages()
internal.unpinAllForumTopicMessages()
internal.unpinChatMessage()
internal.uploadStickerFile()
内部事件
telegram/callback-query
telegram/channel-post
telegram/chat-join-request
telegram/chat-member
telegram/chosen-inline-result
telegram/edited-channel-post
telegram/edited-message
telegram/inline-query
telegram/message
telegram/my-chat-member
telegram/poll-answer
telegram/poll
telegram/pre-checkout-query
telegram/shipping-query