added check for Chrome dialog boxes on each Tab url navigation
This commit is contained in:
@@ -1126,6 +1126,250 @@ Return
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; -------------------------------Discord-------------------------------
|
||||||
|
PostToDiscord:
|
||||||
|
CurrentSite := "Discord"
|
||||||
|
|
||||||
|
; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
Message = Posting Through API
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
if(DiscordParlerWebhookURL = ""){
|
||||||
|
Message = Webhook Link not found. Please set "DiscordParlerWebhookURL" in %SettingsIniFilepath%.
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(BoldTitleWAPI){
|
||||||
|
if(NewLineBetweenTitle)
|
||||||
|
Message = **%PostTitle%**`n`n%PostBody%
|
||||||
|
else,
|
||||||
|
Message = **%PostTitle%**`n%PostBody%
|
||||||
|
}
|
||||||
|
else, { ; NOT bold title
|
||||||
|
if(NewLineBetweenTitle)
|
||||||
|
Message = %PostTitle%`n`n%PostBody%
|
||||||
|
else,
|
||||||
|
Message = %PostTitle%`n%PostBody%
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(ImageAttachmentFilepath != ""){
|
||||||
|
SingleQuotationMark = "
|
||||||
|
; remove any single quotes from filepath
|
||||||
|
ImageAttachmentFilepath := StrReplace(ImageAttachmentFilepath, SingleQuotationMark, "")
|
||||||
|
|
||||||
|
if(StrLen(Message) > 1999){ ; split message into two parts if longer than this
|
||||||
|
loop % StrLen(Message) {
|
||||||
|
|
||||||
|
if(A_index < 1900)
|
||||||
|
Continue
|
||||||
|
|
||||||
|
SplitCharNumber := A_index
|
||||||
|
; IndexMinusOne := A_index - 1
|
||||||
|
|
||||||
|
SplitLocationText := SubStr(Message, SplitCharNumber, 1)
|
||||||
|
if(SplitLocationText = " "){
|
||||||
|
Break
|
||||||
|
; Msgbox % "SplitLocation: " SplitLocation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber)
|
||||||
|
SplitCharNumber := SplitCharNumber + 1
|
||||||
|
DiscordMessagePartTwo := SubStr(Message, SplitCharNumber)
|
||||||
|
; Msgbox % "DiscordMessagePartOne: " DiscordMessagePartOne
|
||||||
|
; Msgbox % "DiscordMessagePartTwo: " DiscordMessagePartTwo
|
||||||
|
|
||||||
|
Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler")
|
||||||
|
Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler")
|
||||||
|
Status := UploadImageToDiscord(DiscordParlerWebhookURL, "", ImageAttachmentFilepath)
|
||||||
|
|
||||||
|
; Msgbox % "StatusOne: " StatusOne
|
||||||
|
; Msgbox % "StatusTwo: " StatusTwo
|
||||||
|
|
||||||
|
/* if(!InStr(StatusOne, "id")){ ; if error for each of the messages, post its
|
||||||
|
parsed := JSON.Load(StatusOne)
|
||||||
|
StatusOneFailure := parsed.content[1]
|
||||||
|
|
||||||
|
parsed := JSON.Load(StatusTwo)
|
||||||
|
StatusTwoFailure := parsed.content[1]
|
||||||
|
|
||||||
|
Message = Partial Failure for the following reason: %StatusOneFailure% OR %StatusTwoFailure%
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
} ; end of strlen > 1999
|
||||||
|
else, {
|
||||||
|
Status := UploadImageToDiscord(DiscordParlerWebhookURL, Message, ImageAttachmentFilepath)
|
||||||
|
SaveOrPostProgress(Message:="Status",PostType:="ErrorLoggingTextFile")
|
||||||
|
|
||||||
|
if(!InStr(Status, "id")){
|
||||||
|
parsed := JSON.Load(Status)
|
||||||
|
Error := parsed.content[1]
|
||||||
|
; Msgbox % "error: " error
|
||||||
|
Message = Discord Post Failed due to API Issue. Error was saved to errorlog; please forward to Yuriy
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(StrLen(Message) > 1999){ ; split message into two parts if longer than this
|
||||||
|
loop % StrLen(Message) {
|
||||||
|
|
||||||
|
if(A_index < 1900)
|
||||||
|
Continue
|
||||||
|
|
||||||
|
SplitCharNumber := A_index
|
||||||
|
|
||||||
|
SplitLocationText := SubStr(Message, SplitCharNumber, 1)
|
||||||
|
if(SplitLocationText = " "){
|
||||||
|
Break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber)
|
||||||
|
SplitCharNumber := SplitCharNumber + 1
|
||||||
|
DiscordMessagePartTwo := SubStr(Message, SplitCharNumber)
|
||||||
|
|
||||||
|
Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler")
|
||||||
|
Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler")
|
||||||
|
}
|
||||||
|
else,
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordParler")
|
||||||
|
}
|
||||||
|
|
||||||
|
IniWrite, Successful, %StatusFileFilePath%, Status, Discord
|
||||||
|
AddToTotalPostsPostedCount()
|
||||||
|
|
||||||
|
Message = Submitted Successfully
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
|
||||||
|
Return
|
||||||
|
; -------------------------------/Discord-------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
|
||||||
|
; -------------------------------Telegram-------------------------------
|
||||||
|
; API documentation
|
||||||
|
; https://core.telegram.org/bots/api#sendmessage
|
||||||
|
PostToTelegram:
|
||||||
|
CurrentSite := "Telegram"
|
||||||
|
|
||||||
|
; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
Message = Posting Through API
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
|
||||||
|
if(TelegramBotToken = "" Or TelegramBotChatID =""){
|
||||||
|
Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script.
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LineBreakChar = `%0A ; Used for API
|
||||||
|
|
||||||
|
|
||||||
|
TelegramTitle := ASCIISTRReplace(PostTitle)
|
||||||
|
TelegramBody := ASCIISTRReplace(PostBody)
|
||||||
|
|
||||||
|
|
||||||
|
/* TelegramTitle := PostTitle
|
||||||
|
TelegramBody := PostBody
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
; Msgbox % "TelegramBody: " TelegramBody
|
||||||
|
|
||||||
|
if(PostBody = ""){
|
||||||
|
if(BoldTitleWAPI)
|
||||||
|
Message := "*" . TelegramTitle . "*"
|
||||||
|
else,
|
||||||
|
Message := TelegramTitle
|
||||||
|
}
|
||||||
|
else, { ; if postbody is not blank
|
||||||
|
; MsgBox, we in post body
|
||||||
|
if(BoldTitleWAPI){
|
||||||
|
if(NewLineBetweenTitle)
|
||||||
|
Message := "*" . TelegramTitle . "*" . "`n`n" . TelegramBody
|
||||||
|
else,
|
||||||
|
Message := "*" . TelegramTitle . "*" . "`n" . TelegramBody
|
||||||
|
}
|
||||||
|
else, { ; NOT Bold Title
|
||||||
|
if(NewLineBetweenTitle)
|
||||||
|
Message := TelegramTitle . "`n`n" . TelegramBody
|
||||||
|
else,
|
||||||
|
Message := TelegramTitle . "`n" . TelegramBody
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Msgbox % "Message: " Message
|
||||||
|
; REMOVE
|
||||||
|
; Message := PostTitle . "`n" . PostBody
|
||||||
|
|
||||||
|
; Msgbox % "TelegramTitle: " TelegramTitle
|
||||||
|
; Msgbox % "TelegramBody: " TelegramBody
|
||||||
|
|
||||||
|
; Msgbox % "Message: " Message
|
||||||
|
|
||||||
|
|
||||||
|
if(ImageAttachmentFilepath != "" AND StrLen(Message) > 1020){ ; utilize function that converts image to MIME/multi form
|
||||||
|
; Telegram API character limit of 4096 for a basic message.
|
||||||
|
; @todo: add functionality to split messages longer than 4096 characters
|
||||||
|
; msgbox, 2
|
||||||
|
|
||||||
|
if(BoldTitleWAPI)
|
||||||
|
TelegramTitle := "*" . TelegramTitle . "*"
|
||||||
|
else,
|
||||||
|
TelegramTitle := TelegramTitle
|
||||||
|
|
||||||
|
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := TelegramTitle ) ; you could add more options; compare the Telegram API docs
|
||||||
|
Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBody )
|
||||||
|
}
|
||||||
|
else if(ImageAttachmentFilepath != "" AND StrLen(Message) <= 1020){
|
||||||
|
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := Message ) ; you could add more options; compare the Telegram API docs
|
||||||
|
|
||||||
|
}
|
||||||
|
else,
|
||||||
|
{ ; send just the text
|
||||||
|
; Msgbox % "Message: " Message
|
||||||
|
Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Message )
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Status){
|
||||||
|
Message = Upload Failed due to API issue. Telegram API Returned Value:`n %Status%
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordParler")
|
||||||
|
IniWrite, Successful, %StatusFileFilePath%, Status, Telegram
|
||||||
|
AddToTotalPostsPostedCount()
|
||||||
|
|
||||||
|
Message = Submitted Successfully
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
|
||||||
|
Return
|
||||||
|
; -------------------------------/Telegram-------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
;---------------Facebook----------------------------------
|
;---------------Facebook----------------------------------
|
||||||
PostToFacebook:
|
PostToFacebook:
|
||||||
CurrentSite := "Facebook"
|
CurrentSite := "Facebook"
|
||||||
@@ -1337,7 +1581,6 @@ if(Status){
|
|||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
; Check login status by checking the header of the page for "Feed" text
|
; Check login status by checking the header of the page for "Feed" text
|
||||||
loop, 5 {
|
loop, 5 {
|
||||||
SaveOrPostProgress(Message:="Checking Login Status",PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:="Checking Login Status",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
@@ -1362,39 +1605,6 @@ if(!InStr(status, "Feed")){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*try CurrentTabURL := driver.Url
|
|
||||||
; Msgbox % "CurrentTabURL: " CurrentTabURL
|
|
||||||
if(InStr(CurrentTabURL, "/login")){
|
|
||||||
SaveOrPostProgress(Message:="Cookies Expired. Trying to Log back in",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
Xpath = //div[@class='form__contain']//button[@class='button'][normalize-space()='Log In']
|
|
||||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
|
||||||
if(Status){
|
|
||||||
SaveOrPostProgress(Message:="Failed to click login button",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
}
|
|
||||||
sleep, 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
; Message = Trying to click on "Parley.." to start new post
|
|
||||||
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
|
|
||||||
|
|
||||||
; sleep, 5000 ; sleep 2 seconds for page to fully load in case it's being slow
|
|
||||||
|
|
||||||
; js = document.getElementsByClassName('input-trigger')[0].click()
|
|
||||||
; try driver.executeScript(JS) ;Execute Javascript
|
|
||||||
|
|
||||||
|
|
||||||
/* ; if failed to click into box then error out
|
|
||||||
if(Status){
|
|
||||||
Message = Post Failed: Page didn't load properly
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
SaveDriverURLOFErrorPage()
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
; Msgbox % "Status: " Status
|
|
||||||
|
|
||||||
Message = Inputting Post
|
Message = Inputting Post
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
@@ -1438,43 +1648,6 @@ if(InStr(CurrentTabURL, "/login")){
|
|||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
|
|
||||||
; driver.FindElementByXPath(Xpath).SendKeys("heyyyy")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ; Input Post content pop up
|
|
||||||
Xpath = //div[@id='create-parley-wysiwyg']
|
|
||||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
|
|
||||||
if(Status){
|
|
||||||
Message = Failed to input Post Message with relative Xpath
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
; Input post with JS
|
|
||||||
JsToExecute = document.querySelector("#create-parley-wysiwyg").innerText = '%JSPostTitleAndBody%'
|
|
||||||
try Status := driver.executeScript(JsToExecute)
|
|
||||||
; Check if text got input
|
|
||||||
JsToExecute = return document.querySelector("#create-parley-wysiwyg").innerText
|
|
||||||
try Status := driver.executeScript(JsToExecute)
|
|
||||||
if(Status = ""){
|
|
||||||
Message = Failed to Input with JS as well
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
Xpath = /html[1]/body[1]/div[3]/div[1]/div[1]/div[1]/div[1]/div[3]/div[1]/div[2]/div[1]/div[1]/form[1]/div[1]/div[2]/div[1]
|
|
||||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
|
|
||||||
if(Status){
|
|
||||||
try CurrentTab := driver.url
|
|
||||||
Message = Failed to input Post: `nCurrent Tab URL: %CurrentTab%
|
|
||||||
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
SaveDriverURLOFErrorPage()
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
if(ImageAttachmentFilepath != ""){
|
if(ImageAttachmentFilepath != ""){
|
||||||
Message = Attaching Image
|
Message = Attaching Image
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
@@ -1510,43 +1683,6 @@ if(InStr(CurrentTabURL, "/login")){
|
|||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Message = Waiting 5 seconds to double check that the post got submitted
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip, ErrorLoggingTextFile")
|
|
||||||
sleep, 5000
|
|
||||||
|
|
||||||
; check the text contents of the input box to make sure that the post got submitted
|
|
||||||
JsToExecute = return document.querySelector("div[id='create-parley-wysiwyg'] div").textContent;
|
|
||||||
try Status := driver.executeScript(JsToExecute)
|
|
||||||
if(Status != ""){
|
|
||||||
Xpath = //button[@id='submit-button'] ; click the submit button again
|
|
||||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
|
||||||
|
|
||||||
; Message = Post got input but did not submit properly and still present after 5 seconds`nPost Content: %Status%
|
|
||||||
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
; DevModeMsgBox(Status)
|
|
||||||
|
|
||||||
/* js = document.getElementById('submit-button').click();
|
|
||||||
status := JS_TryToExecute(js,2,2000)
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* sleep, 3000
|
|
||||||
jscheck = return document.getElementsByClassName('emoji-wysiwyg-editor')[0].textContent;
|
|
||||||
try Status := driver.executeScript(jsCheck)
|
|
||||||
if(Status != ""){
|
|
||||||
Message = Failed to Submit Post (#2523)
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
; Msgbox % "Status: " Status
|
|
||||||
|
|
||||||
|
|
||||||
IniWrite, Successful, %StatusFileFilePath%, Status, Parler
|
IniWrite, Successful, %StatusFileFilePath%, Status, Parler
|
||||||
|
|
||||||
@@ -1562,144 +1698,8 @@ if(InStr(CurrentTabURL, "/login")){
|
|||||||
Return
|
Return
|
||||||
; -------------------------------/Parler-------------------------------
|
; -------------------------------/Parler-------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; -------------------------------Discord-------------------------------
|
|
||||||
PostToDiscord:
|
|
||||||
CurrentSite := "Discord"
|
|
||||||
|
|
||||||
; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile")
|
|
||||||
Message = Posting Through API
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
if(DiscordParlerWebhookURL = ""){
|
|
||||||
Message = Webhook Link not found. Please set "DiscordParlerWebhookURL" in %SettingsIniFilepath%.
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(BoldTitleWAPI){
|
|
||||||
if(NewLineBetweenTitle)
|
|
||||||
Message = **%PostTitle%**`n`n%PostBody%
|
|
||||||
else,
|
|
||||||
Message = **%PostTitle%**`n%PostBody%
|
|
||||||
}
|
|
||||||
else, { ; NOT bold title
|
|
||||||
if(NewLineBetweenTitle)
|
|
||||||
Message = %PostTitle%`n`n%PostBody%
|
|
||||||
else,
|
|
||||||
Message = %PostTitle%`n%PostBody%
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if(PostTitle != "")
|
|
||||||
Message = **%PostTitle%**`n%PostBody%
|
|
||||||
else,
|
|
||||||
Message = %PostBody%
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
if(ImageAttachmentFilepath != ""){
|
|
||||||
SingleQuotationMark = "
|
|
||||||
; remove any single quotes from filepath
|
|
||||||
ImageAttachmentFilepath := StrReplace(ImageAttachmentFilepath, SingleQuotationMark, "")
|
|
||||||
|
|
||||||
if(StrLen(Message) > 1999){ ; split message into two parts if longer than this
|
|
||||||
loop % StrLen(Message) {
|
|
||||||
|
|
||||||
if(A_index < 1900)
|
|
||||||
Continue
|
|
||||||
|
|
||||||
SplitCharNumber := A_index
|
|
||||||
; IndexMinusOne := A_index - 1
|
|
||||||
|
|
||||||
SplitLocationText := SubStr(Message, SplitCharNumber, 1)
|
|
||||||
if(SplitLocationText = " "){
|
|
||||||
Break
|
|
||||||
; Msgbox % "SplitLocation: " SplitLocation
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber)
|
|
||||||
SplitCharNumber := SplitCharNumber + 1
|
|
||||||
DiscordMessagePartTwo := SubStr(Message, SplitCharNumber)
|
|
||||||
; Msgbox % "DiscordMessagePartOne: " DiscordMessagePartOne
|
|
||||||
; Msgbox % "DiscordMessagePartTwo: " DiscordMessagePartTwo
|
|
||||||
|
|
||||||
Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler")
|
|
||||||
Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler")
|
|
||||||
Status := UploadImageToDiscord(DiscordParlerWebhookURL, "", ImageAttachmentFilepath)
|
|
||||||
|
|
||||||
; Msgbox % "StatusOne: " StatusOne
|
|
||||||
; Msgbox % "StatusTwo: " StatusTwo
|
|
||||||
|
|
||||||
/* if(!InStr(StatusOne, "id")){ ; if error for each of the messages, post its
|
|
||||||
parsed := JSON.Load(StatusOne)
|
|
||||||
StatusOneFailure := parsed.content[1]
|
|
||||||
|
|
||||||
parsed := JSON.Load(StatusTwo)
|
|
||||||
StatusTwoFailure := parsed.content[1]
|
|
||||||
|
|
||||||
Message = Partial Failure for the following reason: %StatusOneFailure% OR %StatusTwoFailure%
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
} ; end of strlen > 1999
|
|
||||||
else, {
|
|
||||||
Status := UploadImageToDiscord(DiscordParlerWebhookURL, Message, ImageAttachmentFilepath)
|
|
||||||
SaveOrPostProgress(Message:="Status",PostType:="ErrorLoggingTextFile")
|
|
||||||
|
|
||||||
if(!InStr(Status, "id")){
|
|
||||||
parsed := JSON.Load(Status)
|
|
||||||
Error := parsed.content[1]
|
|
||||||
; Msgbox % "error: " error
|
|
||||||
Message = Discord Post Failed due to API Issue. Error was saved to errorlog; please forward to Yuriy
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(StrLen(Message) > 1999){ ; split message into two parts if longer than this
|
|
||||||
loop % StrLen(Message) {
|
|
||||||
|
|
||||||
if(A_index < 1900)
|
|
||||||
Continue
|
|
||||||
|
|
||||||
SplitCharNumber := A_index
|
|
||||||
|
|
||||||
SplitLocationText := SubStr(Message, SplitCharNumber, 1)
|
|
||||||
if(SplitLocationText = " "){
|
|
||||||
Break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber)
|
|
||||||
SplitCharNumber := SplitCharNumber + 1
|
|
||||||
DiscordMessagePartTwo := SubStr(Message, SplitCharNumber)
|
|
||||||
|
|
||||||
Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler")
|
|
||||||
Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler")
|
|
||||||
}
|
|
||||||
else,
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordParler")
|
|
||||||
}
|
|
||||||
|
|
||||||
IniWrite, Successful, %StatusFileFilePath%, Status, Discord
|
|
||||||
AddToTotalPostsPostedCount()
|
|
||||||
|
|
||||||
Message = Submitted Successfully
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
|
|
||||||
Return
|
|
||||||
; -------------------------------/Discord-------------------------------
|
|
||||||
|
|
||||||
; -------------------------------SubScribeStar-------------------------------
|
; -------------------------------SubScribeStar-------------------------------
|
||||||
PostToSubscribeStar:
|
PostToSubscribeStar:
|
||||||
@@ -1887,113 +1887,6 @@ if(InStr(CurrentTabURL, "/login")){
|
|||||||
Return
|
Return
|
||||||
; -------------------------------/SubScribeStar-------------------------------
|
; -------------------------------/SubScribeStar-------------------------------
|
||||||
|
|
||||||
; -------------------------------Telegram-------------------------------
|
|
||||||
; API documentation
|
|
||||||
; https://core.telegram.org/bots/api#sendmessage
|
|
||||||
PostToTelegram:
|
|
||||||
CurrentSite := "Telegram"
|
|
||||||
|
|
||||||
; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile")
|
|
||||||
Message = Posting Through API
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
|
|
||||||
if(TelegramBotToken = "" Or TelegramBotChatID =""){
|
|
||||||
Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script.
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LineBreakChar = `%0A ; Used for API
|
|
||||||
|
|
||||||
|
|
||||||
TelegramTitle := ASCIISTRReplace(PostTitle)
|
|
||||||
TelegramBody := ASCIISTRReplace(PostBody)
|
|
||||||
|
|
||||||
|
|
||||||
/* TelegramTitle := PostTitle
|
|
||||||
TelegramBody := PostBody
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
; Msgbox % "TelegramBody: " TelegramBody
|
|
||||||
|
|
||||||
if(PostBody = ""){
|
|
||||||
if(BoldTitleWAPI)
|
|
||||||
Message := "*" . TelegramTitle . "*"
|
|
||||||
else,
|
|
||||||
Message := TelegramTitle
|
|
||||||
}
|
|
||||||
else, { ; if postbody is not blank
|
|
||||||
; MsgBox, we in post body
|
|
||||||
if(BoldTitleWAPI){
|
|
||||||
if(NewLineBetweenTitle)
|
|
||||||
Message := "*" . TelegramTitle . "*" . "`n`n" . TelegramBody
|
|
||||||
else,
|
|
||||||
Message := "*" . TelegramTitle . "*" . "`n" . TelegramBody
|
|
||||||
}
|
|
||||||
else, { ; NOT Bold Title
|
|
||||||
if(NewLineBetweenTitle)
|
|
||||||
Message := TelegramTitle . "`n`n" . TelegramBody
|
|
||||||
else,
|
|
||||||
Message := TelegramTitle . "`n" . TelegramBody
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
; Msgbox % "Message: " Message
|
|
||||||
; REMOVE
|
|
||||||
; Message := PostTitle . "`n" . PostBody
|
|
||||||
|
|
||||||
; Msgbox % "TelegramTitle: " TelegramTitle
|
|
||||||
; Msgbox % "TelegramBody: " TelegramBody
|
|
||||||
|
|
||||||
; Msgbox % "Message: " Message
|
|
||||||
|
|
||||||
|
|
||||||
if(ImageAttachmentFilepath != "" AND StrLen(Message) > 1020){ ; utilize function that converts image to MIME/multi form
|
|
||||||
; Telegram API character limit of 4096 for a basic message.
|
|
||||||
; @todo: add functionality to split messages longer than 4096 characters
|
|
||||||
; msgbox, 2
|
|
||||||
|
|
||||||
if(BoldTitleWAPI)
|
|
||||||
TelegramTitle := "*" . TelegramTitle . "*"
|
|
||||||
else,
|
|
||||||
TelegramTitle := TelegramTitle
|
|
||||||
|
|
||||||
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := TelegramTitle ) ; you could add more options; compare the Telegram API docs
|
|
||||||
Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBody )
|
|
||||||
}
|
|
||||||
else if(ImageAttachmentFilepath != "" AND StrLen(Message) <= 1020){
|
|
||||||
Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := Message ) ; you could add more options; compare the Telegram API docs
|
|
||||||
|
|
||||||
}
|
|
||||||
else,
|
|
||||||
{ ; send just the text
|
|
||||||
; Msgbox % "Message: " Message
|
|
||||||
Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Message )
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Status){
|
|
||||||
Message = Upload Failed due to API issue. Telegram API Returned Value:`n %Status%
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
|
|
||||||
; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordParler")
|
|
||||||
IniWrite, Successful, %StatusFileFilePath%, Status, Telegram
|
|
||||||
AddToTotalPostsPostedCount()
|
|
||||||
|
|
||||||
Message = Submitted Successfully
|
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
|
|
||||||
Return
|
|
||||||
; -------------------------------/Telegram-------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; -------------------------------LinkedIn-------------------------------
|
; -------------------------------LinkedIn-------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user