diff --git a/bot.go b/bot.go index 5a84a4d..bc62a78 100644 --- a/bot.go +++ b/bot.go @@ -9,6 +9,14 @@ import ( "strings" ) +type ParseMode string + +const ( + ParseMDV2 ParseMode = "MarkdownV2" + ParseHTML ParseMode = "HTML" + ParseMD ParseMode = "Markdown" +) + type Bot struct { token string logger *Logger @@ -184,14 +192,26 @@ func (b *Bot) Debug(debug bool) *Bot { func (ctx *MsgContext) Answer(text string) { _, err := ctx.Bot.SendMessage(&SendMessageP{ - ChatID: ctx.Msg.Chat.ID, - Text: text, + ChatID: ctx.Msg.Chat.ID, + Text: text, + ParseMode: "markdown", }) if err != nil { ctx.Bot.logger.Error(err) } } +func (ctx *MsgContext) Error(err error) { + _, sendErr := ctx.Bot.SendMessage(&SendMessageP{ + ChatID: ctx.Msg.Chat.ID, + Text: err.Error(), + }) + + if sendErr != nil { + ctx.Bot.logger.Error(sendErr) + } +} + func (b *Bot) Logger() *Logger { return b.logger } diff --git a/methods.go b/methods.go index aa61616..e75389d 100644 --- a/methods.go +++ b/methods.go @@ -54,7 +54,7 @@ type SendMessageP struct { ChatID int `json:"chat_id"` MessageThreadID int `json:"message_thread_id,omitempty"` Text string `json:"text"` - ParseMode string `json:"parse_mode,omitempty"` + ParseMode ParseMode `json:"parse_mode,omitempty"` Entities []*MessageEntity `json:"entities,omitempty"` LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"` DisableNotifications bool `json:"disable_notifications,omitempty"` diff --git a/types.go b/types.go index 66885b8..69f2a35 100644 --- a/types.go +++ b/types.go @@ -49,6 +49,8 @@ type Message struct { From *User `json:"from,omitempty"` Chat *Chat `json:"chat,omitempty"` Text string `json:"text"` + + ReplyToMessage *Message `json:"reply_to_message"` } type InaccessableMessage struct {