publishhelperbot/PublishHelperBot/Types.fs
Vladislav Khapin 07b589e2a0 fix video size
2023-02-27 23:31:40 +04:00

108 lines
2.4 KiB
Forth

module PublishHelperBot.Types
open System
open System.Text.Json.Serialization
open Telegram.Bot
open Telegram.Bot.Types
type ConfigChatId = int64
type CreateYoutubeDlJob = {
[<JsonPropertyName("url")>]
Url: string
[<JsonPropertyName("savePath")>]
SavePath: string
}
type CreateYoutubeDlJobSuccess = {
[<JsonPropertyName("task")>]
Task: Guid
}
type YoutubeDlInfoDict = {
[<JsonPropertyName("title")>]
Title: string option
[<JsonPropertyName("height")>]
Height: int option
[<JsonPropertyName("width")>]
Width: int option
}
type YoutubeDlStateInfo = {
[<JsonPropertyName("info_dict")>]
InfoDict: YoutubeDlInfoDict option
}
type YoutubeDlStateResponse = {
[<JsonPropertyName("state")>]
State: string
[<JsonPropertyName("_youtube-dl_")>]
VideoInfo: YoutubeDlStateInfo option
}
type YoutubeDlError = {
[<JsonPropertyName("message")>]
Message: string
}
type CreateJobResult = Result<CreateYoutubeDlJobSuccess, YoutubeDlError>
type CheckJobResult = Result<YoutubeDlStateResponse, YoutubeDlError>
type CleanJobResult = Result<YoutubeDlStateResponse, YoutubeDlError>
type IYoutubeDlClient =
abstract member CreateJob: CreateYoutubeDlJob -> Async<CreateJobResult>
abstract member CheckJob: externalId: Guid -> Async<CheckJobResult>
abstract member CleanJob: externalId: Guid -> Async<CleanJobResult>
type IYoutubeDlService =
abstract member AddJob: url: string -> Async<Guid>
type TgServiceConfig = {
Client: ITelegramBotClient
ChannelId: ConfigChatId
AdminChatId: ConfigChatId
YoutubeDlClient: IYoutubeDlClient
}
type RelayCaptionMode =
| WithAuthor
| Anonymous
| Unknown
type RelayType =
| Text
| Photo of media: string * caption: string
| Video of video: string * caption: string
type RelayArgs = {
ReplyChatId: int64
ReplyMessageId: int
Relay: RelayType
}
[<RequireQualifiedAccess>]
type BotUpdateType =
| RelayUpdate of RelayArgs
| YoutubeRepost of url: string
| Ping
| Skip
type ITgUpdateHandler =
abstract member PostUpdate: Update -> unit
type PostVideoArgs = {
Url: string
SavePath: string
ExternalId: Guid
Title: string option
Width: int option
Height: int option
}
type ITgService =
abstract member PostRelay: args: RelayArgs -> unit
abstract member PostMessageToAdminChat: text: string -> unit
abstract member Ping: unit -> unit
abstract member PostVideo: PostVideoArgs -> unit