modularized Discord and Telegram code to their own #include file
parent
3e79e11f2a
commit
5852ea4c61
@ -0,0 +1,78 @@
|
||||
PostToDiscord:
|
||||
;------------------------------------------------
|
||||
|
||||
CurrentSocialMediaPosting := "Discord"
|
||||
Message = Posting Video Links to Discord
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
|
||||
IniRead, DiscordVideosWebhookURL, %SettingsIniFilepath%, General, DiscordVideosWebhookURL, %A_Space%
|
||||
if(DiscordVideosWebhookURL = ""){
|
||||
Message = Unable to Grab DiscordVideosWebhookURL from %SettingsIniFilepath%.`nPlease input the URL and then try again.
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
Msgbox, Unable to Grab DiscordVideosWebhookURL from %SettingsIniFilepath%.`nPlease input the URL and then try again.
|
||||
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()
|
||||
}
|
||||
|
||||
; Msgbox % "SocialMediaDescription: " SocialMediaDescription
|
||||
|
||||
SubmitDescriptionForDiscordVideosChannel:
|
||||
Message := "**" . VideoTitle . "**" . "`n" . SocialMediaDescription . "`n"
|
||||
; https://stackoverflow.com/questions/63160401/how-to-create-hyperlink-in-discord-in-an-embed-in-general
|
||||
; Do this with an array!!
|
||||
;
|
||||
|
||||
if(BitChuteURL != "")
|
||||
Message .= "[BitChute](<" . BitChuteURL . ">) \| "
|
||||
|
||||
if(BrighteonURL != "")
|
||||
Message .= "[Brighteon](<" . BrighteonURL . ">) \| "
|
||||
|
||||
if(OdyseeVideoURL != "")
|
||||
Message .= "[Odysee](<" . OdyseeVideoURL . ">) \| "
|
||||
|
||||
if(OdyseeAudioURL != "")
|
||||
Message .= "[Odysee (Audio)](<" . OdyseeAudioURL . ">) \| "
|
||||
/*
|
||||
if(OdyseeVideoURL != "")
|
||||
Message .= "[Odysee](<" . OdyseeVideoURL . ") \| "
|
||||
|
||||
if(OdyseeAudioURL != "")
|
||||
Message .= "[Odysee Audio](<" . OdyseeAudioURL . ") \| "
|
||||
|
||||
*/
|
||||
if(RumbleURL != "")
|
||||
Message .= "[Rumble](<" . RumbleURL . ">) \| "
|
||||
|
||||
/*if(StreamanityURL != "" AND InStr(StreamanityURL, "streamanity.com"))
|
||||
Message .= "[Streamanity](<" . StreamanityURL . ">) \| "
|
||||
|
||||
*/
|
||||
if(DailyMotionURL != "")
|
||||
Message .= "[DailyMotion](<" . DailyMotionURL . ">)"
|
||||
|
||||
|
||||
UploadImageToDiscord(DiscordVideosWebhookURL, Message, VideoThumbFilepath)
|
||||
|
||||
|
||||
|
||||
SaveOrPostProgress(Message:="Video Links posted to #Videos Successfully.",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||
GuiControl,, PostToDiscordButton, Discord - Posted Successfully
|
||||
|
||||
sleep, 2000
|
||||
ToolTip
|
||||
; Msgbox,,Success,Video Links posted to #Videos Successfully.
|
||||
; ToolTip
|
||||
Return
|
||||
; -------------------------------/Discord-------------------------------
|
@ -0,0 +1,168 @@
|
||||
PostToTelegram:
|
||||
;------------------------------------------------
|
||||
CurrentSocialMediaPosting := "Telegram"
|
||||
|
||||
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")
|
||||
; 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 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 := "*" . TelegramVideoTitle . "*"
|
||||
|
||||
TelegramBodymessage := ASCIISTRReplace(VideoDescription)
|
||||
|
||||
|
||||
LineBreakChar = `%0A ; Used for API
|
||||
|
||||
if(BitChuteURL != "")
|
||||
VideoLinks .= "[BitChute](" . BitChuteURL . ") \| "
|
||||
|
||||
if(BrighteonURL != "")
|
||||
VideoLinks .= "[Brighteon](" . BrighteonURL . ") \| "
|
||||
|
||||
if(OdyseeVideoURL != "")
|
||||
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 . ") \| "
|
||||
|
||||
|
||||
TelegramMessage := TelegramVideoTitle . "`n" . TelegramBodymessage . "`n" . VideoLinks
|
||||
|
||||
|
||||
|
||||
StrLenOfMessageAndVideoLinks := StrLen(TelegramVideoTitle) + StrLen(TelegramBodymessage) + StrLen(VideoLinks)
|
||||
; 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")
|
||||
; 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
|
||||
|
||||
; 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
|
||||
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
|
||||
|
||||
TelegramBodymessagePiece := SubStr(TelegramBodymessage, 1, 4096)
|
||||
msgbox % StrLen(TelegramBodymessagePiece)
|
||||
Status2 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece)
|
||||
|
||||
|
||||
|
||||
TelegramBodymessagePiece := SubStr(TelegramBodymessage, 4097, 8192)
|
||||
msgbox % StrLen(TelegramBodymessagePiece)
|
||||
DevModeMsgBox(TelegramBodymessagePiece)
|
||||
Status3 := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBodymessagePiece)
|
||||
|
||||
; 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
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||
GuiControl,, PostToTelegramButton, Telegram - Posted Successfully
|
||||
|
||||
|
||||
; sleep, 2000
|
||||
|
||||
|
||||
ToolTip
|
||||
CurrentSite :=
|
||||
Return
|
||||
; -------------------------------/Telegram-------------------------------
|
Loading…
Reference in New Issue