Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| def4d4d57b | |||
| e810133ff5 | |||
| 45420c0b7b | |||
| 7e8830b7d0 |
|
Before Width: | Height: | Size: 355 KiB After Width: | Height: | Size: 355 KiB |
155
Compile and Release.ahk
Normal file
155
Compile and Release.ahk
Normal file
@@ -0,0 +1,155 @@
|
||||
;---ENVIRONMENT---------------------------------------------------------------------
|
||||
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
|
||||
;#Warn ; Enable warnings to assist with detecting common errors.
|
||||
;DetectHiddenWindows, On
|
||||
#SingleInstance, Force
|
||||
DetectHiddenWindows, ON
|
||||
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||
;SetKeyDelay, 500
|
||||
CoordMode, ToolTip, Screen
|
||||
CoordMode, Mouse, Screen
|
||||
; #NoTrayIcon
|
||||
; Menu, Tray, Icon, RMScriptManager.ico
|
||||
|
||||
;---Notes/Extra Info/#Includes------------------------------------------------------
|
||||
#Include, %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\WindowCredentialManager.ahk
|
||||
|
||||
;---VARIABLES-----------------------------------------------------------------------
|
||||
ProgramName = Freedomain Social Media Poster
|
||||
ExeProgramName = %ProgramName%.exe
|
||||
AHKFilepath = %A_ScriptDir%\%ProgramName%.ahk
|
||||
Exefilepath = %A_ScriptDir%\%ProgramName%.exe
|
||||
icopath = %A_ScriptDir%\Assets\Icon.ico
|
||||
VersionIniFP = %A_ScriptDir%\Version.ini
|
||||
|
||||
; Generate a new errorlog text file each run
|
||||
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
|
||||
ErrorLogTextFile = %A_ScriptDir%\Lib\ErrorLogging\Compiler_%TodayDate%.txt
|
||||
|
||||
|
||||
; Read Credential token from Windows Credential Manager using WindowCredentialManager.ahk
|
||||
cred := CredRead("FDR-Gitea-Token")
|
||||
GiteaToken := Cred.Password
|
||||
|
||||
; Info for Creating the Release with Gitea-CreateRelease.ps1
|
||||
CreateReleasePS1Filepath = %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-CreateRelease.ps1
|
||||
CreateReleaseAPIURL = https://freedomain.dev/api/v1/repos/yuriy/social-media-poster/releases?token=%GiteaToken%
|
||||
|
||||
; Info for Attaching exe file to release using Gitea-AttachAssetToRelease.ps1
|
||||
AttachAssetToReleasePS1Filepath = %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-AttachAssetToRelease.ps1
|
||||
AttachAssetToReleaseAPIURL = https://freedomain.dev/api/v1/repos/yuriy/social-media-poster/releases
|
||||
|
||||
;---\VARIABLES-----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
; Compile to .exe
|
||||
; ------------------------------------------------
|
||||
; Bump the version number in the version.ini file
|
||||
IniRead, VersionNumber, %VersionIniFP%, Social-Media-Poster, Version, 0.0 ; , Filename, Section, Key [, Default]
|
||||
VersionNumber += .01
|
||||
VersionNumber := SubStr(VersionNumber, 1, 4)
|
||||
IniWrite, %VersionNumber%, %VersionIniFP%,Social-Media-Poster, Version
|
||||
|
||||
|
||||
|
||||
; Kill any active intances of the uploaders so the .exe file can be overwriten by the compilation
|
||||
process, close, %ExeProgramName%
|
||||
|
||||
sleep, 500
|
||||
|
||||
; Delete the .exe file so it can be repalced
|
||||
if(FileExist(Exefilepath)){
|
||||
FileDelete, %Exefilepath%
|
||||
if(ErrorLevel){
|
||||
msgbox, failed to delete Exe file. Please delete manually and re-run the compiler.
|
||||
ExitApp
|
||||
}
|
||||
}
|
||||
|
||||
; check if file exists and if not, give user error and stop
|
||||
if(!FileExist(AHKFilepath)){
|
||||
msgbox, %AHKFilepath% does not exist`nExiting
|
||||
ExitApp
|
||||
}
|
||||
|
||||
; check if file exists and if not, give user error and stop
|
||||
if(!FileExist(icopath)){
|
||||
msgbox, %icopath% does not exist`nExiting
|
||||
ExitApp
|
||||
}
|
||||
|
||||
; run, %comspec% /c ""C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%""
|
||||
Command = "C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%"
|
||||
Results := RunCMD(Command)
|
||||
LogToErrorLogFile(Results, ErrorLogTextFile)
|
||||
|
||||
if(!InStr(Results, "Successfully")){
|
||||
Msgbox, Error, Compilation failed with the following error:`n`n%Results%
|
||||
ExitApp
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
; Create new Release on Gitea using Gitea-CreateRelease.ps1
|
||||
; ------------------------------------------------
|
||||
InputBox, ReleaseBody, Release Body, Please Input Text to be used in the Release Body
|
||||
|
||||
ReleaseName := VersionNumber
|
||||
ReleaseTag := VersionNumber
|
||||
|
||||
; Strings with spaces in them need to be surrounted by a single quote and double quote, eg: "'spaced string'"
|
||||
Command = Powershell "%CreateReleasePS1Filepath%" "%CreateReleaseAPIURL%" "%ReleaseName%" "%ReleaseTag%" "'%ReleaseBody%'"
|
||||
|
||||
Message = PowerShell Command to Create Release:`n%Command%
|
||||
LogToErrorLogFile(Message, ErrorLogTextFile)
|
||||
|
||||
Results := RunCMD(Command)
|
||||
LogToErrorLogFile(Results, ErrorLogTextFile)
|
||||
|
||||
|
||||
; Pull out the release ID Number, needed for attaching a file to the release
|
||||
SplitText = @{id=
|
||||
SplitText2 = `;
|
||||
ReleaseID := StrSplit(Results, SplitText)[2]
|
||||
ReleaseID := StrSplit(ReleaseID, SplitText2)[1]
|
||||
|
||||
Message = ReleaseID: %ReleaseID%
|
||||
LogToErrorLogFile(Message, ErrorLogTextFile)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; Attach .exe File to Release using Gitea-AttachAssetToRelease.ps1
|
||||
; ------------------------------------------------
|
||||
AttachAssetToReleaseAPIURL = %AttachAssetToReleaseAPIURL%/%ReleaseID%/assets
|
||||
|
||||
; Strings with spaces in them need to be surrounted by a single quote and double quote, eg: "'spaced string'"
|
||||
Command = Powershell "%AttachAssetToReleasePS1Filepath%" "%AttachAssetToReleaseAPIURL%" "%GiteaToken%" "'%ExeProgramName%'" "'%Exefilepath%'"
|
||||
LogToErrorLogFile(Command, ErrorLogTextFile)
|
||||
|
||||
Results := RunCMD(Command)
|
||||
LogToErrorLogFile(Results, ErrorLogTextFile)
|
||||
|
||||
|
||||
ExitApp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;---FUNCTIONS-----------------------------------------------------------------------
|
||||
LogToErrorLogFile(Text, TextFileFilepath){
|
||||
FileAppend, %Text%`n, %TextFileFilepath%
|
||||
}
|
||||
@@ -7,7 +7,7 @@ CoordMode, ToolTip, Screen
|
||||
CoordMode, Mouse, Screen
|
||||
FileEncoding, UTF-8-RAW ; Needed for special symbols that are used in video descritions
|
||||
if(InStr(A_ScriptName, ".ahk")){
|
||||
Menu, Tray, Icon, %A_ScriptDir%\assets\FreedomainSMP.ico
|
||||
Menu, Tray, Icon, %A_ScriptDir%\assets\Icon.ico
|
||||
}
|
||||
|
||||
ErrorLoggingDirectory = %1%
|
||||
@@ -46,16 +46,14 @@ global UpdateVersionNumber
|
||||
|
||||
;---ToDo---
|
||||
;------------------------------------------------
|
||||
; @todo: fix post scheduling - countdown not working
|
||||
; @todo: Errorlog not getting appended to on > 1 run (ErrorLoggingFilePath) variable is missing somehwere
|
||||
; @todo: Add tags support on all sites that support it - ask stef is useful
|
||||
; @todo: All post submits: mark with "Post Submit Successful" OR "Post Submit Failed" for easier reading of errorlogs
|
||||
|
||||
|
||||
|
||||
; Misc info
|
||||
;------------------------------------------------
|
||||
; Parler has a 1k char limit
|
||||
; All post submits: mark with "Post Submit Successful" OR "Post Submit Failed" for easier reading of errorlogs
|
||||
|
||||
|
||||
;---Global Variables---
|
||||
@@ -97,14 +95,11 @@ global Locals
|
||||
global LinkedIn
|
||||
global MeWe
|
||||
global Twetch
|
||||
; global ThinkSpot
|
||||
; global Flote
|
||||
global PocketNet
|
||||
; global parler
|
||||
global Gettr
|
||||
global steemit
|
||||
; global Pintrest
|
||||
; global Tumblr
|
||||
global Tumblr
|
||||
|
||||
|
||||
; Check if Lib folder exists and create it if not
|
||||
LibFolder := A_ScriptDir . "\Lib"
|
||||
@@ -491,8 +486,14 @@ Gui, Font, s%GUINormalFontSize%
|
||||
|
||||
Gui, Font, Bold
|
||||
Gui, Add, GroupBox,r6.4 x%PlatformsGroupBoxXLocation% y210 w300, Platforms
|
||||
|
||||
Gui, Font, s8
|
||||
Gui, Font, Bold
|
||||
Gui, Add, Button, xp+110 yp+0 gUncheckAllPlatforms, Uncheck All
|
||||
|
||||
Gui, Font, s%GUINormalFontSize%
|
||||
Gui, Font, Normal
|
||||
Gui, Add, Checkbox, xp+10 yp+30 vDiscord Checked%DiscordCheckStatus% gUpdateVars, Discord
|
||||
Gui, Add, Checkbox, x%PlatformsGroupBoxXLocation% yp+30 vDiscord Checked%DiscordCheckStatus% gUpdateVars, Discord
|
||||
Gui, Add, Checkbox, y+7 vTelegram Checked%TelegramCheckStatus% gUpdateVars, Telegram
|
||||
Gui, Add, Checkbox, y+7 vSubscribeStar Checked%SubScribeStarCheckStatus%gUpdateVars, SubscribeStar
|
||||
Gui, Add, Checkbox, y+7 vMinds Checked%MindsCheckStatus% gUpdateVars, Minds
|
||||
@@ -506,6 +507,7 @@ Gui, Add, Checkbox, y+7 vSteemit Checked%SteemitCheckStatus% gUpdateVars, Steemi
|
||||
Gui, Add, Checkbox, y+7 vPocketNet Checked%PocketNetCheckStatus% , Bastyon
|
||||
Gui, Add, Checkbox, y+7 vGettr Checked%GettrCheckStatus% gUpdateVars, Gettr
|
||||
Gui, Add, Checkbox, y+7 vMeWe Checked%MeWeCheckStatus% gUpdateVars, MeWe
|
||||
Gui, Add, Checkbox, y+7 vTumblr Checked%Tumblr% gUpdateVars, Tumblr
|
||||
|
||||
|
||||
Gui, Font, Bold
|
||||
@@ -609,10 +611,6 @@ UpdateScript:
|
||||
UpdateScript()
|
||||
Return
|
||||
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
CancelPost:
|
||||
GuiClose:
|
||||
; ExitApp
|
||||
@@ -636,25 +634,27 @@ run, "%A_ScriptFullPath%" "LastPost"
|
||||
Return
|
||||
|
||||
|
||||
CompileScript:
|
||||
; msgbox, compiling
|
||||
IniWrite, %changelog%, %ChangelogIniFilepath%, %ScriptSettingsSection%, Changelog
|
||||
IniWrite, %ScriptVersion%, %ChangelogIniFilepath%, %ScriptSettingsSection%, ScriptVersion
|
||||
IniWrite, %UpdateURL%, %ChangelogIniFilepath%, %ScriptSettingsSection%, UpdateURL
|
||||
|
||||
run, "%A_scriptdir%\Lib\Releases\Compile Scripts to EXE.ahk" SocialMediaPoster Production
|
||||
; ExitApp
|
||||
Return
|
||||
|
||||
UploadFiles:
|
||||
msgbox, this button needs to be re-programmed. Search for "UploadFiles:" in main program
|
||||
Return
|
||||
|
||||
SelectFilepath:
|
||||
FileSelectFile, SelectedImageFilepath
|
||||
GuiControl,, ImageAttachmentFilepath, %SelectedImageFilepath%
|
||||
Return
|
||||
|
||||
UncheckAllPlatforms:
|
||||
GuiControl,,Discord, 0
|
||||
GuiControl,,Telegram, 0
|
||||
GuiControl,,SubScribeStar, 0
|
||||
GuiControl,,Minds, 0
|
||||
GuiControl,,Gab, 0
|
||||
GuiControl,,Locals, 0
|
||||
GuiControl,,Twetch, 0
|
||||
GuiControl,,LinkedIn, 0
|
||||
GuiControl,,Steemit, 0
|
||||
GuiControl,,Bastyon, 0
|
||||
GuiControl,,Gettr, 0
|
||||
GuiControl,,MeWe, 0
|
||||
GuiControl,,Tumblr, 0
|
||||
Return
|
||||
|
||||
UpdateVars:
|
||||
Gui, Submit, NoHide
|
||||
Return
|
||||
@@ -798,7 +798,6 @@ IniWrite, %ShowTooltipProgress%, %SettingsIniFilepath%, SocialMediaPoster, ShowT
|
||||
(PocketNet = 1)?(PostedWebsites .= "PocketNet|") : ()
|
||||
(Gettr = 1)?(PostedWebsites .= "Gettr|") : ()
|
||||
(Steemit = 1)?(PostedWebsites .= "Steemit|") : ()
|
||||
(Pintrest = 1)?(PostedWebsites .= "Pintrest|") : ()
|
||||
(Tumblr = 1)?(PostedWebsites .= "Tumblr|") : ()
|
||||
|
||||
Message = Starting SMP with: **V%ScriptVersion%** `nTo sites: %PostedWebsites% `nWith Title: **%PostTitle%** `nWith Body:%PostBody% `nWith Tags: %PostTags%
|
||||
@@ -862,8 +861,8 @@ Gosub, PostToMeWe
|
||||
if(Twetch)
|
||||
Gosub, PostToTwetch
|
||||
|
||||
; if(Thinkspot)
|
||||
; Gosub, PostToThinkSpot
|
||||
if(Tumblr)
|
||||
Gosub, PostToTumblr
|
||||
|
||||
if(Locals)
|
||||
Gosub, PostToLocals
|
||||
@@ -977,10 +976,10 @@ Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Steemit%
|
||||
; Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Pintrest%
|
||||
|
||||
Gui, Add, Button,x%MarginSize% w%WebsiteButtonWidths% h%ButtonHeights% Center, Bastyon
|
||||
Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %PocketNet%
|
||||
Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Bastyon%
|
||||
|
||||
; Gui, Add, Button,x%StatusTextSecondRowXPos% y+%MarginSize% w%WebsiteButtonWidths% h%ButtonHeights% Center, Tumblr
|
||||
; Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Tumblr%
|
||||
Gui, Add, Button,x%MarginSize% w%WebsiteButtonWidths% h%ButtonHeights% Center, Tumblr
|
||||
Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Tumblr%
|
||||
|
||||
|
||||
; Gui, Font, s9
|
||||
@@ -999,10 +998,6 @@ Gui, Add, Button, x%StatusTextSecondRowXPos% y+%MarginSize% w270 h40 gOpenGite
|
||||
Gui, Add, Button, x%StatusTextSecondRowXPos% y+%MarginSize% w270 h80 gTryFailedAgain, Try Failed Again
|
||||
|
||||
|
||||
/*Gui, Add, Button,x%MarginSize% w%WebsiteButtonWidths% h%ButtonHeights% Center, PocketNet
|
||||
Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %PocketNet%
|
||||
|
||||
*/
|
||||
Gui, Font, s%GUINormalFontSize%
|
||||
Gui, Font, Bold
|
||||
; gui, add, text, x%ErrorSummaryLogSplitLineXPos% y20 h200 0x11 ; 0x11 is a "line" ; refer to here: https://autohotkey.com/board/topic/50910-draw-line-gui/
|
||||
@@ -1027,53 +1022,6 @@ AddToTotalRunTime()
|
||||
|
||||
Return
|
||||
|
||||
ActivateParlerTab:
|
||||
DevModeMsgBox("activating")
|
||||
DevModeMsgBox(ParlerTabURL)
|
||||
; FindAndActivateTab(ParlerTabURL)
|
||||
|
||||
Return
|
||||
|
||||
|
||||
SendErrorLoggingThroughTelegram:
|
||||
Message = Uploading Errorlog to FDRBotTesting Telegram Server.
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
; ErrorLoggingFilePath := VideoFolderDir . "\" . "ErrorLogging.txt"
|
||||
; Msgbox % "ErrorLoggingFilePath: " ErrorLoggingFilePath
|
||||
|
||||
; Credentials to FDRBotTesting Channel
|
||||
ELTelegramBotToken=1422687468:AAEzdzkck5PhgOG687cEn1cChp5cJFodjVM
|
||||
ELTelegramBotChatID=-1001460795978
|
||||
|
||||
; DevModeMsgBox(ErrorLoggingFilePath)
|
||||
|
||||
Status := SendTelegramFile(ELTelegramBotToken, ELTelegramBotChatID, ErrorLoggingFilePath, caption := "" )
|
||||
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")
|
||||
|
||||
; msgbox, 4096, Error!, %Message%
|
||||
ToolTip
|
||||
Return
|
||||
}
|
||||
ToolTip
|
||||
Message = Errorlog was successfully uploaded to the FDRBotTesting Telegram Server.`nThank You!
|
||||
msgbox, 4096, Success!, %Message%
|
||||
|
||||
; Clipboard := ErrorLoggingFilePath
|
||||
; Message = %ErrorLoggingFilePath% `n`nwas copied to the clipboard for easy attachment
|
||||
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
; msgbox, 4096, Filepath Copied to Clipboard, %ErrorLoggingFilePath%`n`nwas copied to the clipboard for easy attachment.
|
||||
Return
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CopyErrorLoggingFilepath:
|
||||
; Msgbox % "ErrorLoggingFilePath: " ErrorLoggingFilePath
|
||||
@@ -1123,6 +1071,11 @@ Return
|
||||
;------------------------------------------------
|
||||
#include %A_ScriptDir%\Modules\Post-To-LinkedIn.ahk
|
||||
|
||||
; Tumblr
|
||||
;------------------------------------------------
|
||||
#include %A_ScriptDir%\Modules\Post-To-Tumblr.ahk
|
||||
|
||||
|
||||
; Minds
|
||||
;------------------------------------------------
|
||||
#include %A_ScriptDir%\Modules\Post-To-Minds.ahk
|
||||
|
||||
Submodule Lib/Freedomain-Posters-Shared-Functions updated: 6bf72336d0...4a1d2a5d9d
@@ -146,6 +146,27 @@ sleep, 500
|
||||
driver.FindElementByXPath(Xpath).SendKeys("`n`n")
|
||||
sleep, 500
|
||||
|
||||
if(InStr(PostBody, "http")){
|
||||
StrLengthOfPost := StrLen(PostBody)
|
||||
|
||||
SaveOrPostProgress(Message:="Body has hyperlink, Inputting text key by key",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||
|
||||
Loop % StrLengthOfPost{
|
||||
|
||||
Current_Char := SubStr(PostBody, A_index, 1)
|
||||
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=20,StringTextContent:=Current_Char)
|
||||
if(Status){
|
||||
Message = Failed to Input Text
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return
|
||||
}
|
||||
}
|
||||
}
|
||||
else, {
|
||||
SaveOrPostProgress(Message:="Body has no hyperlink, inputting entire text body into element.",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostBody)
|
||||
if(Status){
|
||||
Message = Failed to input Post Body
|
||||
@@ -153,6 +174,8 @@ if(Status){
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
; check if value was input
|
||||
js = return document.querySelector("trix-editor[role='textbox']").innerText
|
||||
|
||||
153
Modules/Post-To-Substack.ahk
Normal file
153
Modules/Post-To-Substack.ahk
Normal file
@@ -0,0 +1,153 @@
|
||||
|
||||
; -------------------------------Minds-------------------------------
|
||||
PostToSubstack:
|
||||
CurrentSite := "Substack"
|
||||
Message = Navigating to Post Creationg Page
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
|
||||
|
||||
IniRead, SubstackProfileURL, %SettingsIniFilepath%, SocialMediaPoster, SubstackProfileURL, %A_Space%
|
||||
if(SubstackProfileURL = ""){
|
||||
Message = SubstackProfileURL is blank. Please update Settings.ini under [SocialMediaPoster]`nSubstackProfileURL=https://PROFILENAME.substack.com/publish/home
|
||||
IniWrite,%A_Space%,%SettingsIniFilepath%, SocialMediaPoster, SubstackProfileURL
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
|
||||
URLAttempt := NavigateFromBaseURLTo(SubstackProfileURL)
|
||||
if(URLAttempt = "Failed")
|
||||
Return
|
||||
|
||||
Status := CheckCurrentTabForCurrentSite()
|
||||
if(Status){
|
||||
Return
|
||||
}
|
||||
|
||||
; Check Login Status
|
||||
; ------------------------------------------------
|
||||
Message = Checking Login Status
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip")
|
||||
|
||||
|
||||
; Check for New Post button at the top right of page
|
||||
Xpath = (//button[@id='trigger7'])[1]
|
||||
try ElementInnerText := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text
|
||||
if(!InStr(ElementInnerText, "New post")){
|
||||
Message = New post button not found. Please check login status. If already logged in, the xpath of the element might have changed.
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return
|
||||
}
|
||||
|
||||
; Start Text Post
|
||||
; ------------------------------------------------
|
||||
Message = Creating New Post
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
; click new post button
|
||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
if(status){
|
||||
Message = Failed to click New post button
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
; click new note button in popup menu
|
||||
Xpath = //div[contains(text(),'New note')]
|
||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
if(status){
|
||||
Message = Failed to click New note button
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
; Input Title and Text
|
||||
; ------------------------------------------------
|
||||
|
||||
; Input Text Box, this is awful and will probably break in the future, but works for now.
|
||||
; @todo: Figure out relative xpath, SelectorHub is not providing anything useful.
|
||||
Xpath = /html[1]/body[1]/div[4]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]
|
||||
|
||||
|
||||
try, CurrentText := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text
|
||||
if(strlen(CurrentText) > 1){
|
||||
Message = Exiting. Functionality to clear out previous failed posts is a WIP.
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody, ClearElement:=0)
|
||||
if(Status){
|
||||
Message = Failed to input Post Title/Body
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
|
||||
; Attach Image
|
||||
; ------------------------------------------------
|
||||
if(ImageAttachmentFilepath){
|
||||
Message = Attaching Image
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
Xpath = (//input[@accept='image/*,.heic'])[1]
|
||||
|
||||
; Attach image
|
||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath, ClearElement:=0)
|
||||
if(status){
|
||||
Message = Failed to attach image
|
||||
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
}
|
||||
|
||||
; driver.FindElementByXPath(Xpath).SendKeys(PostTitleAndBody)
|
||||
|
||||
|
||||
|
||||
|
||||
sleep, 1000
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Xpath = //button[normalize-space()='Post']
|
||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
if(status){
|
||||
Message = Failed to Click Post Now Button
|
||||
SaveOrPostProgress(Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
IniWrite, Successful, %StatusFileFilePath%, Status, %CurrentSite%
|
||||
AddToTotalPostsPostedCount()
|
||||
|
||||
PauseBetweenPosts()
|
||||
DevModeMsgBox("done!")
|
||||
|
||||
Message = Post Publish Successful
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
|
||||
|
||||
Return
|
||||
; -------------------------------/Minds-------------------------------
|
||||
@@ -60,7 +60,15 @@ if(status){
|
||||
Return
|
||||
}
|
||||
|
||||
|
||||
if(ImageAttachmentFilepath){
|
||||
; Click into space below the preview image so the "add photo" button shows up
|
||||
Xpath = (//div[@class='block-list-appender wp-block'])[1]
|
||||
try, driver.FindElementByXPath(Xpath).click()
|
||||
|
||||
; Xpath = (//button[@title='Add photo'])[1]
|
||||
; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||
|
||||
|
||||
; Click the Photo Icon on the next line down to attach an image
|
||||
Xpath = (//button[@title='Add photo'])[1]
|
||||
@@ -82,6 +90,17 @@ if(ImageAttachmentFilepath){
|
||||
|
||||
}
|
||||
|
||||
; Input Tags
|
||||
Xpath = (//textarea[@placeholder='#add tags to help people find your post'])[1]
|
||||
|
||||
try, driver.FindElementByXPath(Xpath).SendKeys(PostTags)
|
||||
try, driver.SendKeys(driver.Keys.Enter)
|
||||
|
||||
|
||||
|
||||
|
||||
sleep, 1000
|
||||
|
||||
|
||||
if (ConfirmBeforeSubmit && ConfirmBeforeSubmitMsgboxFunc() != true) {
|
||||
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
[Social-Media-Poster]
|
||||
Version=2.92
|
||||
Version=2.96
|
||||
|
||||
Reference in New Issue
Block a user