bot

package
v1.13.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const DingtalkAddr = "https://oapi.dingtalk.com/robot/send"
View Source
const TelegramAddr = "https://api.telegram.org"

Variables

This section is empty.

Functions

func Init

func Init(b Interface)

func Send

func Send(text string) error

func SendRaw

func SendRaw(raw any) error

Types

type Dingtalk

type Dingtalk struct {
	// contains filtered or unexported fields
}

func NewDingtalk

func NewDingtalk(token, secret string) *Dingtalk

func (*Dingtalk) Name

func (bot *Dingtalk) Name() string

func (*Dingtalk) Send

func (bot *Dingtalk) Send(text string) error

func (*Dingtalk) SendRaw

func (bot *Dingtalk) SendRaw(raw any) error

func (*Dingtalk) Sign

func (bot *Dingtalk) Sign(secret string) (string, string)

type DingtalkAt

type DingtalkAt struct {
	AtMobiles []string `json:"atMobiles,omitempty"`
	AtUserIds []string `json:"atUserIds,omitempty"`
	IsAtAll   bool     `json:"isAtAll,omitempty"`
}

type DingtalkMarkdown

type DingtalkMarkdown struct {
	Title string `json:"title"`
	Text  string `json:"text"`
}

type DingtalkReq

type DingtalkReq struct {
	MsgType string      `json:"msgtype"` // such as: "text", "markdown"
	At      *DingtalkAt `json:"at,omitempty"`

	Text     *DingtalkText     `json:"text,omitempty"`
	Markdown *DingtalkMarkdown `json:"markdown,omitempty"`
}

type DingtalkResp

type DingtalkResp struct {
	ErrCode int    `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

type DingtalkText

type DingtalkText struct {
	Content string `json:"content"`
}

type Interface

type Interface interface {
	Name() string
	Send(text string) error
	SendRaw(raw any) error
}

func Bot

func Bot() Interface

type Telegram added in v1.11.0

type Telegram struct {
	// contains filtered or unexported fields
}

func NewTelegram added in v1.11.0

func NewTelegram(token, chatId string) *Telegram

func (*Telegram) Name added in v1.11.0

func (bot *Telegram) Name() string

func (*Telegram) Send added in v1.11.0

func (bot *Telegram) Send(text string) error

func (*Telegram) SendRaw added in v1.11.0

func (bot *Telegram) SendRaw(raw any) error

type TelegramReq added in v1.11.0

type TelegramReq struct {
	ChatId                   string `json:"chat_id"`
	MessageThreadId          int    `json:"message_thread_id,omitempty"`
	Text                     string `json:"text"`
	ParseMode                string `json:"parse_mode,omitempty"`
	Entities                 any    `json:"entities,omitempty"`
	DisableWebPagePreview    bool   `json:"disable_web_page_preview,omitempty"`
	DisableNotification      bool   `json:"disable_notification,omitempty"`
	ProtectContent           bool   `json:"protect_content,omitempty"`
	ReplyToMessageId         int    `json:"reply_to_message_id,omitempty"`
	AllowSendingWithoutReply bool   `json:"allow_sending_without_reply,omitempty"`
	ReplyMarkup              any    `json:"reply_markup,omitempty"`
}

type TelegramResp added in v1.11.0

type TelegramResp struct {
	Ok          bool   `json:"ok"`
	ErrorCode   int    `json:"error_code"`
	Description string `json:"description"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL