{-# LANGUAGE DeriveGeneric #-}
module Telegram.Bot.API.Types.Chat where

import Data.Aeson (ToJSON(..), FromJSON(..))
import Data.Time.Clock.POSIX (POSIXTime)
import Data.Text (Text)
import GHC.Generics (Generic)

import Telegram.Bot.API.Types.ChatLocation
import Telegram.Bot.API.Types.ChatPhoto
import Telegram.Bot.API.Types.ChatPermissions
import Telegram.Bot.API.Types.Common
import Telegram.Bot.API.Types.Message
import Telegram.Bot.API.Types.ReactionType
import Telegram.Bot.API.Internal.Utils

-- ** Chat

-- | This object represents a chat.
--
-- <https://core.telegram.org/bots/api#chat>
data Chat = Chat
  { Chat -> ChatId
chatId               :: ChatId          -- ^ Unique identifier for this chat. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
  , Chat -> ChatType
chatType             :: ChatType        -- ^ Type of chat.
  , Chat -> Maybe Text
chatTitle            :: Maybe Text      -- ^ Title, for supergroups, channels and group chats
  , Chat -> Maybe Text
chatUsername         :: Maybe Text      -- ^ Username, for private chats, supergroups and channels if available
  , Chat -> Maybe Text
chatFirstName        :: Maybe Text      -- ^ First name of the other party in a private chat
  , Chat -> Maybe Text
chatLastName         :: Maybe Text      -- ^ Last name of the other party in a private chat
  , Chat -> Maybe Bool
chatIsForum          :: Maybe Bool      -- ^ 'True', if the supergroup chat is a forum (has topics enabled).
  , Chat -> Maybe ChatPhoto
chatPhoto            :: Maybe ChatPhoto -- ^ Chat photo. Returned only in getChat.
  , Chat -> Maybe Text
chatActiveUsernames  :: Maybe Text      -- ^ If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in 'getChat'.
  , Chat -> Maybe [ReactionType]
chatAvailableReactions :: Maybe [ReactionType] -- ^ List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. Returned only in 'getChat'.
  , Chat -> Maybe Int
chatAccentColorId    :: Maybe Int -- ^ Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See [accent colors](https://core.telegram.org/bots/api#accent-colors) for more details. Returned only in 'getChat'. Always returned in 'getChat'.
  , Chat -> Maybe Text
chatBackgroundCustomEmojiId :: Maybe Text -- ^ Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background. Returned only in 'getChat'.
  , Chat -> Maybe Int
chatProfileAccentColorId :: Maybe Int -- ^ Identifier of the accent color for the chat's profile background. See [profile accent colors](https://core.telegram.org/bots/api#profile-accent-colors) for more details. Returned only in getChat.
  , Chat -> Maybe Text
chatProfileBackgroundCustomEmojiId :: Maybe Text -- ^ Custom emoji identifier of the emoji chosen by the chat for its profile background. Returned only in 'getChat'.
  , Chat -> Maybe Text
chatEmojiStatusCustomEmojiId :: Maybe Text -- ^ Custom emoji identifier of emoji status of the other party in a private chat. Returned only in 'getChat'.
  , Chat -> Maybe POSIXTime
chatEmojiStatusExpirationDate :: Maybe POSIXTime -- ^ Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any. Returned only in 'getChat'.
  , Chat -> Maybe Text
chatBio              :: Maybe Text      -- ^ Bio of the other party in a private chat. Returned only in `getChat`.
  , Chat -> Maybe Bool
chatHasPrivateForwards :: Maybe Bool    -- ^ 'True', if privacy settings of the other party in the private chat allows to use `tg://user?id=<user_id>` links only in chats with the user. Returned only in getChat.
  , Chat -> Maybe Bool
chatHasRestrictedVoiceAndVideoMessages :: Maybe Bool -- ^ 'True', if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in 'getChat'.
  , Chat -> Maybe Bool
chatJoinToSendMessages :: Maybe Bool    -- ^ 'True', if users need to join the supergroup before they can send messages. Returned only in 'getChat'.
  , Chat -> Maybe Bool
chatJoinByRequest    :: Maybe Bool      -- ^ 'True', if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in 'getChat'.
  , Chat -> Maybe Text
chatDescription      :: Maybe Text      -- ^ Description, for supergroups and channel chats. Returned only in getChat.
  , Chat -> Maybe Text
chatInviteLink       :: Maybe Text      -- ^ Chat invite link, for supergroups and channel chats. Returned only in getChat.
  , Chat -> Maybe Message
chatPinnedMessage    :: Maybe Message   -- ^ Pinned message, for supergroups. Returned only in getChat.
  , Chat -> Maybe ChatPermissions
chatPermissions      :: Maybe ChatPermissions -- ^ Default chat member permissions, for groups and supergroups.
  , Chat -> Maybe Int
chatSlowModeDelay    :: Maybe Int       -- ^ For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds.
  , Chat -> Maybe POSIXTime
chatMessageAutoDeleteTime :: Maybe POSIXTime -- ^ The time after which all messages sent to the chat will be automatically deleted; in seconds.
  , Chat -> Maybe Bool
chatHasAggressiveAntiSpamEnabled :: Maybe Bool -- ^ 'True', if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. Returned only in 'getChat'.
  , Chat -> Maybe Bool
chatHasHiddenMembers :: Maybe Bool      -- ^ 'True', if non-administrators can only get the list of bots and administrators in the chat. Returned only in 'getChat'.
  , Chat -> Maybe Bool
chatHasProtectedContent :: Maybe Bool   -- ^ 'True', if messages from the chat can't be forwarded to other chats.
  , Chat -> Maybe Bool
chatHasVisibleHistory :: Maybe Bool     -- ^ 'True', if new chat members will have access to old messages; available only to chat administrators. Returned only in 'getChat'.
  , Chat -> Maybe Text
chatStickerSetName   :: Maybe Text      -- ^ For supergroups, name of group sticker set. Returned only in getChat.
  , Chat -> Maybe Bool
chatCanSetStickerSet :: Maybe Bool      -- ^ True, if the bot can change the group sticker set. Returned only in `getChat`.
  , Chat -> Maybe ChatId
chatLinkedChatId     :: Maybe ChatId    -- ^ Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
  , Chat -> Maybe ChatLocation
chatLocation         :: Maybe ChatLocation -- ^ For supergroups, the location to which the supergroup is connected. Returned only in getChat.
  }
  deriving ((forall x. Chat -> Rep Chat x)
-> (forall x. Rep Chat x -> Chat) -> Generic Chat
forall x. Rep Chat x -> Chat
forall x. Chat -> Rep Chat x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Chat -> Rep Chat x
from :: forall x. Chat -> Rep Chat x
$cto :: forall x. Rep Chat x -> Chat
to :: forall x. Rep Chat x -> Chat
Generic, Int -> Chat -> ShowS
[Chat] -> ShowS
Chat -> String
(Int -> Chat -> ShowS)
-> (Chat -> String) -> ([Chat] -> ShowS) -> Show Chat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Chat -> ShowS
showsPrec :: Int -> Chat -> ShowS
$cshow :: Chat -> String
show :: Chat -> String
$cshowList :: [Chat] -> ShowS
showList :: [Chat] -> ShowS
Show)

instance ToJSON   Chat where toJSON :: Chat -> Value
toJSON = Chat -> Value
forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
instance FromJSON Chat where parseJSON :: Value -> Parser Chat
parseJSON = Value -> Parser Chat
forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON

-- | Type of chat.
data ChatType
  = ChatTypePrivate
  | ChatTypeGroup
  | ChatTypeSupergroup
  | ChatTypeChannel
  | ChatTypeSender
  deriving ((forall x. ChatType -> Rep ChatType x)
-> (forall x. Rep ChatType x -> ChatType) -> Generic ChatType
forall x. Rep ChatType x -> ChatType
forall x. ChatType -> Rep ChatType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ChatType -> Rep ChatType x
from :: forall x. ChatType -> Rep ChatType x
$cto :: forall x. Rep ChatType x -> ChatType
to :: forall x. Rep ChatType x -> ChatType
Generic, Int -> ChatType -> ShowS
[ChatType] -> ShowS
ChatType -> String
(Int -> ChatType -> ShowS)
-> (ChatType -> String) -> ([ChatType] -> ShowS) -> Show ChatType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatType -> ShowS
showsPrec :: Int -> ChatType -> ShowS
$cshow :: ChatType -> String
show :: ChatType -> String
$cshowList :: [ChatType] -> ShowS
showList :: [ChatType] -> ShowS
Show)

instance ToJSON   ChatType where
  toJSON :: ChatType -> Value
toJSON = ChatType -> Value
forall a (d :: Meta) (f :: * -> *).
(Generic a, GToJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
a -> Value
gtoJSON
instance FromJSON ChatType where
  parseJSON :: Value -> Parser ChatType
parseJSON = Value -> Parser ChatType
forall a (d :: Meta) (f :: * -> *).
(Generic a, GFromJSON Zero (Rep a), Rep a ~ D1 d f, Datatype d) =>
Value -> Parser a
gparseJSON