packages feed

telega 0.2.3 → 0.2.4

raw patch · 20 files changed

+277/−100 lines, 20 filesdep −timePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: time

API changes (from Hackage documentation)

- Network.API.Telegram.Bot.Object.Group: Basic :: Int64 -> Text -> Group
- Network.API.Telegram.Bot.Object.Group: Super :: Int64 -> Text -> (Maybe Text) -> Group
- Network.API.Telegram.Bot.Object.Group: data Group
- Network.API.Telegram.Bot.Object.Group: instance Data.Aeson.Types.FromJSON.FromJSON Network.API.Telegram.Bot.Object.Group.Group
- Network.API.Telegram.Bot.Object.Group: instance GHC.Show.Show Network.API.Telegram.Bot.Object.Group.Group
- Network.API.Telegram.Bot.Object.Update.Message.Content.File: Photo :: [Size] -> File
+ Network.API.Telegram.Bot.Object.Member: Forever :: Until
+ Network.API.Telegram.Bot.Object.Member: Until :: Int -> Until
+ Network.API.Telegram.Bot.Object.Member: [Kick] :: Int64 -> Int -> Until -> Kick Member
+ Network.API.Telegram.Bot.Object.Member: [Promote] :: Int64 -> Int -> Until -> Powers -> Promote Member
+ Network.API.Telegram.Bot.Object.Member: [Restrict] :: Int64 -> Int -> Until -> Restrictions -> Restrict Member
+ Network.API.Telegram.Bot.Object.Member: [Unban] :: Int64 -> Int -> Unban Member
+ Network.API.Telegram.Bot.Object.Member: data Kick a
+ Network.API.Telegram.Bot.Object.Member: data Promote a
+ Network.API.Telegram.Bot.Object.Member: data Restrict a
+ Network.API.Telegram.Bot.Object.Member: data Unban a
+ Network.API.Telegram.Bot.Object.Member: data Until
+ Network.API.Telegram.Bot.Object.Member: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Member.Kick Network.API.Telegram.Bot.Object.Member.Member)
+ Network.API.Telegram.Bot.Object.Member: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Member.Promote Network.API.Telegram.Bot.Object.Member.Member)
+ Network.API.Telegram.Bot.Object.Member: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Member.Restrict Network.API.Telegram.Bot.Object.Member.Member)
+ Network.API.Telegram.Bot.Object.Member: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Member.Unban Network.API.Telegram.Bot.Object.Member.Member)
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Edit (Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location.Live Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location.Location))
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Send (Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption.Caption Data.With.:&: Network.API.Telegram.Bot.Object.Update.Message.Content.File.Audio.Audio))
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Send (Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption.Caption Data.With.:&: Network.API.Telegram.Bot.Object.Update.Message.Content.File.Document.Document))
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Send (Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption.Caption Data.With.:&: Network.API.Telegram.Bot.Object.Update.Message.Content.File.Video.Video))
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Send (Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption.Caption Data.With.:&: Network.API.Telegram.Bot.Object.Update.Message.Content.File.Voice.Voice))
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Send (Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location.Live Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location.Location))
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Send Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location.Location)
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Send Network.API.Telegram.Bot.Object.Update.Message.Content.Poll.Poll)
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Stop * (Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location.Live Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location.Location))
+ Network.API.Telegram.Bot.Object.Update.Message: instance Network.API.Telegram.Bot.Property.Persistable.Persistable * (Network.API.Telegram.Bot.Object.Update.Message.Stop * Network.API.Telegram.Bot.Object.Update.Message.Content.Poll.Poll)
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File: Photography :: [Size] -> File
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption: Caption :: Text -> Caption
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption: instance Data.Aeson.Types.FromJSON.FromJSON Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption.Caption
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption: instance Data.Aeson.Types.ToJSON.ToJSON Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption.Caption
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption: instance GHC.Show.Show Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption.Caption
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption: newtype Caption
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.Photo: data Photo
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.Size: instance Network.API.Telegram.Bot.Property.Identifiable.Identifiable Network.API.Telegram.Bot.Object.Update.Message.Content.File.Size.Size
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI: URI :: Text -> URI
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI: instance Data.Aeson.Types.FromJSON.FromJSON Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI.URI
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI: instance Data.Aeson.Types.ToJSON.ToJSON Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI.URI
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI: instance GHC.Show.Show Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI.URI
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI: newtype URI
+ Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location: [Live] :: Int -> Location -> Live Location
+ Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location: data Live a
+ Network.API.Telegram.Bot.Object.Update.Message.Content.Poll.Option: instance Data.Aeson.Types.ToJSON.ToJSON Network.API.Telegram.Bot.Object.Update.Message.Content.Poll.Option.Option
+ Network.API.Telegram.Bot.Object.Update.Moving.Group: Basic :: Int64 -> Text -> Group
+ Network.API.Telegram.Bot.Object.Update.Moving.Group: Super :: Int64 -> Text -> (Maybe Text) -> Group
+ Network.API.Telegram.Bot.Object.Update.Moving.Group: data Group
+ Network.API.Telegram.Bot.Object.Update.Moving.Group: instance Data.Aeson.Types.FromJSON.FromJSON Network.API.Telegram.Bot.Object.Update.Moving.Group.Group
+ Network.API.Telegram.Bot.Object.Update.Moving.Group: instance GHC.Show.Show Network.API.Telegram.Bot.Object.Update.Moving.Group.Group
- Network.API.Telegram.Bot.Object.Member: Kicked :: Sender -> POSIXTime -> Member
+ Network.API.Telegram.Bot.Object.Member: Kicked :: Sender -> Int -> Member
- Network.API.Telegram.Bot.Object.Member: Restricted :: Sender -> Restrictions -> POSIXTime -> Member
+ Network.API.Telegram.Bot.Object.Member: Restricted :: Sender -> Restrictions -> Int -> Member
- Network.API.Telegram.Bot.Object.Update.Message.Content: Attachment :: (Maybe Text) -> File -> Content
+ Network.API.Telegram.Bot.Object.Update.Message.Content: Attachment :: (Maybe Caption) -> File -> Content
- Network.API.Telegram.Bot.Object.Update.Message.Content: Polling :: Poll -> Content
+ Network.API.Telegram.Bot.Object.Update.Message.Content: Polling :: Text -> Poll -> Content
- Network.API.Telegram.Bot.Object.Update.Message.Content.File: Audiofile :: Text -> Audio -> File
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File: Audiofile :: URI -> Audio -> File
- Network.API.Telegram.Bot.Object.Update.Message.Content.File: General :: Text -> Document -> File
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File: General :: URI -> Document -> File
- Network.API.Telegram.Bot.Object.Update.Message.Content.File: Videofile :: Text -> Video -> File
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File: Videofile :: URI -> Video -> File
- Network.API.Telegram.Bot.Object.Update.Message.Content.File: Voicerecord :: Text -> Voice -> File
+ Network.API.Telegram.Bot.Object.Update.Message.Content.File: Voicerecord :: URI -> Voice -> File
- Network.API.Telegram.Bot.Object.Update.Message.Content.Poll: Closed :: Text -> Text -> [Option] -> Poll
+ Network.API.Telegram.Bot.Object.Update.Message.Content.Poll: Closed :: Text -> [Option] -> Poll
- Network.API.Telegram.Bot.Object.Update.Message.Content.Poll: Opened :: Text -> Text -> [Option] -> Poll
+ Network.API.Telegram.Bot.Object.Update.Message.Content.Poll: Opened :: Text -> [Option] -> Poll

Files

CHANGELOG.md view
@@ -109,3 +109,11 @@ * Define `Persistable` instance for dropping `Notification`s on pressing inline buttons * Remove thumb field from `Audio`, `Document`, `Video` and `Voice` datatypes * Define `Persistable` instances for `Audio`, `Document`, `Video` and `Voice` datatypes++# 0.2.4+* Define `Persistable` instances for `Location` and `Live Location` datatypes+* Define `Stop` `Persistable` instances for `Poll` and `Live Location` datatypes+* Move `Group` module into `Moving` submodule+* Define `Caption` and `URI` datatypes to distinct specialized `Text` values+* Include `URI` field into `Send` `Persistable` instances for `File` objects+* Define `Persistable` instance to kick, unban, restrict and promote `Member`
Network/API/Telegram/Bot/Object.hs view
@@ -3,4 +3,3 @@ import Network.API.Telegram.Bot.Object.Update as Exports import Network.API.Telegram.Bot.Object.Sender as Exports import Network.API.Telegram.Bot.Object.Member as Exports-import Network.API.Telegram.Bot.Object.Group as Exports
− Network/API/Telegram/Bot/Object/Group.hs
@@ -1,22 +0,0 @@-module Network.API.Telegram.Bot.Object.Group (Group (..)) where--import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:), (.:?))-import "base" Control.Applicative ((<*>))-import "base" Control.Monad ((>>=), fail)-import "base" Data.Function (($))-import "base" Data.Functor ((<$>))-import "base" Data.Int (Int64)-import "base" Data.Maybe (Maybe)-import "base" Text.Show (Show)-import "text" Data.Text (Text)--data Group-	= Basic Int64 Text-	| Super Int64 Text (Maybe Text)-	deriving Show--instance FromJSON Group where-	parseJSON = withObject "Group" $ \v -> v .: "type" >>= \case-		("group" :: Text) -> Basic <$> v .: "id" <*> v .: "title"-		("supergroup" :: Text) -> Super <$> v .: "id" <*> v .: "title" <*> v .:? "description"-		_ -> fail "Neither group nor supergroup!"
Network/API/Telegram/Bot/Object/Member.hs view
@@ -1,28 +1,32 @@-module Network.API.Telegram.Bot.Object.Member (Member (..), module Exports) where+module Network.API.Telegram.Bot.Object.Member+	( module Exports, Member (..), Until (..)+	, Kick (..), Unban (..), Restrict (..), Promote (..)) where  import Network.API.Telegram.Bot.Object.Member.Powers as Exports import Network.API.Telegram.Bot.Object.Member.Restrictions as Exports -import "aeson" Data.Aeson (FromJSON (parseJSON), Value (Object), object, withObject, (.:), (.=))-import "base" Control.Applicative (Applicative ((<*>)))-import "base" Control.Monad (Monad ((>>=)), fail)+import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (Object), withObject, (.:))+import "base" Control.Applicative ((<*>))+import "base" Control.Monad (fail, (>>=)) import "base" Data.Bool (Bool)-import "base" Data.Int (Int, Int64) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))+import "base" Data.Int (Int, Int64)+import "base" Data.Semigroup ((<>)) import "base" Text.Show (Show) import "text" Data.Text (Text)-import "time" Data.Time.Clock.POSIX (POSIXTime)+import "unordered-containers" Data.HashMap.Strict (singleton)  import Network.API.Telegram.Bot.Object.Sender (Sender)+import Network.API.Telegram.Bot.Property.Persistable (Persistable (Payload, payload, endpoint))  data Member 	= Creator Sender 	| Administrator Sender Bool Powers 	| Member Sender-	| Restricted Sender Restrictions POSIXTime+	| Restricted Sender Restrictions Int 	| Left Sender-	| Kicked Sender POSIXTime+	| Kicked Sender Int 	deriving Show  instance FromJSON Member where@@ -34,3 +38,61 @@ 		("left" :: Text) -> Left <$> v .: "user" 		("kicked" :: Text) -> Kicked <$> v .: "user" <*> v.: "until_date" 		_ -> fail "Status of chat member is not defined"++-- | Ban forever or until some date (between 30 seconds and 366 days)+data Until = Forever | Until Int++data Kick a where+	Kick :: Int64 -> Int -> Until -> Kick Member++instance Persistable (Kick Member) where+	type Payload (Kick Member) = Kick Member+	payload (Kick chat_id user_id Forever) =+		singleton "chat_id" (toJSON chat_id) <> singleton "user_id" (toJSON user_id)+	payload (Kick chat_id user_id (Until until_date)) = singleton "chat_id" (toJSON chat_id)+		<> singleton "user_id" (toJSON user_id) <> singleton "until_date" (toJSON until_date)+	endpoint _ = "kickChatMember"++data Unban a where+	Unban :: Int64 -> Int -> Unban Member++instance Persistable (Unban Member) where+	type Payload (Unban Member) = Unban Member+	payload (Unban chat_id user_id) =+		singleton "chat_id" (toJSON chat_id)+		<> singleton "user_id" (toJSON user_id)+	endpoint _ = "unbanChatMember"++data Restrict a where+	Restrict :: Int64 -> Int -> Until -> Restrictions -> Restrict Member++instance Persistable (Restrict Member) where+	type Payload (Restrict Member) = Restrict Member+	payload (Restrict chat_id user_id Forever (Restrictions send_msgs send_media_msgs send_other_msgs wp_previews)) =+		singleton "chat_id" (toJSON chat_id) <> singleton "user_id" (toJSON user_id)+		<> singleton "can_send_messages" (toJSON send_msgs) <> singleton "can_send_media_messages" (toJSON send_media_msgs)+		<> singleton "can_send_other_messages" (toJSON send_other_msgs) <> singleton "can_add_web_page_previews" (toJSON wp_previews)+	payload (Restrict chat_id user_id (Until until_date) (Restrictions send_msgs send_media_msgs send_other_msgs wp_previews)) =+		singleton "chat_id" (toJSON chat_id) <> singleton "user_id" (toJSON user_id) <> singleton "until_date" (toJSON until_date)+		<> singleton "can_send_messages" (toJSON send_msgs) <> singleton "can_send_media_messages" (toJSON send_media_msgs)+		<> singleton "can_send_other_messages" (toJSON send_other_msgs) <> singleton "can_add_web_page_previews" (toJSON wp_previews)+	endpoint _ = "restrictChatMember"++data Promote a where+	Promote :: Int64 -> Int -> Until -> Powers -> Promote Member++instance Persistable (Promote Member) where+	type Payload (Promote Member) = Promote Member+	payload (Promote chat_id user_id Forever (Powers change_info post_msgs edit_msgs delete_msgs invite_users restrict_members pin_msgs promote_members)) =+		singleton "chat_id" (toJSON chat_id) <> singleton "user_id" (toJSON user_id)+		<> singleton "can_change_info" (toJSON change_info) <> singleton "can_post_messages" (toJSON post_msgs)+		<> singleton "can_edit_messages" (toJSON edit_msgs) <> singleton "can_delete_messages" (toJSON delete_msgs)+		<> singleton "can_invite_users" (toJSON invite_users) <> singleton "can_restrict_members" (toJSON restrict_members)+		<> singleton "can_pin_messages" (toJSON pin_msgs) <> singleton "can_promote_members" (toJSON promote_members)+	payload (Promote chat_id user_id (Until until_date) (Powers change_info post_msgs edit_msgs delete_msgs invite_users restrict_members pin_msgs promote_members)) =+		singleton "chat_id" (toJSON chat_id) <> singleton "user_id" (toJSON user_id) <> singleton "until_date" (toJSON until_date)+		<> singleton "can_change_info" (toJSON change_info) <> singleton "can_post_messages" (toJSON post_msgs)+		<> singleton "can_edit_messages" (toJSON edit_msgs) <> singleton "can_delete_messages" (toJSON delete_msgs)+		<> singleton "can_invite_users" (toJSON invite_users) <> singleton "can_restrict_members" (toJSON restrict_members)+		<> singleton "can_pin_messages" (toJSON pin_msgs) <> singleton "can_promote_members" (toJSON promote_members)+	endpoint _ = "promoteChatMember"
Network/API/Telegram/Bot/Object/Sender.hs view
@@ -1,6 +1,6 @@ module Network.API.Telegram.Bot.Object.Sender (Sender (..), nickname, firstname, lastname) where -import "aeson" Data.Aeson (FromJSON (parseJSON), Object, object, withObject, (.:), (.:?))+import "aeson" Data.Aeson (FromJSON (parseJSON), Object, withObject, (.:), (.:?)) import "aeson" Data.Aeson.Types (Parser) import "base" Control.Applicative (Applicative ((<*>))) import "base" Control.Monad (Monad ((>>=)))@@ -26,6 +26,11 @@ 	User i _ _ _ _ == User i' _ _ _ _ = i == i' 	_ == _ = False +instance Identifiable Sender where+	type instance Identificator Sender = Int+	ident (Bot i _ _ _ _) = i+	ident (User i _ _ _ _) = i+ type Whom = Int -> Maybe Text -> Text -> Maybe Text -> Maybe Text -> Sender  instance FromJSON Sender where@@ -36,11 +41,6 @@ 		sender v f = f <$> v .: "id" <*> v .:? "username" 			<*> v .: "first_name" <*> v .:? "last_name" 			<*> v .:? "language_code"--instance Identifiable Sender where-	type instance Identificator Sender = Int-	ident (Bot i _ _ _ _) = i-	ident (User i _ _ _ _) = i  nickname :: Lens' Sender (Maybe Text) nickname f (Bot uid nn fn ln lng) = (\nn' -> Bot uid nn' fn ln lng) <$> f nn
Network/API/Telegram/Bot/Object/Update.hs view
@@ -23,6 +23,12 @@ 	| Incoming Int Message 	deriving Show +instance Identifiable Update where+	type instance Identificator Update = Int+	ident (Query i _) = i+	ident (Membership i _) = i+	ident (Incoming i _) = i+ instance FromJSON Update where 	parseJSON = withObject "Update" $ \v -> 		query v <|> membership v <|> incoming v where@@ -35,9 +41,3 @@  		incoming :: Object -> Parser Update 		incoming v = Incoming <$> v .: "update_id" <*> v .: "message"--instance Identifiable Update where-	type instance Identificator Update = Int-	ident (Query i _) = i-	ident (Membership i _) = i-	ident (Incoming i _) = i
Network/API/Telegram/Bot/Object/Update/Message.hs view
@@ -99,35 +99,74 @@ 	endpoint _ = "sendMessage"  instance Persistable (Send Audio) where-	type instance Payload (Send Audio) = Send Audio-	payload (Send chat_id (Audio duration performer title mime_type file_size)) =-		singleton "chat_id" (toJSON chat_id) <> singleton "duration" (toJSON duration)-		<> singleton "performer" (toJSON performer) <> singleton "title" (toJSON title)-		<> singleton "mime_type" (toJSON mime_type) <> singleton "file_size" (toJSON file_size)+	type instance Payload (Send Audio) = Send (URI :&: Audio)+	payload (Send chat_id (uri :&: Audio duration performer title mime_type file_size)) = singleton "file_id" (toJSON uri)+		<> singleton "chat_id" (toJSON chat_id) <> singleton "duration" (toJSON duration) <> singleton "performer" (toJSON performer)+		<> singleton "title" (toJSON title) <> singleton "mime_type" (toJSON mime_type) <> singleton "file_size" (toJSON file_size) 	endpoint _ = "sendAudio" +instance Persistable (Send (Caption :&: Audio)) where+	type instance Payload (Send (Caption :&: Audio)) = Send (Caption :&: URI :&: Audio)+	payload (Send chat_id (caption :&: audio)) = payload (Send chat_id audio) <> singleton "caption" (toJSON caption)+	endpoint _ = "sendAudio"+ instance Persistable (Send Document) where-	type instance Payload (Send Document) = Send Document-	payload (Send chat_id (Document file_name mime_type file_size)) =-		singleton "chat_id" (toJSON chat_id) <> singleton "file_name" (toJSON file_name)+	type instance Payload (Send Document) = Send (URI :&: Document)+	payload (Send chat_id (uri :&: Document file_name mime_type file_size)) = singleton "file_id" (toJSON uri)+		<> singleton "chat_id" (toJSON chat_id) <> singleton "file_name" (toJSON file_name) 		<> singleton "mime_type" (toJSON mime_type) <> singleton "file_size" (toJSON file_size) 	endpoint _ = "sendDocument" +instance Persistable (Send (Caption :&: Document)) where+	type instance Payload (Send (Caption :&: Document)) = Send (Caption :&: URI :&: Document)+	payload (Send chat_id (caption :&: document)) = payload (Send chat_id document) <> singleton "caption" (toJSON caption)+	endpoint _ = "sendDocument"+ instance Persistable (Send Video) where-	type instance Payload (Send Video) = Send Video-	payload (Send chat_id (Video width height duration mime_type file_size)) =-		singleton "chat_id" (toJSON chat_id) <> singleton "duration" (toJSON duration)-		<> singleton "width" (toJSON width) <> singleton "height" (toJSON height)-		<> singleton "mime_type" (toJSON mime_type) <> singleton "file_size" (toJSON file_size)+	type instance Payload (Send Video) = Send (URI :&: Video)+	payload (Send chat_id (uri :&: Video width height duration mime_type file_size)) = singleton "file_id" (toJSON uri)+		<> singleton "chat_id" (toJSON chat_id) <> singleton "duration" (toJSON duration) <> singleton "width" (toJSON width)+		<> singleton "height" (toJSON height) <> singleton "mime_type" (toJSON mime_type) <> singleton "file_size" (toJSON file_size) 	endpoint _ = "sendVideo" +instance Persistable (Send (Caption :&: Video)) where+	type instance Payload (Send (Caption :&: Video)) = Send (Caption :&: URI :&: Video)+	payload (Send chat_id (caption :&: video)) = payload (Send chat_id video) <> singleton "caption" (toJSON caption)+	endpoint _ = "sendVideo"+ instance Persistable (Send Voice) where-	type instance Payload (Send Voice) = Send Voice-	payload (Send chat_id (Voice duration mime_type file_size)) =-		singleton "chat_id" (toJSON chat_id) <> singleton "duration" (toJSON duration)+	type instance Payload (Send Voice) = Send (URI :&: Voice)+	payload (Send chat_id (uri :&: Voice duration mime_type file_size)) = singleton "file_id" (toJSON uri)+		<> singleton "chat_id" (toJSON chat_id) <> singleton "duration" (toJSON duration) 		<> singleton "mime_type" (toJSON mime_type) <> singleton "file_size" (toJSON file_size) 	endpoint _ = "sendVoice" +instance Persistable (Send (Caption :&: Voice)) where+	type instance Payload (Send (Caption :&: Voice)) = Send (Caption :&: URI :&: Voice)+	payload (Send chat_id (caption :&: voice)) = payload (Send chat_id voice) <> singleton "caption" (toJSON caption)+	endpoint _ = "sendVoice"++instance Persistable (Send Location) where+	type instance Payload (Send Location) = Send Location+	payload (Send chat_id (Location latitude longitude)) = singleton "chat_id" (toJSON chat_id)+		<> singleton "latitude" (toJSON latitude) <> singleton "longitude" (toJSON longitude)+	endpoint _ = "sendLocation"++instance Persistable (Send (Live Location)) where+	type instance Payload (Send (Live Location)) = Send (Live Location)+	payload (Send chat_id (Live live_period (Location latitude longitude))) =+		singleton "chat_id" (toJSON chat_id) <> singleton "live_period" (toJSON live_period)+		<> singleton "latitude" (toJSON latitude) <> singleton "longitude" (toJSON longitude)+	endpoint _ = "sendLocation"++instance Persistable (Send Poll) where+	type instance Payload (Send Poll) = Send Poll+	payload (Send chat_id (Opened question options)) = singleton "chat_id" (toJSON chat_id)+		<> singleton "question" (toJSON question) <> singleton "options" (toJSON options)+	payload (Send chat_id (Closed question options)) = singleton "chat_id" (toJSON chat_id)+		<> singleton "question" (toJSON question) <> singleton "options" (toJSON options)+	endpoint _ = "sendPoll"+ data Reply a = Reply Int a  instance Persistable (Send a) => Persistable (Reply a) where@@ -157,6 +196,13 @@ 		<> singleton "text" (toJSON text) <> singleton "reply_markup" (toJSON reply_markup) 	endpoint _ = "editMessageText" +instance Persistable (Edit (Live Location)) where+	type instance Payload (Edit (Live Location)) = Edit Location+	payload (Edit chat_id message_id (Location latitude longitude)) =+		singleton "chat_id" (toJSON chat_id) <> singleton "message_id" (toJSON message_id)+		<> singleton "latitude" (toJSON latitude) <> singleton "longitude" (toJSON longitude)+	endpoint _ = "editMessageLiveLocation"+ data Delete a = Delete Int64 Int  instance Persistable (Delete Message) where@@ -164,6 +210,20 @@ 	payload (Delete chat_id message_id) = singleton "chat_id" (toJSON chat_id) 		<> singleton "message_id" (toJSON message_id) 	endpoint _ = "deleteMessage"++data Stop a = Stop Int64 Int++instance Persistable (Stop (Live Location)) where+	type instance Payload (Stop (Live Location)) = Stop (Live Location)+	payload (Stop chat_id message_id) = singleton "chat_id" (toJSON chat_id)+		<> singleton "message_id" (toJSON message_id)+	endpoint _ = "stopMessageLiveLocation"++instance Persistable (Stop Poll) where+	type instance Payload (Stop Poll) = Stop (Stop Poll)+	payload (Stop chat_id message_id) = singleton "chat_id" (toJSON chat_id)+		<> singleton "message_id" (toJSON message_id)+	endpoint _ = "stopPoll"  data Silently (todo :: * -> *) a = Silently a 
Network/API/Telegram/Bot/Object/Update/Message/Content.hs view
@@ -20,8 +20,8 @@ data Content 	= Textual Text 	| Command Text-	| Attachment (Maybe Text) File-	| Polling Poll+	| Attachment (Maybe Caption) File+	| Polling Text Poll 	| Information Info 	deriving Show @@ -50,7 +50,10 @@ 		information v = Information <$> parseJSON (Object v)  		polling :: Object -> Parser Content-		polling v = Polling <$> v .: "poll"+		polling v = Polling <$> (v .: "poll" >>= poll_id) <*> v .: "poll" where++			poll_id :: Value -> Parser Text+			poll_id = withObject "Poll" $ \p -> p .: "id"  		textual :: Object -> Parser Content 		textual v = Textual <$> v .: "text"
Network/API/Telegram/Bot/Object/Update/Message/Content/File.hs view
@@ -1,27 +1,28 @@ module Network.API.Telegram.Bot.Object.Update.Message.Content.File (File (..), module Exports) where  import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Audio as Exports+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption as Exports import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Document as Exports+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Photo as Exports import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Size as Exports+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI as Exports import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Video as Exports import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Voice as Exports  import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:))-import "aeson" Data.Aeson.Types (Object, Parser, Value)+import "aeson" Data.Aeson.Types (Object, Parser) import "base" Control.Applicative ((<*>), (<|>)) import "base" Control.Monad ((>>=)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Data.String (String) import "base" Text.Show (Show)-import "text" Data.Text (Text)  data File-	= Audiofile Text Audio-	| Videofile Text Video-	| General Text Document-	| Voicerecord Text Voice-	| Photo [Size]+	= Audiofile URI Audio+	| Videofile URI Video+	| General URI Document+	| Voicerecord URI Voice+	| Photography [Size] 	deriving Show  instance FromJSON File where@@ -29,19 +30,16 @@ 		photo v <|> document v <|> audio v <|> video v <|> voice v where  		photo :: Object -> Parser File-		photo v = Photo <$> v .: "photo"+		photo v = Photography <$> v .: "photo"  		audio :: Object -> Parser File-		audio v = Audiofile <$> (v .: "audio" >>= file_id "Audio") <*> v .: "audio"+		audio v = Audiofile <$> (v .: "audio" >>= parseJSON) <*> v .: "audio"  		document :: Object -> Parser File-		document v = General <$> (v .: "document" >>= file_id "Document") <*> v .: "document"+		document v = General <$> (v .: "document" >>= parseJSON) <*> v .: "document"  		video :: Object -> Parser File-		video v = Videofile <$> (v .: "video" >>= file_id "Video") <*> v .: "video"+		video v = Videofile <$> (v .: "video" >>= parseJSON) <*> v .: "video"  		voice :: Object -> Parser File-		voice v = Voicerecord <$> (v .: "voice" >>= file_id "Voice") <*> v .: "voice"--		file_id :: String -> Value -> Parser Text-		file_id otype = withObject otype $ \f -> f .: "file_id"+		voice v = Voicerecord <$> (v .: "voice" >>= parseJSON) <*> v .: "voice"
+ Network/API/Telegram/Bot/Object/Update/Message/Content/File/Caption.hs view
@@ -0,0 +1,16 @@+module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption (Caption (..)) where++import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (String), withText)+import "base" Control.Applicative (pure)+import "base" Data.Function ((.))+import "base" Text.Show (Show)+import "text" Data.Text (Text)++newtype Caption = Caption Text+	deriving Show++instance FromJSON Caption where+	parseJSON = withText "Caption" (pure . Caption)++instance ToJSON Caption where+	toJSON (Caption txt) = String txt
+ Network/API/Telegram/Bot/Object/Update/Message/Content/File/Photo.hs view
@@ -0,0 +1,3 @@+module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Photo (Photo) where++data Photo
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Size.hs view
@@ -9,7 +9,13 @@ import "base" Text.Show (Show) import "text" Data.Text (Text) +import Network.API.Telegram.Bot.Property.Identifiable (Identifiable (Identificator, ident))+ data Size = Size Text Int Int (Maybe Int) deriving Show++instance Identifiable Size where+	type Identificator Size = Text+	ident (Size file_id _ _ _) = file_id  instance FromJSON Size where 	parseJSON = withObject "Size" $ \v -> Size <$> v .: "file_id"
+ Network/API/Telegram/Bot/Object/Update/Message/Content/File/URI.hs view
@@ -0,0 +1,17 @@+module Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI (URI (..)) where++import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (String), withObject, (.:))+import "base" Data.Functor ((<$>))+import "base" Data.Function (($))+import "base" Text.Show (Show)+import "text" Data.Text (Text)++newtype URI = URI Text+	deriving Show++instance FromJSON URI where+	parseJSON = withObject "URI" $ \v ->+		URI <$> v .: "file_id"++instance ToJSON URI where+	toJSON (URI txt) = String txt
Network/API/Telegram/Bot/Object/Update/Message/Content/Info/Location.hs view
@@ -1,15 +1,15 @@-module Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location (Location (..)) where+module Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location (Location (..), Live (..)) where  import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), object, withObject, (.:), (.=)) import "base" Control.Applicative ((<*>))-import "base" Data.Bool (Bool (True, False)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Data.Int (Int, Int64)+import "base" Data.Int (Int) import "base" GHC.Float (Float) import "base" Text.Show (Show) -data Location = Location Float Float deriving Show+data Location = Location Float Float+	deriving Show  instance FromJSON Location where 	parseJSON = withObject "Location" $ \v -> Location@@ -18,3 +18,5 @@ instance ToJSON Location where 	toJSON (Location latitude longitude) = object 		["latitude" .= latitude, "longitude" .= longitude]++data Live a where Live :: Int -> Location -> Live Location
Network/API/Telegram/Bot/Object/Update/Message/Content/Poll.hs view
@@ -2,27 +2,26 @@  import Network.API.Telegram.Bot.Object.Update.Message.Content.Poll.Option as Exports -import "aeson" Data.Aeson (FromJSON (parseJSON), object, withObject, (.:), (.=))+import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:)) import "aeson" Data.Aeson.Types (Object, Parser) import "base" Control.Applicative ((<*>)) import "base" Control.Monad ((>>=))-import "base" Data.Bool (Bool (True, False), bool)+import "base" Data.Bool (bool) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Data.Int (Int, Int64) import "base" Text.Show (Show) import "text" Data.Text (Text)  data Poll-	= Opened Text Text [Option]-	| Closed Text Text [Option]+	= Opened Text [Option]+	| Closed Text [Option] 	deriving Show -type State = Text -> Text -> [Option] -> Poll+type State = Text -> [Option] -> Poll  instance FromJSON Poll where 	parseJSON = withObject "Pool" $ \v -> v .: "is_closed" 		>>= bool (state v Opened) (state v Closed) where  		state :: Object -> State -> Parser Poll-		state v f = f <$> v .: "id" <*> v .: "question" <*> v .: "options"+		state v f = f <$> v .: "question" <*> v .: "options"
Network/API/Telegram/Bot/Object/Update/Message/Content/Poll/Option.hs view
@@ -1,6 +1,7 @@ module Network.API.Telegram.Bot.Object.Update.Message.Content.Poll.Option (Option (..)) where -import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:))+import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON)+	, Value (String), withObject, (.:)) import "base" Control.Applicative ((<*>)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))@@ -13,3 +14,6 @@ instance FromJSON Option where 	parseJSON = withObject "Option" $ \v -> Option 		<$> v .: "text" <*> v .: "voter_counter"++instance ToJSON Option where+	toJSON (Option opt _) = String opt
Network/API/Telegram/Bot/Object/Update/Message/Keyboard.hs view
@@ -5,11 +5,7 @@ import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), object, withObject, (.:), (.=)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Data.Int (Int, Int64)-import "base" Data.Semigroup ((<>)) import "base" Text.Show (Show)-import "text" Data.Text (Text)-import "unordered-containers" Data.HashMap.Strict (singleton)  data Keyboard = Inline [[Button]] deriving Show 
Network/API/Telegram/Bot/Object/Update/Moving.hs view
@@ -1,5 +1,7 @@-module Network.API.Telegram.Bot.Object.Update.Moving (Moving (..)) where+module Network.API.Telegram.Bot.Object.Update.Moving (module Exports, Moving (..)) where +import Network.API.Telegram.Bot.Object.Update.Moving.Group as Exports+ import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:)) import "aeson" Data.Aeson.Types (Object, Parser) import "base" Control.Applicative ((<*>), (<|>))@@ -7,7 +9,6 @@ import "base" Data.Functor ((<$>)) import "base" Text.Show (Show) -import Network.API.Telegram.Bot.Object.Group (Group) import Network.API.Telegram.Bot.Object.Sender (Sender)  data Moving
+ Network/API/Telegram/Bot/Object/Update/Moving/Group.hs view
@@ -0,0 +1,22 @@+module Network.API.Telegram.Bot.Object.Update.Moving.Group (Group (..)) where++import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:), (.:?))+import "base" Control.Applicative ((<*>))+import "base" Control.Monad ((>>=), fail)+import "base" Data.Function (($))+import "base" Data.Functor ((<$>))+import "base" Data.Int (Int64)+import "base" Data.Maybe (Maybe)+import "base" Text.Show (Show)+import "text" Data.Text (Text)++data Group+	= Basic Int64 Text+	| Super Int64 Text (Maybe Text)+	deriving Show++instance FromJSON Group where+	parseJSON = withObject "Group" $ \v -> v .: "type" >>= \case+		("group" :: Text) -> Basic <$> v .: "id" <*> v .: "title"+		("supergroup" :: Text) -> Super <$> v .: "id" <*> v .: "title" <*> v .:? "description"+		_ -> fail "Neither group nor supergroup!"
telega.cabal view
@@ -1,5 +1,5 @@ name:                telega-version:             0.2.3+version:             0.2.4 synopsis:            Telegram Bot API binding description:         High-level bindings, typed entities, inline mode only homepage:            https://github.com/iokasimov/telega@@ -22,7 +22,6 @@     Network.API.Telegram.Bot     Network.API.Telegram.Bot.Core     Network.API.Telegram.Bot.Object-    Network.API.Telegram.Bot.Object.Group     Network.API.Telegram.Bot.Object.Member     Network.API.Telegram.Bot.Object.Member.Powers     Network.API.Telegram.Bot.Object.Member.Restrictions@@ -34,8 +33,11 @@     Network.API.Telegram.Bot.Object.Update.Message.Content     Network.API.Telegram.Bot.Object.Update.Message.Content.File     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Audio+    Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Document+    Network.API.Telegram.Bot.Object.Update.Message.Content.File.Photo     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Size+    Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Video     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Voice     Network.API.Telegram.Bot.Object.Update.Message.Content.Info@@ -46,12 +48,13 @@     Network.API.Telegram.Bot.Object.Update.Message.Keyboard.Button     Network.API.Telegram.Bot.Object.Update.Message.Origin     Network.API.Telegram.Bot.Object.Update.Moving+    Network.API.Telegram.Bot.Object.Update.Moving.Group     Network.API.Telegram.Bot.Property     Network.API.Telegram.Bot.Property.Accessible     Network.API.Telegram.Bot.Property.Identifiable     Network.API.Telegram.Bot.Property.Persistable-  build-depends: base == 4.*, transformers, with, lens, aeson, text, unordered-containers, time, http-client, wreq-  default-extensions: DataKinds, LambdaCase, OverloadedStrings, NoImplicitPrelude, PackageImports, ViewPatterns,+  build-depends: base == 4.*, transformers, with, lens, aeson, text, unordered-containers, http-client, wreq+  default-extensions: DataKinds, LambdaCase, OverloadedStrings, NoImplicitPrelude, PackageImports, GADTs,     AllowAmbiguousTypes, MultiParamTypeClasses, ScopedTypeVariables, UndecidableInstances, UndecidableSuperClasses,     FlexibleInstances, TypeApplications, TypeFamilies, TypeFamilyDependencies, TypeOperators, PolyKinds   default-language: Haskell2010