Skip to content

Instantly share code, notes, and snippets.

@Rudokhvist
Last active August 29, 2022 01:27
Show Gist options
  • Save Rudokhvist/e6ab9220a650178e1c4c14e499b52ab2 to your computer and use it in GitHub Desktop.
Save Rudokhvist/e6ab9220a650178e1c4c14e499b52ab2 to your computer and use it in GitHub Desktop.
create multiple bot configs from a template and a file with login:password pairs. Don't use `:` in passwords or logins, OR ELSE.
Set objPassFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(".\passwords.txt",1)
Set objTmplFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(".\template.json",1)
strTmplText = objTmplFile.ReadAll()
objTmplFile.Close
Set objTmplFile = Nothing
Dim strLine
botnum = 1
digitnum = 3
do while not objPassFile.AtEndOfStream
strLine = objPassFile.ReadLine()
filenum = CStr (botnum)
Dim num : num = 0
If digitnum > Len(filenum) Then num = digitnum - Len(filenum)
filenum = String(num, "0") & filenum
filename = ".\bot" & filenum & ".json"
Set objFileToWrite = CreateObject("Scripting.FileSystemObject").OpenTextFile(filename,2,true)
credentials = Split (strLine,":")
strOutText = Replace (strTmplText,"%username%","""" & credentials(0) & """" )
strOutText = Replace (strOutText,"%password%","""" & credentials(1) & """")
objFileToWrite.WriteLine(strOutText)
objFileToWrite.Close
Set objFileToWrite = Nothing
botnum = botnum +1
loop
objPassFile.Close
Set objPassFile = Nothing
MsgBox ("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment