77 lines
1.7 KiB
Forth
77 lines
1.7 KiB
Forth
|
module PublishHelperBot.Types
|
||
|
|
||
|
open System
|
||
|
open Telegram.Bot
|
||
|
open Telegram.Bot.Types
|
||
|
|
||
|
type ConfigChatId = int64
|
||
|
|
||
|
type CreateYoutubeDlJob = {
|
||
|
url: string
|
||
|
savePath: string
|
||
|
}
|
||
|
|
||
|
type CreateYoutubeDlJobSuccess = {
|
||
|
task: Guid
|
||
|
}
|
||
|
|
||
|
type YoutubeDlStateResponse = {
|
||
|
state: string
|
||
|
}
|
||
|
|
||
|
type YoutubeDlError = {
|
||
|
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 ITgService =
|
||
|
abstract member PostRelay: args: RelayArgs -> unit
|
||
|
abstract member PostMessageToAdminChat: text: string -> unit
|
||
|
abstract member Ping: unit -> unit
|
||
|
abstract member PostVideo: url: string * savePath: string * externalId: Guid -> unit
|