This package provides a webhook adapter for sending messages (text or markdown) to multiple IM bots via the official webhook API.
- Send Messages to Multiple Bots: Easily send text or markdown messages to all registered bots.
- Bot Management: Register multiple bots with the
BotManagerto send messages across various channels.
- WeCom
- FeiShu
To use this package in your Go project, you can install it by running:
go get github.com/gmodx/im-bot-webhook-adapterYou can register multiple bots using their respective webhook keys. For example:
import "github.com/gmodx/im-bot-webhook-adapter"
weComBot := imbotwebhookadapter.NewWeComBot("your_wecom_webhook_key")
imbotwebhookadapter.Register("bot_name", weComBot)Once the bots are registered, you can send messages to all registered bots.
imbotwebhookadapter.Send(imbotwebhookadapter.MsgType_Text, "This is a text message")You can also send markdown messages:
imbotwebhookadapter.Send(imbotwebhookadapter.MsgType_Markdown, "This is a **markdown** message")- Text: Sends a plain text message.
- Markdown: Sends a message formatted with markdown syntax.
The Bot interface allows you to implement any type of bot that supports sending messages:
type Bot interface {
Send(msgType MsgType, content string) error
}Bots can be registered and managed using the BotManager.
Here's a complete example of registering bots and sending a message:
package main
import "github.com/gmodx/im-bot-webhook-adapter"
func main() {
weComBot := imbotwebhookadapter.NewWeComBot("your_wecom_webhook_key")
imbotwebhookadapter.Register("WeComBot", weComBot)
// Send a text message to all registered bots
imbotwebhookadapter.Send(imbotwebhookadapter.MsgType_Text, "Hello from WeCom Bot!")
}