You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
3.0 KiB
Plaintext
76 lines
3.0 KiB
Plaintext
|
|
;--------------------Telegram----------------------------
|
|
TelegramVideoUpload:
|
|
|
|
if(VideoFileSizeInMB > 50){
|
|
Message = Telegram Upload Skipped. Video is larger than 50MB
|
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
Return
|
|
}
|
|
|
|
CurrentSocialMediaPosting := "Telegram Video"
|
|
Message = Uploading Video to Telegram
|
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
|
|
IniRead, TelegramBotToken, %SettingsIniFilepath%, SocialMediaPoster, TelegramBotToken, %A_Space%
|
|
IniRead, TelegramBotChatID, %SettingsIniFilepath%, SocialMediaPoster, TelegramBotChatID, %A_Space%
|
|
|
|
|
|
LineBreakChar = `%0A ; Used for Telegram API
|
|
|
|
SaveOrPostProgress(Message:="Posting to Telegram",PostType:="Tooltip,ErrorLoggingTextFile")
|
|
|
|
if(TelegramBotToken = "" Or TelegramBotChatID =""){
|
|
Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and click the button again.
|
|
msgbox, 4096, Error!, %Message%
|
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
; Msgbox, 4096, Error!, TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script.
|
|
Return
|
|
}
|
|
|
|
|
|
; If description is longer than 2k chars, then API will error out. goto section that will allow user to edit video description to shorten it for posting
|
|
if(StrLen(SocialMediaDescription) > 2000){
|
|
TelegramVideoUploadDescription := SubStr(SocialMediaDescription, 1, 990)
|
|
TelegramVideoUploadDescription .= "...."
|
|
; msgbox, here goes
|
|
; Goto, CreateDescriptionForVideosPosting
|
|
}
|
|
|
|
|
|
SubmitDescriptionForTelegramVideoUpload:
|
|
TelegramVideoTitle := ASCIISTRReplace(VideoTitle)
|
|
|
|
TelegramBodymessage := ASCIISTRReplace(TelegramVideoUploadDescription)
|
|
|
|
LineBreakChar = `%0A ; Used for API
|
|
|
|
|
|
Message := "*" . TelegramVideoTitle . "*" . LineBreakChar . TelegramBodymessage . LineBreakChar
|
|
|
|
Message := StrReplace(Message, "`n", LineBreakChar) ; replace all new line characters with the global charater
|
|
|
|
; Msgbox % "Message: " Message
|
|
|
|
Status := SendTelegramVideo(TelegramBotToken, TelegramBotChatID, VideoFilepath, caption := Message ) ; you could add more options; compare the Telegram API docs
|
|
if(InStr(Status, "error_code")){
|
|
Message = Telegram Post Failed due to an API Issue. Error was saved to ErrorLogging file. Please send it to Yuriy.
|
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
|
|
; SaveOrPostProgress(Message:=Status,PostType:=",ErrorLoggingTextFile")
|
|
Message = Telegram Error: %Status%
|
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
|
|
ToolTip
|
|
Return
|
|
}
|
|
; msgbox
|
|
|
|
|
|
Message = Upload Complete to Telegram
|
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
IniWrite, Successful, %VideoLinksIniFile%, Misc, Telegram
|
|
; SaveDriverURL()
|
|
AddToTotalVideosUploadedCount()
|
|
|
|
Return |