From a564ebbfe309972d278148af0776cc3d49116399 Mon Sep 17 00:00:00 2001 From: Paul Larsen Date: Mon, 6 May 2024 19:50:15 +0200 Subject: [PATCH] add tochat method --- custom_helpers.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/custom_helpers.go b/custom_helpers.go index 4067622..f49dabb 100644 --- a/custom_helpers.go +++ b/custom_helpers.go @@ -78,6 +78,19 @@ func (im InaccessibleMessage) ToMessage() *Message { } } +// ToChat is a helper function to turn a ChatFullInfo struct into a Chat. +func (c ChatFullInfo) ToChat() Chat { + return Chat{ + Id: c.Id, + Type: c.Type, + Title: c.Title, + Username: c.Username, + FirstName: c.FirstName, + LastName: c.LastName, + IsForum: c.IsForum, + } +} + // SendMessage is a helper function to easily call Bot.SendMessage in a chat. func (c Chat) SendMessage(b *Bot, text string, opts *SendMessageOpts) (*Message, error) { return b.SendMessage(c.Id, text, opts)