PostToTelegram: ;------------------------------------------------ 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 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 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") Return } TelegramVideoTitle := ASCIISTRReplace(VideoTitle) TelegramVideoTitle := "*" . TelegramVideoTitle . "*" TelegramBodymessage := ASCIISTRReplace(VideoDescription) ; Variables 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 ; shows "404 - Page not found" on page if not if(BitChuteURL){ if(!InStr(URLDownloadToVar(BitChuteURL), "404 - Page not found")){ if(BitChuteURL != "") VideoLinks .= "[BitChute](" . BitChuteURL . ") \| " } else, { LogMessage = Bitchute URL skipped, URL Currently leads to: 404 - page not found SaveOrPostProgress(Message:=LogMessage,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") } } ; check the status of the Brighteon URL to see if it's done processing ; shows "404 - Page not found" on page if not if(BrighteonURL){ if(!InStr(URLDownloadToVar(BrighteonURL), "SELECTED IS NOT CURRENTLY AVAILABLE")){ if(BrighteonURL != "") VideoLinks .= "[Brighteon](" . BrighteonURL . ") \| " } else, { LogMessage = Brighteon URL skipped, URL Currently leads to: 404 - page not found SaveOrPostProgress(Message:=LogMessage,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") } } if(OdyseeVideoURL != "") VideoLinks .= "[Odysee](" . OdyseeVideoURL . ") \| " if(OdyseeAudioURL != "") VideoLinks .= "[Odysee \(Audio\)](" . OdyseeAudioURL . ") \| " if(RumbleURL != "") VideoLinks .= "[Rumble](" . RumbleURL . ") \| " if(DailyMotionURL != "") VideoLinks .= "[DailyMotion](" . DailyMotionURL . ") \| " if(PodcastNumber != "") VideoLinks .= "[FDRPodcasts](" . "https://fdrpodcasts.com/" . PodcastNumber . ") \| " TelegramMessage := TelegramVideoTitle . "`n" . TelegramBodymessage . "`n" . VideoLinks StrLenOfMessageAndVideoLinks := StrLen(TelegramVideoTitle) + StrLen(TelegramBodymessage) + StrLen(VideoLinks) ; DevModeMsgBox(StrLenOfMessageAndVideoLinks) ; 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 ; Output returned data to ErrorLog File Message = API Response:`n%Status% SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") 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 = Telegram API Error:`n %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 ; Output returned data to ErrorLog File Message = API Response:`n%Status% SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") ; Video Description goes into TelegramMessage Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessage) ; Output returned data to ErrorLog File Message = API Response:`n%Status% SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") } 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 Message = API Response:`n%Status% ; Output returned data to ErrorLog File SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") ; 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) ; go through array and post each chunk as new message Loop % VideoDescriptionChunks.Length(){ ; ArrayItem := ARRAY[A_Index] Description := VideoDescriptionChunks[A_Index] Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Description) ; Output returned data to ErrorLog File Message = Telegram API Response:`n%Status% SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile") } } Message = Video Links Posted to Telegram Successfully SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") GuiControl,, PostToTelegramButton, Telegram - Posted Successfully ToolTip CurrentSite := Return ; -------------------------------/Telegram-------------------------------