-
Notifications
You must be signed in to change notification settings - Fork 103
Running Chatterbot on Windows
Written by Alex Gray - @ImJustFelix
Running bots on Windows is a pain; as first, you have to type the command "Ruby" and then the name of the file holding the robot code followed by ".rb" which equates to "Ruby theeinsteinbot.rb", which in the end, only runs ONE robot, after typing a short line to execute the code.
I had written two short codes to help myself running these robots, both of which are written using Batch files (.BAT) and 2 shortcuts for both code files. Both are short and easy to manipulate to your computers environment and your twitter robot codes. I will also explain each line, so you know what’s actually happening, and not just copying and pasting, and learning nothing... I’ve done this by using "REM" which allows you to comment on the code as you write (not case sensitive).
REM @echo off allows you to execute the code.
@echo off
REM changes the colour of the text; I did this, just because I wanted to
color 2
REM the screen is cleared of all current code
cls
REM set the path of where ruby is – mine is in ruby on rails
set PATH_TO_RUBY=C:\RubyOnRails\Ruby1.9.2\bin
REM set what the ruby application is actually called 9 times out of ten, it is "ruby.exe"
set RUBY=%PATH_TO_RUBY%\ruby.exe
REM set the path for where your scripts are
set PATH_TO_SCRIPTS=C:\RubyOnRails\Ruby1.9.2\bin
REM you can use "%RUBY% %PATH_TO_SCRIPTS%\" plus the name of the file and file extension to execute the twitter robot code, this can be done multiple times, as I’ve done 3 here.
%RUBY% %PATH_TO_SCRIPTS%\botname.rb
%RUBY% %PATH_TO_SCRIPTS%\otherbotname.rb
%RUBY% %PATH_TO_SCRIPTS%\thirdbotname.rb
REM exit the code
Exit
The second script allows the first script to loop and is pretty straight forward in implementing it. Again, below is the script, with "REM" used to signify my comments in the code.
REM @echo off allows you to execute the code.
@echo off
REM changes the colour of the text; I did this, just because I wanted to
color 2
REM the screen is cleared of all current code
Cls
REM Start the loop here
:ScriptLoop
REM pause the program for 1800 seconds (30 minutes)
TIMEOUT /T 1800
REM call the SHORTCUT to the first script
Call MassScriptRun.lnk
REM go back to the start of the loop
GoTo ScriptLoop
To allow the codes to work properly, you need to save them as "MassScriptRun.BAT" and "ScriptLoop.BAT" and also creating shortcuts for both the files, saving the "ScriptLoop.lnk" shortcut to the desktop so you can run the loop file whenever you want, without going through all the folders to get to it. This is the only file that should leave the folder containing your twitter robot codes, and the 2 BAT files.
To make the 2 files run in the background you will need to open the properties of both shortcuts, select the shortcut tab, and set the "Run:" as minimized, so it doesn’t interfere with your other work you may be doing.