From 7e8830b7d078bd2ac3d5ff5a7dc64c7e3a863cd2 Mon Sep 17 00:00:00 2001 From: Yuriy Date: Thu, 4 Jul 2024 00:23:05 -0400 Subject: [PATCH] Script to automatically compile and create new release, icon rename --- Assets/{FreedomainSMP.ico => Icon.ico} | Bin Compile and Release.ahk | 155 ++++++++++++++++++++++++ Freedomain Social Media Poster.ahk | 123 ++++++------------- Lib/Freedomain-Posters-Shared-Functions | 2 +- Version.ini | 2 +- 5 files changed, 195 insertions(+), 87 deletions(-) rename Assets/{FreedomainSMP.ico => Icon.ico} (100%) create mode 100644 Compile and Release.ahk diff --git a/Assets/FreedomainSMP.ico b/Assets/Icon.ico similarity index 100% rename from Assets/FreedomainSMP.ico rename to Assets/Icon.ico diff --git a/Compile and Release.ahk b/Compile and Release.ahk new file mode 100644 index 0000000..21d3420 --- /dev/null +++ b/Compile and Release.ahk @@ -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% +} \ No newline at end of file diff --git a/Freedomain Social Media Poster.ahk b/Freedomain Social Media Poster.ahk index 07e7a6a..d982750 100644 --- a/Freedomain Social Media Poster.ahk +++ b/Freedomain Social Media Poster.ahk @@ -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 diff --git a/Lib/Freedomain-Posters-Shared-Functions b/Lib/Freedomain-Posters-Shared-Functions index 6bf7233..4a1d2a5 160000 --- a/Lib/Freedomain-Posters-Shared-Functions +++ b/Lib/Freedomain-Posters-Shared-Functions @@ -1 +1 @@ -Subproject commit 6bf72336d0af0aa57064fc40c267677bb27577f3 +Subproject commit 4a1d2a5d9d95d06567e84f4128f02b1a233d53df diff --git a/Version.ini b/Version.ini index 1323259..38932e7 100644 --- a/Version.ini +++ b/Version.ini @@ -1,2 +1,2 @@ [Social-Media-Poster] -Version=2.92 +Version=2.95