methods

package
Version: v0.0.0-...-de9bd37 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ParseModeHTML 解析HTML
	ParseModeHTML = "HTML"
	// ParseModeMarkdown 解析Markdown
	ParseModeMarkdown = "Markdown"
)

Variables

This section is empty.

Functions

func DelWebhook

func DelWebhook(apiwebsite, token string) error

Types

type Bot

type Bot struct {
	ID        int64  `json:"id"`         // 机器人唯一ID
	FirstName string `json:"first_name"` // 机器人First name
	LastName  string `json:"last_name"`  // 机器人Last name
	UserName  string `json:"username"`   // 机器人用户名
}

Bot 机器人信息

type BotExt

type BotExt struct {
	Bot
	Token      string // 机器人Token
	APIWebsite string // 机器人API网站
}

BotExt 机器人扩展信息

func GetMe

func GetMe(apiwebsite, token string) (*BotExt, error)

GetMe 获取机器人信息

func (*BotExt) AnswerCallbackQuery

func (bot *BotExt) AnswerCallbackQuery(query *types.CallbackQuery, text string, alert bool, url string, cacheTime int32) error

AnswerCallbackQuery 应答查询回调

func (*BotExt) Call

func (bot *BotExt) Call(methodName string, request interface{}) ([]byte, error)

Call 调用方法

func (*BotExt) EditMessageReplyMarkup

func (bot *BotExt) EditMessageReplyMarkup(message *types.Message, text string, mdMode bool,
	markup *InlineKeyboardMarkup) (*types.Message, error)

EditMessageReplyMarkup 标记消息回复标记

func (*BotExt) EditMessageReplyMarkupDisableWebPagePreview

func (bot *BotExt) EditMessageReplyMarkupDisableWebPagePreview(message *types.Message, text string, mdMode bool,
	markup *InlineKeyboardMarkup) (*types.Message, error)

EditMessageReplyMarkupDisableWebPagePreview 标记消息回复标记并禁用网页预览

func (*BotExt) EditReplyMarkup

func (bot *BotExt) EditReplyMarkup(chatID int64, messageID int32, text string, mdMode bool,
	markup *InlineKeyboardMarkup) (*types.Message, error)

EditReplyMarkup 标记消息回复标记

func (*BotExt) EditReplyMarkupDisableWebPagePreview

func (bot *BotExt) EditReplyMarkupDisableWebPagePreview(chatID int64, messageID int32, text string, mdMode bool,
	markup *InlineKeyboardMarkup) (*types.Message, error)

EditReplyMarkupDisableWebPagePreview 标记消息回复标记并禁用网页预览

func (*BotExt) GetFile

func (bot *BotExt) GetFile(fileID string) ([]byte, error)

GetFile 获取文件

func (*BotExt) GetUpdates

func (bot *BotExt) GetUpdates(timeout, offset uint32) ([]*types.Update, error)

GetUpdates 获取更新

func (*BotExt) ReplyMessage

func (bot *BotExt) ReplyMessage(message *types.Message, text string, mdMode bool,
	markup interface{}) (*types.Message, error)

ReplyMessage 回复消息

func (*BotExt) ReplyMessageDisableWebPagePreview

func (bot *BotExt) ReplyMessageDisableWebPagePreview(message *types.Message, text string, mdMode bool,
	markup *InlineKeyboardMarkup) (*types.Message, error)

ReplyMessageDisableWebPagePreview 回复消息并禁用网页预览

func (*BotExt) ReplyPhoto

func (bot *BotExt) ReplyPhoto(message *types.Message, caption string, fileID string,
	markup *InlineKeyboardMarkup) (*types.Message, error)

ReplyPhoto 回复照片

func (*BotExt) SendDocument

func (bot *BotExt) SendDocument(chatID int64, caption string, fileID string,
	markup *InlineKeyboardMarkup) (*types.Message, error)

SendDocument 发送文档

func (*BotExt) SendDocumentFile

func (bot *BotExt) SendDocumentFile(chatID int64, caption string, file []byte,
	filename string, markup *InlineKeyboardMarkup) (*types.Message, error)

SendDocumentFile 发送文档文件

func (*BotExt) SendMessage

func (bot *BotExt) SendMessage(chatID int64, text string, mdMode bool,
	markup interface{}) (*types.Message, error)

SendMessage 发送消息

func (*BotExt) SendMessageDisableWebPagePreview

func (bot *BotExt) SendMessageDisableWebPagePreview(chatID int64, text string, mdMode bool,
	markup interface{}) (*types.Message, error)

SendMessageDisableWebPagePreview 发送消息并禁用网页预览

func (*BotExt) SendPhoto

func (bot *BotExt) SendPhoto(chatID int64, caption string, fileID string,
	markup *InlineKeyboardMarkup) (*types.Message, error)

SendPhoto 发送照片

func (*BotExt) SendPhotoFile

func (bot *BotExt) SendPhotoFile(chatID int64, caption string, file []byte,
	markup *InlineKeyboardMarkup) (*types.Message, error)

SendPhotoFile 发送照片文件

func (*BotExt) SendSticker

func (bot *BotExt) SendSticker(chatID int64, fileID string,
	markup *InlineKeyboardMarkup) (*types.Message, error)

SendSticker 发送贴纸

func (*BotExt) SendStickerFile

func (bot *BotExt) SendStickerFile(chatID int64, file []byte,
	markup *InlineKeyboardMarkup) (*types.Message, error)

SendStickerFile 发送贴纸文件

func (*BotExt) SetWebhook

func (bot *BotExt) SetWebhook(url string, certificate []byte, maxConnections int32,
	allowedUpdates []string) error

SetWebhook 设置webhook

func (*BotExt) Upload

func (bot *BotExt) Upload(methodName string, formdata []Field) ([]byte, error)

Upload 上传文件

type ErrorResonpe

type ErrorResonpe struct {
	OK          bool   `json:"ok"`          // 是否成功
	ErrorCode   int32  `json:"error_code"`  // 错误代码
	Description string `json:"description"` // 描述信息
}

ErrorResonpe 错误响应

type Field

type Field struct {
	Name     string // 字段名
	Text     string // 文本
	File     []byte // 文件
	FileName string // 文件名
}

Field 字段信息

func (*Field) IsFile

func (f *Field) IsFile() bool

IsFile 是否文件

type GetMeResonpe

type GetMeResonpe struct {
	OK     bool `json:"ok"`     // 是否成功
	Result *Bot `json:"result"` // 机器人信息
}

GetMeResonpe 获取信息响应

type InlineKeyboardButton

type InlineKeyboardButton struct {
	Text                         string `json:"text"`                                       // 按钮文本标签
	URL                          string `json:"url,omitempty"`                              // 打开地址
	CallbackData                 string `json:"callback_data,omitempty"`                    // 回调数据
	SwitchInlineQuery            string `json:"switch_inline_query,omitempty"`              // 切换内联查询
	SwitchInlineQueryCurrentChat string `json:"switch_inline_query_current_chat,omitempty"` // 切换内联查询到当前聊天
}

InlineKeyboardButton 内联键盘按钮

type InlineKeyboardMarkup

type InlineKeyboardMarkup struct {
	InlineKeyboard [][]*InlineKeyboardButton `json:"inline_keyboard"` // 按钮列表
}

InlineKeyboardMarkup 内联键盘

func MakeInlineKeyboardMarkup

func MakeInlineKeyboardMarkup(menus []InlineKeyboardButton, columns ...int) *InlineKeyboardMarkup

MakeInlineKeyboardMarkup 生成回调键盘

func MakeInlineKeyboardMarkupAuto

func MakeInlineKeyboardMarkupAuto(menus []InlineKeyboardButton, columns uint) *InlineKeyboardMarkup

MakeInlineKeyboardMarkupAuto 生成回调内联键盘(自动排版)

func (*InlineKeyboardMarkup) Merge

Merge 合并内联键盘

func (*InlineKeyboardMarkup) ToJSON

func (markup *InlineKeyboardMarkup) ToJSON() ([]byte, error)

ToJSON 转换为

type KeyboardButton

type KeyboardButton struct {
	Text            string `json:"text"`                       // 按钮文本标签
	RequestContact  bool   `json:"request_contact,omitempty"`  // 发送联系人信息
	RequestLocation bool   `json:"request_location,omitempty"` // 发送位置信息
}

KeyboardButton 键盘按钮

type ReplyKeyboardMarkup

type ReplyKeyboardMarkup struct {
	Keyboard        [][]*KeyboardButton `json:"keyboard"`                    // 按钮列表
	ResizeKeyboard  bool                `json:"resize_keyboard,omitempty"`   // 自动设置大小
	OneTimeKeyboard bool                `json:"one_time_keyboard,omitempty"` // 使用键盘时隐藏自定义键盘
	Selective       bool                `json:"selective,omitempty"`         // 特定用户可见
}

ReplyKeyboardMarkup 回复键盘

func MakeReplyKeyboardMarkup

func MakeReplyKeyboardMarkup(menus []KeyboardButton, columns ...int) *ReplyKeyboardMarkup

MakeReplyKeyboardMarkup 生成回复键盘

func MakeReplyKeyboardMarkupAuto

func MakeReplyKeyboardMarkupAuto(menus []KeyboardButton, columns uint) *ReplyKeyboardMarkup

MakeReplyKeyboardMarkupAuto 生成回复键盘(自动排版)

func (*ReplyKeyboardMarkup) ToJSON

func (markup *ReplyKeyboardMarkup) ToJSON() ([]byte, error)

ToJSON 转换为

type ReplyKeyboardRemove

type ReplyKeyboardRemove struct {
	RemoveKeyboard bool `json:"remove_keyboard"`     // 删除键盘
	Selective      bool `json:"selective,omitempty"` // 指定人可见
}

ReplyKeyboardRemove 删除回复键盘

func (*ReplyKeyboardRemove) ToJSON

func (markup *ReplyKeyboardRemove) ToJSON() ([]byte, error)

ToJSON 转换为

type SendMessageResonpe

type SendMessageResonpe struct {
	OK     bool           `json:"ok"`     // 是否成功
	Result *types.Message `json:"result"` // 消息内容
}

SendMessageResonpe 发送消息响应

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL