@ -56,24 +56,19 @@ VideoLinks .= "[Odysee](" . OdyseeVideoURL . ") \| "
if(OdyseeAudioURL != "")
VideoLinks .= "[Odysee \(Audio\)](" . OdyseeAudioURL . ") \| "
/*
if(OdyseeVideoURL != "")
VideoLinks .= "[Odysee](" . OdyseeVideoURL . ") \| "
if(OdyseeAudioURL != "")
VideoLinks .= "[Odysee Audio](" . OdyseeAudioURL . ") \| "
*/
if(RumbleURL != "")
VideoLinks .= "[Rumble](" . RumbleURL . ") \| "
/*
if(InStr(StreamanityURL, "https://streamanity.com/video/"))
VideoLinks .= "[Streamanity](" . StreamanityURL . ") \| "
*/
if(DailyMotionURL != "")
VideoLinks .= "[DailyMotion](" . DailyMotionURL . ") \| "
if(PodcastTranscriptURL != "")
VideoLinks .= "[Video Transcript](" . PodcastTranscriptURL . ") \| "
if(PodcastNumber != "")
VideoLinks .= "[FDRPodcasts](" . "https://fdrpodcasts.com/" . PodcastNumber . ") \| "
TelegramMessage := TelegramVideoTitle . "`n" . TelegramBodymessage . "`n" . VideoLinks
@ -83,10 +78,28 @@ StrLenOfMessageAndVideoLinks := StrLen(TelegramVideoTitle) + StrLen(TelegramBody
; DevModeMsgBox(StrLenOfMessageAndVideoLinks)
if(StrLenOfMessageAndVideoLinks > 1024){
; Telegram SendMessage is limited to 4096 characters
if(StrLenOfMessageAndVideoLinks < 4096){ ; split into sendphoto and 1 sendmessage
; DevModeMsgBox("Less than 4096 chars")
; If Length of Title, Video Links and Message is less than 1024 characters:
; ------------------------------------------------
if(StrLenOfMessageAndVideoLinks < 1024) {
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramMessage ) ; 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
}
}
; If Title, Links and Message are longer than 1024, but less than 4096, split into 2 pieces: sendphoto and sendmessage
; ------------------------------------------------
if(StrLenOfMessageAndVideoLinks < 4096){
; Photo and Video Title go into SendPhoto
TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs
@ -94,64 +107,33 @@ if(StrLenOfMessageAndVideoLinks > 1024){
; Video Description goes into TelegramMessage
Status2 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessage)
} ; split into 2 SendMessages
else if (StrLenOfMessageAndVideoLinks > 4096 AND StrLenOfMessageAndVideoLinks < 8192){ ; Split into 2 parts
} else, {
; If Title, links and message are longer than 4096 chars, we need to split them into multiple messages
; ------------------------------------------------
TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs
TelegramBodymessagePiece := SubStr(TelegramBodymessage, 1, 4096)
Status2 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece)
TelegramBodymessagePiece := SubStr(TelegramBodymessage, 4097, 8192)
Status3 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece)
} ; split into 3 sendMessages
else if (StrLenOfMessageAndVideoLinks > 8192 AND StrLenOfMessageAndVideoLinks < 12288){ ; Split into 3 parts
TelegramVideoTitle := TelegramVideoTitle . "`n" . VideoLinks
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramVideoTitle ) ; you could add more options; compare the Telegram API docs
; Split the Description into 4096 character chunks while preserving sentences
; Used 4095 because a ". " has to be put in at the end of the chunk.
VideoDescriptionChunks := SplitStringWithSentences(TelegramBodymessage, 4094)
TelegramBodymessagePiece := SubStr(TelegramBodymessage, 1, 4096)
msgbox % StrLen(TelegramBodymessagePiece)
Status2 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece)
; go through array and post each chunk as new message
Loop % VideoDescriptionChunks.Length(){
; ArrayItem := ARRAY[A_Index]
Description := VideoDescriptionChunks[A_Index]
TelegramBodymessagePiece := SubStr(TelegramBodymessage, 4097, 8192)
msgbox % StrLen(TelegramBodymessagePiece)
DevModeMsgBox(TelegramBodymessagePiece)
Status3 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece)
SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Description)
; Clipboard := Description
; msgbox % Description
; TelegramBodymessagePiece := SubStr(TelegramBodymessage, 8193, 12288)
; Status3 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece)
}
} else, { ; if less than 1024 characters, send normally
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, VideoThumbFilepath, caption := TelegramMessage ) ; 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 % "SizeOfCaption: " SizeOfCaption
; SizeOfCaption := SizeOfCaption +
; Message .= VideoLinks
; msgbox % StrLen(VideoLinks)
; Message := StrReplace(Message, "`n", LineBreakChar) ; replace all new line characters with the global charater
; msgbox % StrLen(Message)
; SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordVideos")
; SaveOrPostProgress(Message:="Video Links posted to #Videos Successfully.",PostType:="Tooltip,ErrorLoggingTextFile")
Message = Video Links Posted to Telegram Successfully