diff --git a/Freedomain Video Uploader.ahk b/Freedomain Video Uploader.ahk index 0e62085..19d60c7 100644 --- a/Freedomain Video Uploader.ahk +++ b/Freedomain Video Uploader.ahk @@ -35,7 +35,7 @@ ScriptVersion = 3.20 FullScriptName := ScriptName . " - " . ScriptVersion -; UStartTime := A_TickCount ; start time +UStartTime := A_TickCount ; start time ; Included Files - These have to be included at the top for the Global variables to get registered early? #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\General-Functions.ahk @@ -149,6 +149,8 @@ IniRead, ShowTooltipProgress, %SettingsIniFilepath%, General, ShowTooltipProgres ; ToolTip, reading settings ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip") +IniRead, XPosition, %SettingsIniFilepath%, General, XPosition +IniRead, YPosition, %SettingsIniFilepath%, General, YPosition IniRead, RootDirToStartIn, %SettingsIniFilepath%, General, RootDirToStartIn @@ -817,7 +819,12 @@ Gui, Add, StatusBar,Center, Total Videos Uploaded: %TotalVideosUploaded% ; Show GUI to the user Gui, +Resize +MaximizeBox + +if(XPosition and YPosition) +Gui, Show, x%XPosition% y%YPosition%, %FullScriptName% - Upload Settings - %BodyTextFilePath% +else, Gui, Show,, %FullScriptName% - Upload Settings - %BodyTextFilePath% + ControlFocus, Edit1, %FullScriptName% ToolTip @@ -833,12 +840,10 @@ if(SkipToDBInfo){ ; Write current project to ini file for easy reloading IniWrite, %BodyTextFilePath%, %SettingsIniFilepath%, %ScriptSettingsSection%, LastPost -; calculate run time and convert to seconds -; URunTime := round(((A_TickCount - UStartTime) / 1000), 2) -; Msgbox % "URunTime: " URunTime +URunTime1 := round(((A_TickCount - UStartTime) / 1000), 2) -;---Check for Update--- +;---Check for Updates--- ;------------------------------------------------ ; msgbox, checking for updates if(AutoUpdateCheck AND !UpdateAvailable){ @@ -850,43 +855,20 @@ if(AutoUpdateCheck AND !UpdateAvailable){ ; UpdateAvailable := if(CheckForUpdates(GitReleasesAPIURL)) - GuiControl ,, UpdateAvailable, Uploader Update Available + GuiControl,,UpdateAvailable, Uploader Update Available if(CheckForChromeUpdates(ChromeFilepath)) - GuiControl ,, ChromeUpdateAvailable, Chrome Update Available - - ; GetChromeFilepath() -} -; msgbox, done! -; msgbox, checking update -; msgbox % -; msgbox - -; if() -; Initiate Chrome Filepath Variable -; @todo: find a better location for this? - -; GetChromeFilepath() - -; Msgbox % "ChromeFIlepath: " ChromeFIlepath -/* -if(!InStr(ChromeFilepath, A_scriptDir)){ - ; Chrome portale is not downloaded. Ask user to download it. - msgbox, download newest portable chrome? - LatestVersion := GetLatestChromeStableVersion() - Msgbox % "LatestVersion: " LatestVersion - DownloadURLs := GetDownloadURLOfChromeAndDriver(LatestVersion) - Msgbox % "DownloadURLs: " DownloadURLs - Msgbox % "chromedriverDLURL64: " chromedriverDLURL64 - Msgbox % "chromeDLURL64: " chromeDLURL64 + GuiControl,,ChromeUpdateAvailable, Chrome Update Available } -*/ -; DevModeMsgBox(AutoUpdateCheck) -; DevModeMsgBox(UpdateAvailable) +; calculate run time and convert to seconds +URunTime2 := round(((A_TickCount - UStartTime) / 1000), 2) +; Msgbox % "URunTime1: " URunTime1 +; Msgbox % "URunTime2: " URunTime2 +; Msgbox % "URunTime: " URunTime Return @@ -1027,8 +1009,10 @@ if(CurrentSocialMediaPosting = "Discord") Goto, SubmitDescriptionForDiscordVideosChannel if(CurrentSocialMediaPosting = "Telegram") Goto, SubmitDescriptionForTelegramVideosChannel + if(CurrentSocialMediaPosting = "Telegram Video") goto, SubmitDescriptionForTelegramVideoUpload + Return @@ -1049,6 +1033,9 @@ CreateDescriptionForSocialMedia(){ ; -------------------------------Upload Video Functionality------------------------------- StartScript: WinGetPos, XPosition, YPosition, , , A +IniWrite, %XPosition%, %SettingsIniFilepath%, General, XPosition +IniWrite, %YPosition%, %SettingsIniFilepath%, General, YPosition + ; Msgbox % "XPosition: " XPosition ; Msgbox % "YPosition: " YPosition Gui, Submit @@ -1160,7 +1147,6 @@ if(LBRYURLSlug = "") ; if slug spot is blank, then set it to video title LBRYURLSlug := VideoTitle LBRYURLSlug := LBRYCMDTextReplacement(LBRYURLSlug) -; Msgbox % "LBRYURLSlug: " LBRYURLSlug ; Save the LBRY URL Slug to .ini file in case it's needed later IniWrite, %LBRYURLSlug%, %VideoLinksIniFile%, Misc, LBRYUrlSlug IniWrite, %VideoThumbFilepath%, %VideoLinksIniFile%, Misc, VideoThumbFilepath @@ -1208,9 +1194,6 @@ SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") JSVideoDescription := FormatTextToJSText(VideoDescription) JSVideoTitle := FormatTextToJSText(VideoTitle) -; Save json description to errorlogging file -; Message = JSVideoDescription: `n" %JSVideoDescription% -; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") ; -------------------------------/Log Info To Text------------------------------- @@ -1224,54 +1207,50 @@ VideoTags := StrReplace(VideoTags, " ",",") KeywordsArray := StrSplit(VideoTags,",") -if(Facebook){ - UploadedToSites .= "Facebook," - ; gosub, FacebookUpload -} +; Call each sub one by one, if errors occur then an upload will be stopped and the next upload will then proceed -if(Telegram){ - UploadedToSites .= "Telegram," - gosub, TelegramVideoUpload -} +/* -; Call each sub one by one, if errors occur then an upload will be stopped and the next upload will then proceed -if(Locals){ - UploadedToSites .= "Locals," - gosub, LocalsUpload -} +if(Facebook) + gosub, FacebookUpload -if(BitChute){ - UploadedToSites .= "Bitchute," - Gosub, BitChuteUpload -} + */ +/* +*/ + +if(Telegram) +gosub, TelegramVideoUpload + +if(Locals) +gosub, LocalsUpload + + +if(BitChute) +Gosub, BitChuteUpload if(OdyseeVideo){ - UploadedToSites .= "LBRYVideo," LBRYUploadType := "Video" Gosub, LBRYVideoUpload } + if(OdyseeAudio){ - UploadedToSites .= "LBRYAudio," LBRYUploadType := "Audio" Gosub, LBRYAudioUpload } -if(Rumble){ - UploadedToSites .= "Rumble," - Gosub, RumbleUpload -} +if(Rumble) +Gosub, RumbleUpload -if(Brighteon){ - UploadedToSites .= "Brighteon," - Gosub, BrighteonUpload -} -if(DailyMotion){ - UploadedToSites .= "DailyMotion," - Gosub, DailyMotionUpload +if(Brighteon) +Gosub, BrighteonUpload + + +if(DailyMotion) +Gosub, DailyMotionUpload + -} ; grab the LBRY Video/Audio URLs if(OdyseeVideo){ @@ -1283,77 +1262,25 @@ if(OdyseeAudio){ Gosub, LBRYGetURL } -/* if(OdyseeVideoThumb){ - OdyseeUploadType := "Video" - Gosub, OdyseeVideoThumbUpload - } - - */ -/* if(OdyseeAudioThumb){ - OdyseeUploadType := "Audio" - Gosub, OdyseeAudioThumbUpload - } - */ - - if(LocalsGrabURL OR LocalsURL = "LocalsUploadStartedNeedToGrabURL"){ - Gosub, LocalsGrabURL - } - - - if(URLOfLastErrorPage != ""){ - Message = Activating Tab of last failed post. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - - ; @todo: replaceme with working funciton to activate tab - ; FindAndActivateTab(URLOfLastErrorPage) - } +if(LocalsGrabURL OR LocalsURL = "LocalsUploadStartedNeedToGrabURL"){ + Gosub, LocalsGrabURL +} - CurrentSite := "" - ; if(StreamanityURL AND StreamanityCheckStatus) +if(URLOfLastErrorPage != ""){ + Message = Activating Tab of last failed post. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - ; this feels soooooooooooooo ineficient, but i'm not sure how else to do this - ; if(StreamanityCheckStatus AND !InStr(StreamanityURL, "streamanity")) ; if checked and URL is blank, report error - ; Status := "Failures" -/* -if(URLOfLastErrorPage){ - Status := "Failures" -} -else, { - Status := "Success" + ; @todo: replaceme with working funciton to activate tab + ; FindAndActivateTab(URLOfLastErrorPage) } - - - if(OdyseeVideoCheckStatus and !InStr(OdyseeVideoURL, "odysee")) - Status := "Failures" - else if(OdyseeAudioCheckStatus AND !InStr(OdyseeAudioURL, "odysee")) - Status := "Failures" - else if(BitChuteCheckStatus AND !InStr(BitChuteURL, "bitchute")) - Status := "Failures" - else if(RumbleCheckStatus AND !InStr(RumbleURL, "rumble")) - Status := "Failures" - else if(DailyMotionCheckStatus AND !InStr(DailyMotionURL, "dailymotion")) - Status := "Failures" - else if(BrighteonCheckStatus AND !InStr(BrighteonURL, "brighteon")) - Status := "Failures" - - */ - ; DevModeMsgBox(status) - ; Msgbox % "status: " status - - if(URLOfLastErrorPage) - Message = Video Uploading Finished WITH Some Failures - else, - Message = All Videos Uploaded Successfully +CurrentSite := "" -/* -if(StreamanityURL != "" AND OdyseeVideoURL != "" AND OdyseeAudioURL != "" and BitChuteURL != "" AND RumbleURL != "" and DailyMotionURL != "" and BrighteonURL != "") -Message = All Videos Uploaded Successfully -else, +if(URLOfLastErrorPage) Message = Video Uploading Finished WITH Some Failures - -*/ +else, +Message = All Videos Uploaded Successfully if(PingOnCompletion) @@ -1526,7 +1453,11 @@ SaveCurrentChromeVersionToIniFile() Return OpenLBRYBlobFilesFolder: +try, run, C:\Users\%A_UserName%\AppData\Local\lbry\lbrynet\blobfiles +catch e { + msgbox, Unable to open lbrynet blobfiles folder. `nIs LBRY installed? +} Return StartSocialMediaPoster: @@ -1539,7 +1470,7 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){ OnMessage(0x44, "") IfMsgBox OK, { - FileSelectFile, SocialMediaPosterFilepath,,, Please Select Social Media Poster + FileSelectFile, SocialMediaPosterFilepath,,, Please Select Social Media Poster Filepath if(ErrorLevel) Return @@ -1560,65 +1491,67 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){ run, %SocialMediaPosterFilepath% "%VideoLinksIniFile%" Return +/* +Indent Reset +*/ - - ; -------------------------------CopyThis------------------------------- - CopyPodcastNumber: - Clipboard := PodcastNumber - SaveOrPostProgress(Message:=PodcastNumber "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 1000 - ToolTip - Return +; -------------------------------CopyThis------------------------------- +CopyPodcastNumber: +Clipboard := PodcastNumber +SaveOrPostProgress(Message:=PodcastNumber "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 1000 +ToolTip +Return - CopyVideoTitle: - Clipboard := VideoTitle - SaveOrPostProgress(Message:=VideoTitle "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 1000 - ToolTip - Return +CopyVideoTitle: +Clipboard := VideoTitle +SaveOrPostProgress(Message:=VideoTitle "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 1000 +ToolTip +Return - CopyBitChuteURL: - Clipboard := BitChuteURL - SaveOrPostProgress(Message:=BitChuteURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 1000 - ToolTip - Return +CopyBitChuteURL: +Clipboard := BitChuteURL +SaveOrPostProgress(Message:=BitChuteURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 1000 +ToolTip +Return - CopyBrighteonURL: - Clipboard := BrighteonURL - SaveOrPostProgress(Message:=BrighteonURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 1000 - ToolTip - Return +CopyBrighteonURL: +Clipboard := BrighteonURL +SaveOrPostProgress(Message:=BrighteonURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 1000 +ToolTip +Return - CopyDailyMotionURL: - Clipboard := DailyMotionURL - SaveOrPostProgress(Message:=DailyMotionURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 1000 - ToolTip - Return +CopyDailyMotionURL: +Clipboard := DailyMotionURL +SaveOrPostProgress(Message:=DailyMotionURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 1000 +ToolTip +Return - CopyOdyseeVideoURL: - Clipboard := OdyseeVideoURL - SaveOrPostProgress(Message:=OdyseeVideoURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 1000 - ToolTip - Return +CopyOdyseeVideoURL: +Clipboard := OdyseeVideoURL +SaveOrPostProgress(Message:=OdyseeVideoURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 1000 +ToolTip +Return - CopyOdyseeAudioURL: - Clipboard := OdyseeAudioURL - SaveOrPostProgress(Message:=OdyseeAudioURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 1000 - ToolTip - Return +CopyOdyseeAudioURL: +Clipboard := OdyseeAudioURL +SaveOrPostProgress(Message:=OdyseeAudioURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 1000 +ToolTip +Return - CopyRumbleURL: - Clipboard := RumbleURL - SaveOrPostProgress(Message:=RumbleURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 1000 - ToolTip - Return +CopyRumbleURL: +Clipboard := RumbleURL +SaveOrPostProgress(Message:=RumbleURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 1000 +ToolTip +Return /*CopyStreamanityURL: Clipboard := StreamanityURL @@ -1654,28 +1587,22 @@ Return UpdateINI: IniWrite, %PodcastNumber%, %VideoLinksIniFile%, URLs, PodcastNumber IniWrite, %VideoTitle%, %VideoLinksIniFile%, Misc, VideoTitle +IniWrite, %LocalsURL%, %VideoLinksIniFile%, URLs, LocalsURL +IniWrite, %RumbleURL%, %VideoLinksIniFile%, URLs, RumbleURL +IniWrite, %DailyMotionURL%, %VideoLinksIniFile%, URLs, DailyMotionURL +IniWrite, %BrighteonURL%, %VideoLinksIniFile%, URLs, BrighteonURL +IniWrite, %BitChuteURL%, %VideoLinksIniFile%, URLs, BitChuteURL +; LBRY/Odysee: IniWrite, %LBRYVideoURL%, %VideoLinksIniFile%, URLs, LBRYVideoURL IniWrite, %LBRYAudioURL%, %VideoLinksIniFile%, URLs, LBRYAudioURL - IniWrite, %OdyseeVideoURL%, %VideoLinksIniFile%, URLs, OdyseeVideoURL - OdyseeVideoThumb := StrReplace(OdyseeVideoThumb, "Thumb:", "") IniWrite, %OdyseeVideoThumb%, %VideoLinksIniFile%, Misc, OdyseeVideoThumb - IniWrite, %OdyseeAudioURL%, %VideoLinksIniFile%, URLs, OdyseeAudioURL OdyseeAudioThumb := StrReplace(OdyseeAudioThumb, "Thumb:", "") IniWrite, %OdyseeAudioThumb%, %VideoLinksIniFile%, Misc, OdyseeAudioThumb -IniWrite, %LocalsURL%, %VideoLinksIniFile%, URLs, LocalsURL - -IniWrite, %RumbleURL%, %VideoLinksIniFile%, URLs, RumbleURL -; IniWrite, %StreamanityURL%, %VideoLinksIniFile%, URLs, StreamanityURL -IniWrite, %DailyMotionURL%, %VideoLinksIniFile%, URLs, DailyMotionURL -IniWrite, %BrighteonURL%, %VideoLinksIniFile%, URLs, BrighteonURL -IniWrite, %BitChuteURL%, %VideoLinksIniFile%, URLs, BitChuteURL - - if(VideoDescription != OriginalVideoDescription){ VideoBodyFilepath = %VideoFolderDir%\body.txt @@ -1731,109 +1658,29 @@ if(InStr(Status, "error_code")){ Message = Telegram Error: %Status% SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - ; msgbox, 4096, Error!, %Message% ToolTip Return } -ToolTip + Message = ErrorLog was successfully uploaded to the FDRBotTesting Telegram Server.`nThank You! SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") sleep, 5000 ToolTip -; msgbox, 4096, Success!, %Message% -; Clipboard := ErrorLoggingFilePath -; Message = %ErrorLoggingFilePath% `n`nwas copied to the clipboard for easy attachment -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -; msgbox, 4096, Filepath Copied to Clipboard, %ErrorLoggingFilePath%`n`nwas copied to the clipboard for easy attachment. Return - - -;--------------------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 - - ; Post-To-Telegram ;------------------------------------------------ #Include %A_ScriptDir%\Modules\Post-To-Telegram.ahk +; Post-Video-To-Telegram +;------------------------------------------------ +#Include %A_ScriptDir%\Modules\Post-Video-To-Telegram.ahk + + ; Post-To-Discord ;------------------------------------------------ #Include %A_ScriptDir%\Modules\Post-To-Discord.ahk diff --git a/Modules/Post-Video-To-Telegram.ahk b/Modules/Post-Video-To-Telegram.ahk new file mode 100644 index 0000000..8a4f48e --- /dev/null +++ b/Modules/Post-Video-To-Telegram.ahk @@ -0,0 +1,76 @@ + +;--------------------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 \ No newline at end of file