From 0b79d6feb1e3d2f87753a1808acbb148a346eeec Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Mon, 17 Jan 2022 14:58:16 -0500 Subject: Refactor some chat commands --- telegram/utils.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'telegram/utils.go') diff --git a/telegram/utils.go b/telegram/utils.go index 0a70af8..556b1a7 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -312,6 +312,21 @@ func (c *Client) formatContent(file *client.File, filename string) string { ) } +func (c *Client) formatRestrict(ban bool, hours int64) client.ChatMemberStatus { + var until int32 + if hours != 0 { + until = int32(time.Now().Unix() + hours*3600) + } + + if ban { + return &client.ChatMemberStatusBanned{ + BannedUntilDate: until, + } + } else { + return &client.ChatMemberStatusLeft{} + } +} + func (c *Client) messageToText(message *client.Message) string { if message.Content == nil { log.Warnf("Unknown message (big emoji?): %#v", message) -- cgit v1.2.3