code cleanup, removed unused code, added ability to save x and y position of GUI between runs

pull/2/head
Yuriy 1 year ago
parent 534df945eb
commit e10fd869a4

@ -35,7 +35,7 @@ ScriptVersion = 3.20
FullScriptName := ScriptName . " - " . ScriptVersion 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? ; 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 #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\General-Functions.ahk
@ -149,6 +149,8 @@ IniRead, ShowTooltipProgress, %SettingsIniFilepath%, General, ShowTooltipProgres
; ToolTip, reading settings ; ToolTip, reading settings
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip") ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
IniRead, XPosition, %SettingsIniFilepath%, General, XPosition
IniRead, YPosition, %SettingsIniFilepath%, General, YPosition
IniRead, RootDirToStartIn, %SettingsIniFilepath%, General, RootDirToStartIn IniRead, RootDirToStartIn, %SettingsIniFilepath%, General, RootDirToStartIn
@ -817,7 +819,12 @@ Gui, Add, StatusBar,Center, Total Videos Uploaded: %TotalVideosUploaded%
; Show GUI to the user ; Show GUI to the user
Gui, +Resize +MaximizeBox Gui, +Resize +MaximizeBox
if(XPosition and YPosition)
Gui, Show, x%XPosition% y%YPosition%, %FullScriptName% - Upload Settings - %BodyTextFilePath%
else,
Gui, Show,, %FullScriptName% - Upload Settings - %BodyTextFilePath% Gui, Show,, %FullScriptName% - Upload Settings - %BodyTextFilePath%
ControlFocus, Edit1, %FullScriptName% ControlFocus, Edit1, %FullScriptName%
ToolTip ToolTip
@ -833,12 +840,10 @@ if(SkipToDBInfo){
; Write current project to ini file for easy reloading ; Write current project to ini file for easy reloading
IniWrite, %BodyTextFilePath%, %SettingsIniFilepath%, %ScriptSettingsSection%, LastPost 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 ; msgbox, checking for updates
if(AutoUpdateCheck AND !UpdateAvailable){ if(AutoUpdateCheck AND !UpdateAvailable){
@ -850,43 +855,20 @@ if(AutoUpdateCheck AND !UpdateAvailable){
; UpdateAvailable := ; UpdateAvailable :=
if(CheckForUpdates(GitReleasesAPIURL)) if(CheckForUpdates(GitReleasesAPIURL))
GuiControl ,, UpdateAvailable, Uploader Update Available GuiControl,,UpdateAvailable, Uploader Update Available
if(CheckForChromeUpdates(ChromeFilepath)) if(CheckForChromeUpdates(ChromeFilepath))
GuiControl ,, ChromeUpdateAvailable, Chrome Update Available 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
}
*/ ; calculate run time and convert to seconds
URunTime2 := round(((A_TickCount - UStartTime) / 1000), 2)
; DevModeMsgBox(AutoUpdateCheck)
; DevModeMsgBox(UpdateAvailable)
; Msgbox % "URunTime1: " URunTime1
; Msgbox % "URunTime2: " URunTime2
; Msgbox % "URunTime: " URunTime
Return Return
@ -1027,8 +1009,10 @@ if(CurrentSocialMediaPosting = "Discord")
Goto, SubmitDescriptionForDiscordVideosChannel Goto, SubmitDescriptionForDiscordVideosChannel
if(CurrentSocialMediaPosting = "Telegram") if(CurrentSocialMediaPosting = "Telegram")
Goto, SubmitDescriptionForTelegramVideosChannel Goto, SubmitDescriptionForTelegramVideosChannel
if(CurrentSocialMediaPosting = "Telegram Video") if(CurrentSocialMediaPosting = "Telegram Video")
goto, SubmitDescriptionForTelegramVideoUpload goto, SubmitDescriptionForTelegramVideoUpload
Return Return
@ -1049,6 +1033,9 @@ CreateDescriptionForSocialMedia(){
; -------------------------------Upload Video Functionality------------------------------- ; -------------------------------Upload Video Functionality-------------------------------
StartScript: StartScript:
WinGetPos, XPosition, YPosition, , , A WinGetPos, XPosition, YPosition, , , A
IniWrite, %XPosition%, %SettingsIniFilepath%, General, XPosition
IniWrite, %YPosition%, %SettingsIniFilepath%, General, YPosition
; Msgbox % "XPosition: " XPosition ; Msgbox % "XPosition: " XPosition
; Msgbox % "YPosition: " YPosition ; Msgbox % "YPosition: " YPosition
Gui, Submit Gui, Submit
@ -1160,7 +1147,6 @@ if(LBRYURLSlug = "") ; if slug spot is blank, then set it to video title
LBRYURLSlug := VideoTitle LBRYURLSlug := VideoTitle
LBRYURLSlug := LBRYCMDTextReplacement(LBRYURLSlug) LBRYURLSlug := LBRYCMDTextReplacement(LBRYURLSlug)
; Msgbox % "LBRYURLSlug: " LBRYURLSlug
; Save the LBRY URL Slug to .ini file in case it's needed later ; Save the LBRY URL Slug to .ini file in case it's needed later
IniWrite, %LBRYURLSlug%, %VideoLinksIniFile%, Misc, LBRYUrlSlug IniWrite, %LBRYURLSlug%, %VideoLinksIniFile%, Misc, LBRYUrlSlug
IniWrite, %VideoThumbFilepath%, %VideoLinksIniFile%, Misc, VideoThumbFilepath IniWrite, %VideoThumbFilepath%, %VideoLinksIniFile%, Misc, VideoThumbFilepath
@ -1208,9 +1194,6 @@ SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
JSVideoDescription := FormatTextToJSText(VideoDescription) JSVideoDescription := FormatTextToJSText(VideoDescription)
JSVideoTitle := FormatTextToJSText(VideoTitle) JSVideoTitle := FormatTextToJSText(VideoTitle)
; Save json description to errorlogging file
; Message = JSVideoDescription: `n" %JSVideoDescription%
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
; -------------------------------/Log Info To Text------------------------------- ; -------------------------------/Log Info To Text-------------------------------
@ -1224,54 +1207,50 @@ VideoTags := StrReplace(VideoTags, " ",",")
KeywordsArray := StrSplit(VideoTags,",") KeywordsArray := StrSplit(VideoTags,",")
if(Facebook){ ; Call each sub one by one, if errors occur then an upload will be stopped and the next upload will then proceed
UploadedToSites .= "Facebook,"
; gosub, FacebookUpload
}
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(Facebook)
if(Locals){ gosub, FacebookUpload
UploadedToSites .= "Locals,"
gosub, LocalsUpload
}
if(BitChute){ */
UploadedToSites .= "Bitchute," /*
Gosub, BitChuteUpload */
}
if(Telegram)
gosub, TelegramVideoUpload
if(Locals)
gosub, LocalsUpload
if(BitChute)
Gosub, BitChuteUpload
if(OdyseeVideo){ if(OdyseeVideo){
UploadedToSites .= "LBRYVideo,"
LBRYUploadType := "Video" LBRYUploadType := "Video"
Gosub, LBRYVideoUpload Gosub, LBRYVideoUpload
} }
if(OdyseeAudio){ if(OdyseeAudio){
UploadedToSites .= "LBRYAudio,"
LBRYUploadType := "Audio" LBRYUploadType := "Audio"
Gosub, LBRYAudioUpload Gosub, LBRYAudioUpload
} }
if(Rumble){ if(Rumble)
UploadedToSites .= "Rumble," Gosub, RumbleUpload
Gosub, RumbleUpload
}
if(Brighteon){
UploadedToSites .= "Brighteon,"
Gosub, BrighteonUpload
}
if(DailyMotion){ if(Brighteon)
UploadedToSites .= "DailyMotion," Gosub, BrighteonUpload
Gosub, DailyMotionUpload
if(DailyMotion)
Gosub, DailyMotionUpload
}
; grab the LBRY Video/Audio URLs ; grab the LBRY Video/Audio URLs
if(OdyseeVideo){ if(OdyseeVideo){
@ -1283,77 +1262,25 @@ if(OdyseeAudio){
Gosub, LBRYGetURL Gosub, LBRYGetURL
} }
/* if(OdyseeVideoThumb){ if(LocalsGrabURL OR LocalsURL = "LocalsUploadStartedNeedToGrabURL"){
OdyseeUploadType := "Video"
Gosub, OdyseeVideoThumbUpload
}
*/
/* if(OdyseeAudioThumb){
OdyseeUploadType := "Audio"
Gosub, OdyseeAudioThumbUpload
}
*/
if(LocalsGrabURL OR LocalsURL = "LocalsUploadStartedNeedToGrabURL"){
Gosub, LocalsGrabURL Gosub, LocalsGrabURL
} }
if(URLOfLastErrorPage != ""){ if(URLOfLastErrorPage != ""){
Message = Activating Tab of last failed post. Message = Activating Tab of last failed post.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip") SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
; @todo: replaceme with working funciton to activate tab ; @todo: replaceme with working funciton to activate tab
; FindAndActivateTab(URLOfLastErrorPage) ; FindAndActivateTab(URLOfLastErrorPage)
}
CurrentSite := ""
; if(StreamanityURL AND StreamanityCheckStatus)
; 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"
} }
CurrentSite := ""
if(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
/*
if(StreamanityURL != "" AND OdyseeVideoURL != "" AND OdyseeAudioURL != "" and BitChuteURL != "" AND RumbleURL != "" and DailyMotionURL != "" and BrighteonURL != "")
Message = All Videos Uploaded Successfully
else,
Message = Video Uploading Finished WITH Some Failures Message = Video Uploading Finished WITH Some Failures
else,
*/ Message = All Videos Uploaded Successfully
if(PingOnCompletion) if(PingOnCompletion)
@ -1526,7 +1453,11 @@ SaveCurrentChromeVersionToIniFile()
Return Return
OpenLBRYBlobFilesFolder: OpenLBRYBlobFilesFolder:
try,
run, C:\Users\%A_UserName%\AppData\Local\lbry\lbrynet\blobfiles run, C:\Users\%A_UserName%\AppData\Local\lbry\lbrynet\blobfiles
catch e {
msgbox, Unable to open lbrynet blobfiles folder. `nIs LBRY installed?
}
Return Return
StartSocialMediaPoster: StartSocialMediaPoster:
@ -1539,7 +1470,7 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){
OnMessage(0x44, "") OnMessage(0x44, "")
IfMsgBox OK, { IfMsgBox OK, {
FileSelectFile, SocialMediaPosterFilepath,,, Please Select Social Media Poster FileSelectFile, SocialMediaPosterFilepath,,, Please Select Social Media Poster Filepath
if(ErrorLevel) if(ErrorLevel)
Return Return
@ -1560,65 +1491,67 @@ if(SocialMediaPosterFilepath = "" or !FileExist(SocialMediaPosterFilepath)){
run, %SocialMediaPosterFilepath% "%VideoLinksIniFile%" run, %SocialMediaPosterFilepath% "%VideoLinksIniFile%"
Return Return
/*
Indent Reset
*/
; -------------------------------CopyThis-------------------------------
; -------------------------------CopyThis------------------------------- CopyPodcastNumber:
CopyPodcastNumber: Clipboard := PodcastNumber
Clipboard := PodcastNumber SaveOrPostProgress(Message:=PodcastNumber "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:=PodcastNumber "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") sleep, 1000
sleep, 1000 ToolTip
ToolTip Return
Return
CopyVideoTitle: CopyVideoTitle:
Clipboard := VideoTitle Clipboard := VideoTitle
SaveOrPostProgress(Message:=VideoTitle "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=VideoTitle "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 1000 sleep, 1000
ToolTip ToolTip
Return Return
CopyBitChuteURL: CopyBitChuteURL:
Clipboard := BitChuteURL Clipboard := BitChuteURL
SaveOrPostProgress(Message:=BitChuteURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=BitChuteURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 1000 sleep, 1000
ToolTip ToolTip
Return Return
CopyBrighteonURL: CopyBrighteonURL:
Clipboard := BrighteonURL Clipboard := BrighteonURL
SaveOrPostProgress(Message:=BrighteonURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=BrighteonURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 1000 sleep, 1000
ToolTip ToolTip
Return Return
CopyDailyMotionURL: CopyDailyMotionURL:
Clipboard := DailyMotionURL Clipboard := DailyMotionURL
SaveOrPostProgress(Message:=DailyMotionURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=DailyMotionURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 1000 sleep, 1000
ToolTip ToolTip
Return Return
CopyOdyseeVideoURL: CopyOdyseeVideoURL:
Clipboard := OdyseeVideoURL Clipboard := OdyseeVideoURL
SaveOrPostProgress(Message:=OdyseeVideoURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=OdyseeVideoURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 1000 sleep, 1000
ToolTip ToolTip
Return Return
CopyOdyseeAudioURL: CopyOdyseeAudioURL:
Clipboard := OdyseeAudioURL Clipboard := OdyseeAudioURL
SaveOrPostProgress(Message:=OdyseeAudioURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=OdyseeAudioURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 1000 sleep, 1000
ToolTip ToolTip
Return Return
CopyRumbleURL: CopyRumbleURL:
Clipboard := RumbleURL Clipboard := RumbleURL
SaveOrPostProgress(Message:=RumbleURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:=RumbleURL "`nCopied to Clipboard",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 1000 sleep, 1000
ToolTip ToolTip
Return Return
/*CopyStreamanityURL: /*CopyStreamanityURL:
Clipboard := StreamanityURL Clipboard := StreamanityURL
@ -1654,28 +1587,22 @@ Return
UpdateINI: UpdateINI:
IniWrite, %PodcastNumber%, %VideoLinksIniFile%, URLs, PodcastNumber IniWrite, %PodcastNumber%, %VideoLinksIniFile%, URLs, PodcastNumber
IniWrite, %VideoTitle%, %VideoLinksIniFile%, Misc, VideoTitle 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, %LBRYVideoURL%, %VideoLinksIniFile%, URLs, LBRYVideoURL
IniWrite, %LBRYAudioURL%, %VideoLinksIniFile%, URLs, LBRYAudioURL IniWrite, %LBRYAudioURL%, %VideoLinksIniFile%, URLs, LBRYAudioURL
IniWrite, %OdyseeVideoURL%, %VideoLinksIniFile%, URLs, OdyseeVideoURL IniWrite, %OdyseeVideoURL%, %VideoLinksIniFile%, URLs, OdyseeVideoURL
OdyseeVideoThumb := StrReplace(OdyseeVideoThumb, "Thumb:", "") OdyseeVideoThumb := StrReplace(OdyseeVideoThumb, "Thumb:", "")
IniWrite, %OdyseeVideoThumb%, %VideoLinksIniFile%, Misc, OdyseeVideoThumb IniWrite, %OdyseeVideoThumb%, %VideoLinksIniFile%, Misc, OdyseeVideoThumb
IniWrite, %OdyseeAudioURL%, %VideoLinksIniFile%, URLs, OdyseeAudioURL IniWrite, %OdyseeAudioURL%, %VideoLinksIniFile%, URLs, OdyseeAudioURL
OdyseeAudioThumb := StrReplace(OdyseeAudioThumb, "Thumb:", "") OdyseeAudioThumb := StrReplace(OdyseeAudioThumb, "Thumb:", "")
IniWrite, %OdyseeAudioThumb%, %VideoLinksIniFile%, Misc, OdyseeAudioThumb 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){ if(VideoDescription != OriginalVideoDescription){
VideoBodyFilepath = %VideoFolderDir%\body.txt VideoBodyFilepath = %VideoFolderDir%\body.txt
@ -1731,100 +1658,15 @@ if(InStr(Status, "error_code")){
Message = Telegram Error: %Status% Message = Telegram Error: %Status%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; msgbox, 4096, Error!, %Message%
ToolTip ToolTip
Return Return
} }
ToolTip
Message = ErrorLog was successfully uploaded to the FDRBotTesting Telegram Server.`nThank You! Message = ErrorLog was successfully uploaded to the FDRBotTesting Telegram Server.`nThank You!
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
sleep, 5000 sleep, 5000
ToolTip 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 Return
@ -1834,6 +1676,11 @@ Return
#Include %A_ScriptDir%\Modules\Post-To-Telegram.ahk #Include %A_ScriptDir%\Modules\Post-To-Telegram.ahk
; Post-Video-To-Telegram
;------------------------------------------------
#Include %A_ScriptDir%\Modules\Post-Video-To-Telegram.ahk
; Post-To-Discord ; Post-To-Discord
;------------------------------------------------ ;------------------------------------------------
#Include %A_ScriptDir%\Modules\Post-To-Discord.ahk #Include %A_ScriptDir%\Modules\Post-To-Discord.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
Loading…
Cancel
Save