diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-17 22:58:16 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-01-17 22:58:16 +0300 |
commit | 0b79d6feb1e3d2f87753a1808acbb148a346eeec (patch) | |
tree | b563a67967d696ccb3baa72c3d851c78ee80947d /telegram/utils.go | |
parent | e260668f91ee7a1a1fb8ecaa159c6795b9db2eb2 (diff) |
Refactor some chat commands
Diffstat (limited to 'telegram/utils.go')
-rw-r--r-- | telegram/utils.go | 15 |
1 files changed, 15 insertions, 0 deletions
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) |