You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
social-media-poster/Modules/Post-To-Steemit.ahk

184 lines
6.0 KiB
Plaintext

;-----------------------Steemit-------------------------
PostToSteemit:
CurrentSite := "Steemit"
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
URLAttempt := NavigateFromBaseURLTo("https://steemit.com/submit.html")
if(URLAttempt = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
Message = Checking for Content from Previous Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Click CLear Button
Xpath = //button[normalize-space()='Clear']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Trying to log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Xpath = //a[normalize-space()='Login']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Login Expired. Please log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
sleep, 2000
; otherwise button was clicked and we need to submit the saved credentials
Xpath = //button[normalize-space()='Login']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=20,SleepLength:=100)
; DevModeMsgBox(Status)
if(Status){
Message = Login Expired. Please log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
else,
{
sleep, 3000
Xpath = //button[normalize-space()='Clear']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Upload Failed: Check Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
}
}
else, {
sleep, 500
try, driver.switchToalert().accept() ; if text exists Steemit will pop up menu asking for confirmation for clearing
}
/*
*/
Message = Inputting Post Content
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Input title
Xpath = //input[@placeholder='Title']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitle)
if(Status){
Message = Login Expired. Please log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
Xpath = //textarea[@placeholder='Write your story...']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostBody)
if(Status){
Message = Failed to input Post Body
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
if(ImageAttachmentFilepath != ""){
Message = Attaching Thumbnail
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath)
if(Status){
Message = Failed to attach Image
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
/*
Xpath = //a[normalize-space()='selecting them']
Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000)
if(Status){
Message = Failed to click on "Attach Image" button
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath)
if(InputStatus = "Failed")
{
Message = Upload Failed:`nUnable to Find "Open File" window to input filepath into
SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging")
Return
}
*/
Message = Waiting 5 seconds for thumbnail to be generated
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 5000
}
message = Inputting Tags
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Input Post Tags
Xpath = //input[@placeholder='#tag']
TagsArray := StrSplit(PostTags, ",")
TagsArrayLength := TagsArray.Length() ; Save total number of items in the array
loop, %TagsArrayLength%{
Tag := TagsArray[A_Index]
Tag := StrReplace(Tag, " ", "")
Tag = #%Tag%
Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag)
try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Space)
if(A_index = 8) ; Steemit only allows 8 tags
Break
}
/*
*/
if (ConfirmBeforeSubmit && ConfirmBeforeSubmitMsgboxFunc() != true) {
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
SaveOrPostProgress(Message:=Message, PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
return
}
Message = Submitting Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Click Submit Button
Xpath = //button[@type='submit']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Failed to submit Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
IniWrite, Successful, %StatusFileFilePath%, Status, Steemit
AddToTotalPostsPostedCount()
Message = Post Publish Successful
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return
;-----------------------/Steemit-------------------------