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

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

import Telegram.Bot.API.Types.Animation
import Telegram.Bot.API.Types.Audio
import Telegram.Bot.API.Types.Document
import {-# SOURCE #-} Telegram.Bot.API.Types.Chat
import Telegram.Bot.API.Types.ChatShared
import Telegram.Bot.API.Types.Common
import Telegram.Bot.API.Types.Contact
import Telegram.Bot.API.Types.Dice
import Telegram.Bot.API.Types.ForumTopicEdited
import Telegram.Bot.API.Types.ForumTopicClosed
import Telegram.Bot.API.Types.ForumTopicCreated
import Telegram.Bot.API.Types.ForumTopicReopened
import Telegram.Bot.API.Types.Game
import Telegram.Bot.API.Types.InlineKeyboardMarkup
import Telegram.Bot.API.Types.Invoice
import Telegram.Bot.API.Types.Location
import Telegram.Bot.API.Types.MessageAutoDeleteTimerChanged
import Telegram.Bot.API.Types.MessageEntity
import Telegram.Bot.API.Types.PassportData
import Telegram.Bot.API.Types.PhotoSize
import Telegram.Bot.API.Types.Poll
import Telegram.Bot.API.Types.ProximityAlertTriggered
import Telegram.Bot.API.Types.Sticker
import Telegram.Bot.API.Types.SuccessfulPayment
import Telegram.Bot.API.Types.User
import Telegram.Bot.API.Types.UserShared
import Telegram.Bot.API.Types.Venue
import Telegram.Bot.API.Types.Video
import Telegram.Bot.API.Types.VideoChatEnded
import Telegram.Bot.API.Types.VideoChatScheduled
import Telegram.Bot.API.Types.VideoChatStarted
import Telegram.Bot.API.Types.VideoNote
import Telegram.Bot.API.Types.Voice
import Telegram.Bot.API.Types.WebAppData
import Telegram.Bot.API.Types.WriteAccessAllowed
import Telegram.Bot.API.Internal.Utils

-- ** Message

-- | This object represents a message.
data Message = Message
  { Message -> MessageId
messageMessageId             :: MessageId -- ^ Unique message identifier inside this chat.
  , Message -> Maybe MessageThreadId
messageMessageThreadId       :: Maybe MessageThreadId -- ^ Unique identifier of a message thread to which the message belongs; for supergroups only.
  , Message -> Maybe User
messageFrom                  :: Maybe User -- ^ Sender, empty for messages sent to channels.
  , Message -> Maybe Chat
messageSenderChat            :: Maybe Chat -- ^ Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field from contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
  , Message -> POSIXTime
messageDate                  :: POSIXTime -- ^ Date the message was sent in Unix time.
  , Message -> Chat
messageChat                  :: Chat -- ^ Conversation the message belongs to.
  , Message -> Maybe User
messageForwardFrom           :: Maybe User -- ^ For forwarded messages, sender of the original message.
  , Message -> Maybe Chat
messageForwardFromChat       :: Maybe Chat -- ^ For messages forwarded from channels, information about the original channel.
  , Message -> Maybe MessageId
messageForwardFromMessageId  :: Maybe MessageId -- ^ For messages forwarded from channels, identifier of the original message in the channel.
  , Message -> Maybe Text
messageForwardSignature      :: Maybe Text -- ^ For messages forwarded from channels, signature of the post author if present.
  , Message -> Maybe Text
messageForwardSenderName     :: Maybe Text -- ^ Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
  , Message -> Maybe POSIXTime
messageForwardDate           :: Maybe POSIXTime -- ^ For forwarded messages, date the original message was sent in Unix time
  , Message -> Maybe Bool
messageIsTopicMessage        :: Maybe Bool -- ^ 'True', if the message is sent to a forum topic.
  , Message -> Maybe Bool
messageIsAutomaticForward    :: Maybe Bool -- ^ 'True', if the message is a channel post that was automatically forwarded to the connected discussion group.
  , Message -> Maybe Message
messageReplyToMessage        :: Maybe Message -- ^ For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
  , Message -> Maybe User
messageViaBot                :: Maybe User -- ^ Bot through which the message was sent.
  , Message -> Maybe POSIXTime
messageEditDate              :: Maybe POSIXTime -- ^ Date the message was last edited in Unix time
  , Message -> Maybe Bool
messageHasProtectedContent   :: Maybe Bool -- ^ 'True', if the message can't be forwarded.
  , Message -> Maybe MediaGroupId
messageMediaGroupId          :: Maybe MediaGroupId -- ^ The unique identifier of a media message group this message belongs to
  , Message -> Maybe Text
messageAuthorSignature       :: Maybe Text -- ^ Signature of the post author for messages in channels
  , Message -> Maybe Text
messageText                  :: Maybe Text -- ^ For text messages, the actual UTF-8 text of the message, 0-4096 characters.
  , Message -> Maybe [MessageEntity]
messageEntities              :: Maybe [MessageEntity] -- ^ For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
  , Message -> Maybe Animation
messageAnimation             :: Maybe Animation -- ^ Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set.
  , Message -> Maybe Audio
messageAudio                 :: Maybe Audio -- ^ Message is an audio file, information about the file
  , Message -> Maybe Document
messageDocument              :: Maybe Document -- ^ Message is a general file, information about the file.
  , Message -> Maybe [PhotoSize]
messagePhoto                 :: Maybe [PhotoSize] -- ^ Message is a photo, available sizes of the photo
  , Message -> Maybe Sticker
messageSticker               :: Maybe Sticker -- ^ Message is a sticker, information about the sticker
  , Message -> Maybe Video
messageVideo                 :: Maybe Video -- ^ Message is a video, information about the video
  , Message -> Maybe VideoNote
messageVideoNote             :: Maybe VideoNote -- ^ Message is a video note, information about the video message
  , Message -> Maybe Voice
messageVoice                 :: Maybe Voice -- ^ Message is a voice message, information about the file
  , Message -> Maybe Text
messageCaption               :: Maybe Text -- ^ Caption for the audio, document, photo, video or voice, 0-200 characters
  , Message -> Maybe [MessageEntity]
messageCaptionEntities       :: Maybe [MessageEntity] -- ^ For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption.
  , Message -> Maybe Bool
messageHasMediaSpoiler       :: Maybe Bool -- ^ 'True', if the message media is covered by a spoiler animation.
  , Message -> Maybe Contact
messageContact               :: Maybe Contact -- ^ Message is a shared contact, information about the contact
  , Message -> Maybe Dice
messageDice                  :: Maybe Dice -- ^ Message is a dice with random value.
  , Message -> Maybe Game
messageGame                  :: Maybe Game -- ^ Message is a game, information about the game. More about games »  , messageLocation              :: Maybe Location -- ^ Message is a shared location, information about the location
  , Message -> Maybe Poll
messagePoll                  :: Maybe Poll -- ^ Message is a native poll, information about the poll.
  , Message -> Maybe Venue
messageVenue                 :: Maybe Venue -- ^ Message is a venue, information about the venue
  , Message -> Maybe Location
messageLocation              :: Maybe Location -- ^ Message is a shared location, information about the location.
  , Message -> Maybe [User]
messageNewChatMembers        :: Maybe [User] -- ^ New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
  , Message -> Maybe User
messageLeftChatMember        :: Maybe User -- ^ A member was removed from the group, information about them (this member may be the bot itself)
  , Message -> Maybe Text
messageNewChatTitle          :: Maybe Text -- ^ A chat title was changed to this value
  , Message -> Maybe [PhotoSize]
messageNewChatPhoto          :: Maybe [PhotoSize] -- ^ A chat photo was change to this value
  , Message -> Maybe Bool
messageDeleteChatPhoto       :: Maybe Bool -- ^ Service message: the chat photo was deleted
  , Message -> Maybe Bool
messageGroupChatCreated      :: Maybe Bool -- ^ Service message: the group has been created
  , Message -> Maybe Bool
messageSupergroupChatCreated :: Maybe Bool -- ^ Service message: the supergroup has been created. This field can‘t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.
  , Message -> Maybe Bool
messageChannelChatCreated    :: Maybe Bool -- ^ Service message: the channel has been created. This field can‘t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.
  , Message -> Maybe MessageAutoDeleteTimerChanged
messageAutoDeleteTimerChanged :: Maybe MessageAutoDeleteTimerChanged -- ^ Service message: auto-delete timer settings changed in the chat.
  , Message -> Maybe Bool
messageHasAggressiveAntiSpamEnabled :: 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'.
  , Message -> Maybe Bool
messageHasHiddenMembers      :: Maybe Bool -- ^ 'True', if non-administrators can only get the list of bots and administrators in the chat. Returned only in 'getChat'.
  , Message -> Maybe ChatId
messageMigrateToChatId       :: Maybe ChatId -- ^ The group has been migrated to a supergroup with the specified identifier. 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.
  , Message -> Maybe ChatId
messageMigrateFromChatId     :: Maybe ChatId -- ^ The supergroup has been migrated from a group with the specified identifier. 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.
  , Message -> Maybe Message
messagePinnedMessage         :: Maybe Message -- ^ Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
  , Message -> Maybe Invoice
messageInvoice               :: Maybe Invoice -- ^ Message is an invoice for a payment, information about the invoice.
  , Message -> Maybe SuccessfulPayment
messageSuccessfulPayment     :: Maybe SuccessfulPayment -- ^ Message is a service message about a successful payment, information about the payment.
  , Message -> Maybe UserShared
messageUserShared            :: Maybe UserShared -- ^ Service message: a user was shared with the bot.
  , Message -> Maybe ChatShared
messageChatShared            :: Maybe ChatShared -- ^ Service message: a chat was shared with the bot.
  , Message -> Maybe Text
messageConnectedWebsite      :: Maybe Text -- ^ The domain name of the website on which the user has logged in.
  , Message -> Maybe WriteAccessAllowed
messageWriteAccessAllowed    :: Maybe WriteAccessAllowed -- ^ Service message: the user allowed the bot added to the attachment menu to write messages.
  , Message -> Maybe PassportData
messagePassportData          :: Maybe PassportData -- ^ Telegram Passport data.
  , Message -> Maybe ProximityAlertTriggered
messageProximityAlertTriggered :: Maybe ProximityAlertTriggered -- ^ Service message. A user in the chat triggered another user's proximity alert while sharing Live Location.
  , Message -> Maybe ForumTopicCreated
messageForumTopicCreated     :: Maybe ForumTopicCreated -- ^ Service message: forum topic created.
  , Message -> Maybe ForumTopicEdited
messageForumTopicEdited     :: Maybe ForumTopicEdited -- ^ Service message: forum topic edited.
  , Message -> Maybe ForumTopicClosed
messageForumTopicClosed     :: Maybe ForumTopicClosed -- ^ Service message: forum topic closed.
  , Message -> Maybe ForumTopicReopened
messageForumTopicReopened     :: Maybe ForumTopicReopened -- ^ Service message: forum topic reopened.
  , Message -> Maybe VideoChatScheduled
messageVideoChatScheduled    :: Maybe VideoChatScheduled -- ^ Service message: video chat scheduled.
  , Message -> Maybe VideoChatStarted
messageVideoChatStarted      :: Maybe VideoChatStarted -- ^ Service message: video chat started
  , Message -> Maybe VideoChatEnded
messageVideoChatEnded        :: Maybe VideoChatEnded -- ^ Service message: video chat ended.
  , Message -> Maybe VideoChatParticipantsInvited
messageVideoChatParticipantsInvited :: Maybe VideoChatParticipantsInvited -- ^ Service message: new participants invited to a video chat.
  , Message -> Maybe WebAppData
messageWebAppData            :: Maybe WebAppData -- ^ Service message: data sent by a Web App.
  , Message -> Maybe InlineKeyboardMarkup
messageReplyMarkup           :: Maybe InlineKeyboardMarkup -- ^ Inline keyboard attached to the message. `login_url` buttons are represented as ordinary `url` buttons.
  }
  deriving (forall x. Rep Message x -> Message
forall x. Message -> Rep Message x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Message x -> Message
$cfrom :: forall x. Message -> Rep Message x
Generic, Int -> Message -> ShowS
[Message] -> ShowS
Message -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Message] -> ShowS
$cshowList :: [Message] -> ShowS
show :: Message -> String
$cshow :: Message -> String
showsPrec :: Int -> Message -> ShowS
$cshowsPrec :: Int -> Message -> ShowS
Show)

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