@ -1,6 +1,14 @@
PostToTelegram:
PostToTelegram:
;------------------------------------------------
;------------------------------------------------
CurrentSocialMediaPosting := "Telegram"
CurrentSite := "Telegram"
if(!FileExist(VideoThumbFilepath)){
Message = Post Aborted.`nVideo Thumbnail not found at:`n%VideoThumbFilepath%
SaveOrPostProgress(Message,PostType:="ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
MsgBox 0x10,, %Message%
Return
}
Message = Posting Video Links to Telegram
Message = Posting Video Links to Telegram
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
@ -15,62 +23,46 @@ if(TelegramBotToken = "" Or TelegramBotChatID =""){
Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and click the button again.
Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and click the button again.
msgbox, 4096, Error!, %Message%
msgbox, 4096, Error!, %Message%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
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
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 AND VideoDescriptionForVideosChannel = ""){
goto, CreateDescriptionForVideosPosting
}
*/
/*
if(SocialMediaDescription = ""){
CreateDescriptionForSocialMedia()
}
if(SocialMediaDescription > 1000){ ; Telegram has a 1024 char media caption capacity
SocialMediaDescription := SubStr(SocialMediaDescription, 1, 500)
}
*/
; @todo: split telegram message into multiple posts
SubmitDescriptionForTelegramVideosChannel:
TelegramVideoTitle := ASCIISTRReplace(VideoTitle)
TelegramVideoTitle := ASCIISTRReplace(VideoTitle)
TelegramVideoTitle := "*" . TelegramVideoTitle . "*"
TelegramVideoTitle := "*" . TelegramVideoTitle . "*"
TelegramBodymessage := ASCIISTRReplace(VideoDescription)
TelegramBodymessage := ASCIISTRReplace(VideoDescription)
; Variables
LineBreakChar = `%0A ; Used for API
LineBreakChar = `%0A ; Used for API
VideoLinks :=
; Create the Hyperlinks for each Platform
; ------------------------------------------------
; check the status of the Bitchute URL to see if it's done processing
; check the status of the Bitchute URL to see if it's done processing
; shows "404 - Page not found" on page if not
; shows "404 - Page not found" on page if not
if(BitChuteURL){
if(BitChuteURL){
if(!InStr(URLDownloadToVar(BitChuteURL), "404 - Page not found")){
if(!InStr(URLDownloadToVar(BitChuteURL), "404 - Page not found")){
if(BitChuteURL != "")
if(BitChuteURL != "")
VideoLinks .= "[BitChute](" . BitChuteURL . ") \| "
VideoLinks .= "[BitChute](" . BitChuteURL . ") \| "
}
}
else, {
else, {
LogMessage = Bitchute URL skipped, URL Currently leads to: 404 - page not found
LogMessage = Bitchute URL skipped, URL Currently leads to: 404 - page not found
SaveOrPostProgress(Message:=LogMessage,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveOrPostProgress(Message:=LogMessage,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
}
}
; check the status of the Brighteon URL to see if it's done processing
; check the status of the Brighteon URL to see if it's done processing
; shows "404 - Page not found" on page if not
; shows "404 - Page not found" on page if not
if(BrighteonURL){
if(BrighteonURL){
if(!InStr(URLDownloadToVar(BrighteonURL), "SELECTED IS NOT CURRENTLY AVAILABLE")){
if(!InStr(URLDownloadToVar(BrighteonURL), "SELECTED IS NOT CURRENTLY AVAILABLE")){
if(BrighteonURL != "")
if(BrighteonURL != "")
VideoLinks .= "[Brighteon](" . BrighteonURL . ") \| "
VideoLinks .= "[Brighteon](" . BrighteonURL . ") \| "
}
}
else, {
else, {
LogMessage = Brighteon URL skipped, URL Currently leads to: 404 - page not found
LogMessage = Brighteon URL skipped, URL Currently leads to: 404 - page not found
SaveOrPostProgress(Message:=LogMessage,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveOrPostProgress(Message:=LogMessage,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
}
}
}
if(OdyseeVideoURL != "")
if(OdyseeVideoURL != "")
@ -85,10 +77,6 @@ VideoLinks .= "[Rumble](" . RumbleURL . ") \| "
if(DailyMotionURL != "")
if(DailyMotionURL != "")
VideoLinks .= "[DailyMotion](" . DailyMotionURL . ") \| "
VideoLinks .= "[DailyMotion](" . DailyMotionURL . ") \| "
/*if(PodcastTranscriptURL != "")
VideoLinks .= "[Video Transcript](" . PodcastTranscriptURL . ") \| "
*/
if(PodcastNumber != "")
if(PodcastNumber != "")
VideoLinks .= "[FDRPodcasts](" . "https://fdrpodcasts.com/" . PodcastNumber . ") \| "
VideoLinks .= "[FDRPodcasts](" . "https://fdrpodcasts.com/" . PodcastNumber . ") \| "
@ -96,94 +84,92 @@ VideoLinks .= "[FDRPodcasts](" . "https://fdrpodcasts.com/" . PodcastNumber . ")
TelegramMessage := TelegramVideoTitle . "`n" . TelegramBodymessage . "`n" . VideoLinks
TelegramMessage := TelegramVideoTitle . "`n" . TelegramBodymessage . "`n" . VideoLinks
StrLenOfMessageAndVideoLinks := StrLen(TelegramVideoTitle) + StrLen(TelegramBodymessage) + StrLen(VideoLinks)
StrLenOfMessageAndVideoLinks := StrLen(TelegramVideoTitle) + StrLen(TelegramBodymessage) + StrLen(VideoLinks)
; DevModeMsgBox(StrLenOfMessageAndVideoLinks)
; If Length of Title, Video Links and Message is less than 1024 characters:
; If Length of Title, Video Links and Message is less than 1024 characters:
; ------------------------------------------------
; ------------------------------------------------
if(StrLenOfMessageAndVideoLinks < 1024) {
if(StrLenOfMessageAndVideoLinks < 1024) {
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramMessage ) ; you could add more options; compare the Telegram API docs
Message = Sending Post as One Message
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Output returned data to ErrorLog File
Message = API Response:`n%Status%
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramMessage ) ; you could add more options; compare the Telegram API docs
if(InStr(Status, "error_code")){
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.
Message = Telegram Post Failed Due To An Api Issue. Please See Errorlog For More Info.
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")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
ToolTip
Return
}
}
Message = API Response:`n%Status% ; Output returned data to ErrorLog File
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
}
}
; If Title, Links and Message are longer than 1024, but less than 4096, split into 2 pieces: sendphoto and sendmessage
; If Title, Links and Message are longer than 1024, but less than 4096, split into 2 pieces: sendphoto and sendmessage
; ------------------------------------------------
; ------------------------------------------------
if(StrLenOfMessageAndVideoLinks < 4096){
if(StrLenOfMessageAndVideoLinks < 4096){
Message = Sending Post as Two Messages
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Photo and Video Title go into SendPhoto
; Photo and Video Title go into SendPhoto
TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks
TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs
; Output returned data to ErrorLog File
if(InStr(Status, "error_code")){
Message = API Response:`n%Status%
Message = Telegram Post Failed Due To An Api Issue. Please See Errorlog For More Info.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
Message = API Response:`n%Status% ; Output returned data to ErrorLog File
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
; Video Description goes into TelegramMessage
; Video Description goes into TelegramMessage
Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessage)
Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessage)
; Output returned data to ErrorLog File
if(InStr(Status, "error_code")){
Message = API Response:`n%Status%
Message = Telegram Post Failed Due To An Api Issue. Please See Errorlog For More Info.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
Message = API Response:`n%Status% ; Output returned data to ErrorLog File
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
}
else, {
; If Title, links and message are longer than 4096 chars, we need to split them into multiple messages
; ------------------------------------------------
Message = Sending Post as Multiple Messages
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile")
} else, {
TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks
; If Title, links and message are longer than 4096 chars, we need to split them into multiple messages
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs
; ------------------------------------------------
if(InStr(Status, "error_code")){
TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks
Message = Telegram Post Failed Due To An Api Issue. Please See Errorlog For More Info.
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
Message = API Response:`n%Status% ; Output returned data to ErrorLog File
; Split the Description into 4096 character chunks while preserving sentences
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
; Used 4095 because a ". " has to be put in at the end of the chunk.
VideoDescriptionChunks := SplitStringWithSentences(TelegramBodymessage, 4094)
; go through array and post each chunk as new message
; Split the Description into 4096 character chunks while preserving sentences
Loop % VideoDescriptionChunks.Length(){
; Used 4095 because a ". " has to be put in at the end of the chunk.
; ArrayItem := ARRAY[A_Index]
VideoDescriptionChunks := SplitStringWithSentences(TelegramBodymessage, 4094)
Description := VideoDescriptionChunks[A_Index]
Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Description)
; go through array and post each chunk as new message
; Output returned data to ErrorLog File
Loop % VideoDescriptionChunks.Length(){
Message = API Response:`n%Status%
; ArrayItem := ARRAY[A_Index]
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
Description := VideoDescriptionChunks[A_Index]
; Clipboard := Description
; msgbox % Description
Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Description)
if(InStr(Status, "error_code")){
Message = Telegram Post Failed Due To An Api Issue. Please See Errorlog For More Info.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
}
Message = API Response:`n%Status% ; Output returned data to ErrorLog File
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile")
}
}
}
; SaveOrPostProgress(Message:="Video Links posted to #Videos Successfully.",PostType:="Tooltip,ErrorLoggingTextFile")
Message = Video Links Posted to Telegram Successfully
Message = Video Links Posted to Telegram Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
GuiControl,, PostToDiscordTelegramButton, Telegram - Posted Successfully
GuiControl,, PostToTelegramButton, Telegram - Posted Successfully
; sleep, 2000
ToolTip
ToolTip
CurrentSite :=
CurrentSite :=
Return
Return
; -------------------------------/Telegram-------------------------------
; -------------------------------/Telegram-------------------------------