publishhelperbot/PublishHelperBot/Types.fs

108 lines
2.4 KiB
Forth
Raw Permalink Normal View History

2023-02-26 19:08:42 +03:00
module PublishHelperBot.Types
open System
2023-02-27 22:31:40 +03:00
open System.Text.Json.Serialization
2023-02-26 19:08:42 +03:00
open Telegram.Bot
open Telegram.Bot.Types
type ConfigChatId = int64
type CreateYoutubeDlJob = {
2023-02-27 22:31:40 +03:00
[<JsonPropertyName("url")>]
Url: string
[<JsonPropertyName("savePath")>]
SavePath: string
2023-02-26 19:08:42 +03:00
}
type CreateYoutubeDlJobSuccess = {
2023-02-27 22:31:40 +03:00
[<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
2023-02-26 19:08:42 +03:00
}
type YoutubeDlStateResponse = {
2023-02-27 22:31:40 +03:00
[<JsonPropertyName("state")>]
State: string
[<JsonPropertyName("_youtube-dl_")>]
VideoInfo: YoutubeDlStateInfo option
2023-02-26 19:08:42 +03:00
}
type YoutubeDlError = {
2023-02-27 22:31:40 +03:00
[<JsonPropertyName("message")>]
Message: string
2023-02-26 19:08:42 +03:00
}
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
2023-02-27 22:31:40 +03:00
type PostVideoArgs = {
Url: string
SavePath: string
ExternalId: Guid
Title: string option
Width: int option
Height: int option
}
2023-02-26 19:08:42 +03:00
type ITgService =
abstract member PostRelay: args: RelayArgs -> unit
abstract member PostMessageToAdminChat: text: string -> unit
abstract member Ping: unit -> unit
2023-02-27 22:31:40 +03:00
abstract member PostVideo: PostVideoArgs -> unit