@@ -153,6 +153,37 @@ func (file BaseFile) useExistingFile() bool {
153153 return file .UseExisting
154154}
155155
156+ // BaseEdit is base type of all chat edits.
157+ type BaseEdit struct {
158+ ChatID int64
159+ ChannelUsername string
160+ MessageID int
161+ InlineMessageID string
162+ ReplyMarkup * InlineKeyboardMarkup
163+ }
164+
165+ func (edit BaseEdit ) values () (url.Values , error ) {
166+ v := url.Values {}
167+
168+ if edit .ChannelUsername != "" {
169+ v .Add ("chat_id" , edit .ChannelUsername )
170+ } else {
171+ v .Add ("chat_id" , strconv .FormatInt (edit .ChatID , 10 ))
172+ }
173+ v .Add ("message_id" , strconv .Itoa (edit .MessageID ))
174+ v .Add ("inline_message_id" , edit .InlineMessageID )
175+
176+ if edit .ReplyMarkup != nil {
177+ data , err := json .Marshal (edit .ReplyMarkup )
178+ if err != nil {
179+ return v , err
180+ }
181+ v .Add ("reply_markup" , string (data ))
182+ }
183+
184+ return v , nil
185+ }
186+
156187// MessageConfig contains information about a SendMessage request.
157188type MessageConfig struct {
158189 BaseChat
@@ -500,6 +531,63 @@ func (config ChatActionConfig) method() string {
500531 return "sendChatAction"
501532}
502533
534+ // EditMessageTextConfig allows you to modify the text in a message.
535+ type EditMessageTextConfig struct {
536+ BaseEdit
537+ Text string
538+ ParseMode string
539+ DisableWebPagePreview bool
540+ ReplyMarkup InlineKeyboardMarkup
541+ }
542+
543+ func (config EditMessageTextConfig ) values () (url.Values , error ) {
544+ v , _ := config .BaseEdit .values ()
545+
546+ v .Add ("text" , config .Text )
547+ v .Add ("parse_mode" , config .ParseMode )
548+ v .Add ("disable_web_page_preview" , strconv .FormatBool (config .DisableWebPagePreview ))
549+
550+ return v , nil
551+ }
552+
553+ func (config EditMessageTextConfig ) method () string {
554+ return "editMessageText"
555+ }
556+
557+ // EditMessageCaptionConfig allows you to modify the caption of a message.
558+ type EditMessageCaptionConfig struct {
559+ BaseEdit
560+ Caption string
561+ ReplyMarkup InlineKeyboardMarkup
562+ }
563+
564+ func (config EditMessageCaptionConfig ) values () (url.Values , error ) {
565+ v , _ := config .BaseEdit .values ()
566+
567+ v .Add ("caption" , config .Caption )
568+
569+ return v , nil
570+ }
571+
572+ func (config EditMessageCaptionConfig ) method () string {
573+ return "editMessageCaption"
574+ }
575+
576+ // EditMessageReplyMarkup allows you to modify the reply markup
577+ // of a message.
578+ type EditMessageReplyMarkup struct {
579+ BaseEdit
580+ ReplyMarkup InlineKeyboardMarkup
581+ }
582+
583+ func (config EditMessageReplyMarkup ) values () (url.Values , error ) {
584+ return config .BaseEdit .values ()
585+ }
586+
587+ func (config EditMessageReplyMarkup ) method () string {
588+ return "editMessageReplyMarkup"
589+ }
590+
503591// UserProfilePhotosConfig contains information about a
504592// GetUserProfilePhotos request.
505593type UserProfilePhotosConfig struct {
0 commit comments