<config>

//////////////
//
//  Pulse Protection v1.0 by Pri (9th of October 2011)
//  This script requires Metis v2.82 & RoboMX v2.08
//  Please use Metis v2.82 for the smoothest experience: http://bit.ly/ldk6C3
//  Website: http://www.renmx.com
//  Forum: http://www.mxpulse.com/board
//
///////  COMMANDS
//
//  !PulseGeo On/Off - Turn the Geolocate feature on/off (Finds where users are based on IP) (Default: On)
//  !PulseHost On/Off - Turn the 'Currently Hosting' feature on/off (Displays rooms hosted by your users) (Default: On)
//  !PulseRooms - View all the rooms using the same Password as you
//
///////  SERVER SUPPORT
//
//  WCS, RCS, ZCS, RSWCS, and FXServer are all supported out of the box
//
//////////////

<usergroup name="Pulse_Admin_Users" case="0">
// This usergroup is only for your admins so that they can control some of the special commands.
// Those commands include !PulseGeo On/Off - !PulseRooms is open to all users
*  ®ÊN  Pri  *
</usergroup>

<OnEnter type="script" mode="thread">
// Clear variable "Private_IP_Detected" for a clean run
<out type="pop" extdata="Private_IP_Detected"/>
// Break if the IP is private (127.0.0.1, 192.168.x.x, 10.0.x.x and so on)
<out type="push" extdata="Joined_IP">:%IP%</out>
<out type="push" extdata="Private_IP_Detected" condition="==" lvalue="%IP%" rvalue="127.0.0.1">1</out>
<out type="push" extdata="Private_IP_Detected" condition="==" lvalue="%IP%" rvalue="0.0.0.0">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":169.254.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.16.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.17.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.18.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.19.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.20.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.21.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.22.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.23.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.24.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.25.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.26.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.27.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.28.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.29.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.30.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.31.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":192.168.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":10.">1</out>
<out type="break" condition="==" lvalue="%USERVAR[Private_IP_Detected]%" rvalue="1"></out>
// Check that the user has the correct version of Metis to run this script by quering server and checking for a file, if this file doesn't display right tell the user to update
<out type="push" extdata="Pulse_Metis_Check" condition="==" lvalue="%USERVAR[Pulse_Metis_Check]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/metis.check.ini" lvalue="l" rvalue="1"/></out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#You appear to be running an outdated version of Metis.</out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#You can download the latest one here#c63#: #c62#http://www.mxpulse.com/metis/Metis.r2x</out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#To install this file replace your old Metis.r2x file located in your script plugins folder</out>
<out type="break" condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849"></out>
// Check that the scripts folder and settings file has been setup. If it hasn't do it.
<out type="push" extdata="Pulse_Setup_Check"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Pulse.Protection.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Pulse_Setup_Check$" rvalue="" type="exec" extdata="1">cmd.exe /c MD C:\Pri.Script.Dependencies\Pulse.Protection</out>
<out condition="==" lvalue="$Pulse_Setup_Check$" rvalue="" type="sleep" extdata="3000"></out>
<out condition="==" lvalue="$Pulse_Setup_Check$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Pulse.Protection.ini" mode="t">1</out>
// Check if the Geolocate file has been made, if it hasnt make it.
<out type="push" extdata="Pulse_Plus_Geo_Check"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Geolocate.Setting.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Pulse_Plus_Geo_Check$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Geolocate.Setting.ini" mode="t">1</out>
// Check if the Host Reporting file has been made, if it hasnt make it and then tell the admins about it too
<out type="push" extdata="Pulse_Plus_Host_Check"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Currently.Hosting.Display.Setting.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Pulse_Plus_Host_Check$" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#This version of Pulse Protection includes Host reporting #c63#(#c62#Rooms being hosted by users#c63#)#c9# If you don't like this feature you can turn it off by typing #c4#!PulseHost Off #c9#But remember you need to edit the Pulse Protection XML file to list your name in the usergroup before you can use that command.</out>
<out condition="==" lvalue="$Pulse_Plus_Host_Check$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Currently.Hosting.Display.Setting.ini" mode="t">1</out>
// Download some special characters required for this to function (Metis by itself doesn't allow these characters inside the code so they have to be loaded as varibles)
<out type="push" extdata="Special_1" condition="==" lvalue="%USERVAR[Special_1]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/metis.assistant.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Special_3" condition="==" lvalue="%USERVAR[Special_3]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/metis.assistant.txt" lvalue="l" rvalue="3"/></out>
// If the IP supplied to the bot is blank then load in the Access Level reminder counter (should be blank at first, then goes up to 3+)
<out type="push" extdata="ReminderCount" condition="==" lvalue="%IP%" rvalue=""><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Bot.Access.Level.Reminder.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="ReminderCount" condition="==" lvalue="%IP%" rvalue=""><operator type="+" lvalue="$ReminderCount$" rvalue="1"/></out>
<out condition="==" lvalue="%IP%" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Bot.Access.Level.Reminder.ini" mode="t">$ReminderCount$</out>
// Break if the IP is blank then tell the Admins that they need to give their Bot high enough access to see IP Addresses
<out type="goto" extdata="3" condition=">" lvalue="$ReminderCount$" rvalue="3"></out> 
<out condition="==" lvalue="%IP%" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#Your bot doesn't have a high enough access level to see the IP's of people who enter your room, Try logging it in as Admin or Host to correct this, or make your bot its own password with the necessary access level</out>
<out condition="==" lvalue="%IP%" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#Reminder #c62#%RANDOMNUM[ReminderCount]%#c9# of 3</out>
<out type="break" condition="==" lvalue="%IP%" rvalue=""></out>
// Check for an updated version of this script
<out type="push" extdata="Version_Info">v1.0</out>
<out type="pop" extdata="Version_Release_Message"/>
<out type="push" extdata="Version_Check_Date"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Version.Check.Date.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Version_Info" condition="!=" lvalue="%USERVAR[Version_Check_Date]%" rvalue="%DATE%"><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/version.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Version_Release_Message" condition="!=" lvalue="%USERVAR[Version_Info]%" rvalue="v1.0"><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/version.ini" lvalue="l" rvalue="2"/></out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#%USERVAR[Version_Release_Message]%</out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Version.Check.Date.txt" mode="t">%DATE%\n%USERVAR[Version_Info]%</out>
// Pulse Protection now requires version 2.82 of Metis, if the user is not using this version tell the admins and break
<out condition="!=" lvalue="%VERSION%" rvalue="2.82">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#This script requires Metis v2.82, please upgrade from v%VERSION%#c63#: #c62#http://bit.ly/ldk6C3</out>
<out type="break" condition="!=" lvalue="%VERSION%" rvalue="2.82"></out>
// Perform a check to see if the Geolocation system is operational, if it isn't block the Geolocation queries until the bot is rebooted
<out type="push" extdata="Pulse_Geolocation_Server_Status" condition="==" lvalue="%USERVAR[Pulse_Geolocation_Server_Status]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/geolocation.server.status.ini" lvalue="l" rvalue="1"/></out>
// Perform a check to see if the IP -> Roomname API is operational, if it isn't block the Roomname queries until the bot is rebooted
<out type="push" extdata="Pulse_roomname_api_Status" condition="==" lvalue="%USERVAR[Pulse_roomname_api_Status]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/roomname.api.status.ini" lvalue="l" rvalue="1"/></out>
// Check if a custom Password has been set by the admins of the room for use with Pulse Protections authentication system
<out type="push" extdata="Pulse_Prot_Password"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.password.ini" lvalue="l" rvalue="1"/></out>
// If no password was found use the default
<out type="push" extdata="Pass_generator" condition="==" lvalue="$Pulse_Prot_Password$" rvalue="">%RANDOMNUM[251]%%RANDOMNUM[252]%%RANDOMNUM[253]%%RANDOMNUM[254]%%RANDOMNUM[255]%</out>
// If a random password was generated let the user know what it is
<out condition="==" lvalue="$Pulse_Prot_Password$" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#A Random Password has been generated for the data you supply to the Server</out>
<out condition="==" lvalue="$Pulse_Prot_Password$" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#Generated Password#c63#: #c62#%USERVAR[Pass_generator]%</out>
<out condition="==" lvalue="$Pulse_Prot_Password$" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#Saved in#c63#: #c62#C:\Pri.Script.Dependencies\Pulse.Protection\.password.ini</out>
<out condition="==" lvalue="$Pulse_Prot_Password$" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#You and your friends can use the same password to share the same database</out>
// Save the Random Password (But of course only if a password isn't present already)
<out condition="==" lvalue="$Pulse_Prot_Password$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.password.ini" mode="t">%USERVAR[Pass_generator]%\nWhen making a password you can use uppercase and lowercase letters and also numbers, for example H1b0A9sD8mSd8 is an acceptible password.\nTo change your password simply erase the code at the top of this file, change it to something else, and save it.</out>
<out type="push" extdata="Pulse_Prot_Password" condition="==" lvalue="$Pulse_Prot_Password$" rvalue="">%USERVAR[Pass_generator]%</out>
// Sometimes the creation of the Folder for the Setup Check is to slow causing the install check file to not save, so let's just re-attempt that if this is a first time install
<out condition="==" lvalue="$Pulse_Setup_Check$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Pulse.Protection.ini" mode="t">1</out>
// Remove colour codes from username
<out type="push" extdata="Cleaned_Name">%NAME%</out>
<out type="push" extdata="Cleaned_Name"><operator type="strrem" lvalue="%USERVAR[Cleaned_Name]%" rvalue="#c?#"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrem" lvalue="%USERVAR[Cleaned_Name]%" rvalue="#c!#"/></out>
<out type="push" extdata="Cleaned_Name_LINE">0</out>
<out type="push" extdata="Cleaned_Name_LINE"><operator type="+" lvalue="$Cleaned_Name_LINE$" rvalue="1"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrem" lvalue="%USERVAR[Cleaned_Name]%" rvalue="#c%USERVAR[Cleaned_Name_LINE]%#"/></out>
<out type="goto" extdata="3" condition="==" lvalue="$Cleaned_Name_LINE$" rvalue="255"></out> 
<out type="goto" extdata="2" condition="!?" lvalue="%USERVAR[Cleaned_Name]%" rvalue="#c"></out> 
<out type="goto" extdata="-4" condition="?" lvalue="%USERVAR[Cleaned_Name]%" rvalue="#c"></out>
// Replace some symbols from the name that just don't work in a httpget request to the web server, and other characters we just don't want saved
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="%USERVAR[Special_1]%lowast;" rvalue="[star]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="%USERVAR[Special_1]%" rvalue="[and]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="\" rvalue="[bslash]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="/" rvalue="[fslash]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="%USERVAR[Special_3]%" rvalue="[dollar]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="#" rvalue="[hash]"/></out>
// Replace some symbols from the Roomname that don't work in httpget requests
<out type="push" extdata="Cleaned_Room">%ROOMNAME%</out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="%USERVAR[Special_1]%lowast;" rvalue="[star]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="%USERVAR[Special_1]%" rvalue="[and]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="\" rvalue="[bslash]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="/" rvalue="[fslash]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="%USERVAR[Special_3]%" rvalue="[dollar]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="#" rvalue="[hash]"/></out>
// Check if the user wants to use Pulse with the Geolocating API or just Pulse on its own, default is with Geolocate
<out type="push" extdata="Pulse_Plus_Geo_Check"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Geolocate.Setting.ini" lvalue="l" rvalue="1"/></out>
// If for some reason the geolocate setting is missing just consider it set to 1 and also save this setting
<out condition="==" lvalue="%USERVAR[Pulse_Plus_Geo_Check]%" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Geolocate.Setting.ini" mode="t">1</out>
<out type="push" extdata="Pulse_Plus_Geo_Check" condition="==" lvalue="%USERVAR[Pulse_Plus_Geo_Check]%" rvalue="">1</out>
// If the Geolocation server is down then default to non-Geo query
<out type="push" extdata="Pulse_Plus_Geo_Check" condition="==" lvalue="%USERVAR[Pulse_Geolocation_Server_Status]%" rvalue="0">0</out>
// Create a query for checking what usernames this IP is matched to and query mxpulse
<out type="push" extdata="Result" condition="==" lvalue="%USERVAR[Pulse_Plus_Geo_Check]%" rvalue="1"><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/v06/Pulse.With.Geo.php?ip=%IP%&amp;name=%USERVAR[Cleaned_Name]%&amp;pass=%USERVAR[Pulse_Prot_Password]%&amp;room=%USERVAR[Cleaned_Room]%" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Result" condition="==" lvalue="%USERVAR[Pulse_Plus_Geo_Check]%" rvalue="0"><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/v06/?ip=%IP%&amp;name=%USERVAR[Cleaned_Name]%&amp;pass=%USERVAR[Pulse_Prot_Password]%&amp;room=%USERVAR[Cleaned_Room]%" lvalue="l" rvalue="1"/></out>
// If the users current name is present remove it, unless using Geolocate in which case only remove the name if they have other aliases
<out type="push" extdata="Result" condition="==" lvalue="%USERVAR[Pulse_Plus_Geo_Check]%" rvalue="0"><operator type="strrem" lvalue="%USERVAR[Result]%" rvalue="%USERVAR[Cleaned_Name]%[:@:]"/></out>
<out type="push" extdata="Geo_Filtered_Result" condition="==" lvalue="%USERVAR[Pulse_Plus_Geo_Check]%" rvalue="1"><operator type="strrem" lvalue="%USERVAR[Result]%" rvalue="%USERVAR[Cleaned_Name]%[:@:]"/></out>
<out type="push" extdata="Result"><operator type="strrem" lvalue="%USERVAR[Result]%" rvalue="%USERVAR[Cleaned_Name]%[:@:]"/></out>
// If no [:@:] is found insert it in to the end of the Result variable, unless Geolocate is off in which case skip this
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Pulse_Plus_Geo_Check]%" rvalue="0"></out> 
<out type="push" extdata="Result" condition="!?" lvalue="%USERVAR[Result]%" rvalue="[:@:]">%USERVAR[Result]%%USERVAR[Cleaned_Name]%[:@:]</out>
// Work out if the user has multiple aliases or not and format the output to reflect that by using 'Only Known as' or 'Also Known as'
<out type="push" extdata="Result" condition="?" lvalue="%USERVAR[Result]%" rvalue="[;@;]%USERVAR[Cleaned_Name]%[:@:]"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[;@;]" rvalue="#c9# Only known as#c63#: #c62#"/></out>
<out type="push" extdata="Result" condition="?" lvalue="%USERVAR[Result]%" rvalue="[;@;]%USERVAR[Cleaned_Name]%[:@:]"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue=", -#c9# Only" rvalue="#c9# Only"/></out>
<out type="push" extdata="Result" condition="!?" lvalue="%USERVAR[Result]%" rvalue="[;@;]%USERVAR[Cleaned_Name]%[:@:]"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[;@;]" rvalue="#c9# Also known as#c63#: #c62#"/></out>
<out type="push" extdata="Result" condition="!?" lvalue="%USERVAR[Result]%" rvalue="[;@;]%USERVAR[Cleaned_Name]%[:@:]"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue=", -#c9# Also" rvalue="#c9# Also"/></out>
// Make the output a little nicer to read / Put some symbols back that were removed for HTTPGET to server
<out type="push" extdata="Result"><operator type="strrem" lvalue="%USERVAR[Result]%" rvalue="\"/></out>
<out type="push" extdata="Result"><operator type="strrem" lvalue="%USERVAR[Result]%" rvalue="/"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[:@:]" rvalue="#c63#,#c62# "/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[star]" rvalue="%USERVAR[Special_1]%lowast;"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[and]" rvalue="%USERVAR[Special_1]%"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[bslash]" rvalue="\"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[fslash]" rvalue="/"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[dollar]" rvalue="%USERVAR[Special_3]%"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[hash]" rvalue="#"/></out>
// Pop Geo_Filtered_Result for clean run next time
<out type="pop" extdata="Geo_Filtered_Result"/>
// Skip the default output if the user has chosen Geolocate (default behavior) to be on
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Pulse_Plus_Geo_Check]%" rvalue="1"></out> 
// Output to the room the users aliases unless they don't have any
<out condition="!=" lvalue="%USERVAR[Result]%" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#Also known as#c63#: #c62#%USERVAR[Result]%</out>
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Pulse_Plus_Geo_Check]%" rvalue="0"></out>
<out condition="!=" lvalue="%USERVAR[Result]%" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#From#c63#: #c62#%USERVAR[Result]%</out>
// Check if the user has the 'Currently Hosting' feature on or off (Default is on)
<out type="push" extdata="Pulse_Currently_Hosting_Setting"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Currently.Hosting.Display.Setting.ini" lvalue="l" rvalue="1"/></out>
// If the IP -> Roomname API is not functional then break here
<out type="push" extdata="Pulse_Currently_Hosting_Setting" condition="==" lvalue="%USERVAR[Pulse_roomname_api_Status]%" rvalue="0">0</out>
<out type="break" condition="==" lvalue="$Pulse_Currently_Hosting_Setting$" rvalue="0"></out>
// Lets see if this users IP is currently hosting any rooms and if they are, show those rooms in Opmsg
<out type="push" extdata="Web_Result"><operator type="readweb" nvalue="http://winmxunlimited.net/utilities/api/pulse/index.php?ip=%IP%" lvalue="l" rvalue="1"/></out>
// Break the script here if the Web_Result is blank
<out type="break" condition="==" lvalue="%USERVAR[Web_Result]%" rvalue=""></out>
// Save the output to a file cache
<out type="push" extdata="Web_Result"><operator type="strrep" nvalue="%USERVAR[Web_Result]%" lvalue="[:@:]" rvalue="\n"/></out>
<out type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Web.Cache.txt" mode="t">%USERVAR[Web_Result]%</out>
// Read back in the cache to formulate the room message
<out type="push" extdata="Pulse_Server_Version"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Web.Cache.txt" lvalue="l" rvalue="5"/></out>
<out type="push" extdata="Pulse_Room_Name"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Web.Cache.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Pulse_User_Current"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Web.Cache.txt" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="Pulse_User_Max"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.Web.Cache.txt" lvalue="l" rvalue="3"/></out>
// If the server being reported isn't blank then modify the UI to accept server version
<out type="push" extdata="Pulse_Server_Version" condition="!=" lvalue="%USERVAR[Pulse_Server_Version]%" rvalue="">%USERVAR[Pulse_Server_Version]%, #c9#</out>
// Break if the Cache is blank
<out type="break" condition="==" lvalue="$Pulse_Room_Name$" rvalue=""></out>
// Combine the data in to a single output and display it
<out>/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#Currently Hosting#c63#: #c62#%USERVAR[Pulse_Room_Name]% #c63#(#c9#%USERVAR[Pulse_Server_Version]%%USERVAR[Pulse_User_Current]%/%USERVAR[Pulse_User_Max]%#c63#)</out>
// Clear the Cache just incase something goes wrong as we don't want the same cache being used for multiple users under any circumstances
<out type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Web.Cache.txt" mode="t"></out>
</OnEnter>

<command type="script">
<in>!pulserooms</in>
// Check that the command was used at the beginning of a sentence
<out type="push" extdata="req">%TRIGGER%</out>
<out type="push" extdata="req"><operator type="strleft" lvalue="$req$" rvalue="11"/></out>
<out type="break" condition="!_?" lvalue="$req$" rvalue="!pulserooms"></out>
// Load in the users password, if they don't have a password yet tell them they need to set one
<out type="push" extdata="Pulse_Prot_Password"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\.password.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="%USERVAR[Pulse_Prot_Password]%" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#You have not yet set a password for Pulse Protection to use. Have a user enter your room to have one created automatically.</out>
<out type="break" condition="==" lvalue="%USERVAR[Pulse_Prot_Password]%" rvalue=""></out>
// Create a query including this rooms Pulse Password to retrieve a list of rooms using the same password back from the server
<out type="push" extdata="Result"><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/v06/Syncing.Rooms.php?pass=%USERVAR[Pulse_Prot_Password]%" lvalue="l" rvalue="1"/></out>
// If the result is blank then say an error occured
<out condition="==" lvalue="%USERVAR[Result]%" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#An error occured, please try again later.</out>
<out type="break" condition="==" lvalue="%USERVAR[Result]%" rvalue=""></out>
// Make the output a little nicer to read / Put some symbols back that were removed for HTTPGET to server
<out type="push" extdata="Result"><operator type="strrem" lvalue="%USERVAR[Result]%" rvalue="\"/></out>
<out type="push" extdata="Result"><operator type="strrem" lvalue="%USERVAR[Result]%" rvalue="/"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[:@:]" rvalue="\n"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[star]" rvalue="%USERVAR[Special_1]%lowast;"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[and]" rvalue="%USERVAR[Special_1]%"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[bslash]" rvalue="\"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[fslash]" rvalue="/"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[dollar]" rvalue="%USERVAR[Special_3]%"/></out>
<out type="push" extdata="Result"><operator type="strrep" nvalue="%USERVAR[Result]%" lvalue="[hash]" rvalue="#"/></out>
// Write this answer to a temporary cache in the Pulse folder so we can split the results up and read them back
<out type="file" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\Syncing.Rooms.Cache.txt" mode="t">%USERVAR[Result]%</out>
// Tell the user the listing is going to start
<out>/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#Rooms using the same Pulse password as you#c63#:</out>
// Now read back the cache one line at a time
<out type="push" extdata="LINECOUNT">0</out>
<out type="push" extdata="LINECOUNT"><operator type="+" lvalue="$LINECOUNT$" rvalue="1"/></out>
<out type="push" extdata="LINERESULT"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Pulse.Protection\Syncing.Rooms.Cache.txt" lvalue="l" rvalue="$LINECOUNT$"/></out>
<out condition="!=" lvalue="%USERVAR[LINERESULT]%" rvalue="">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c62#%USERVAR[LINERESULT]%</out>
<out type="goto" extdata="-3" condition="!=" lvalue="" rvalue="%USERVAR[LINERESULT]%"></out>
// Tell the user the listing is complete
<out>/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#Listing complete.</out>
</command>

<command type="script" usergroup="Pulse_Admin_Users">
<in>!PulseGeo on</in>
<in>!PulseGeo off</in>
// Check if the command was typed at the start of a sentence, if not break
<out type="push" extdata="req">%TRIGGER%</out>
<out type="push" extdata="req"><operator type="strleft" lvalue="$req$" rvalue="10"/></out>
<out type="break" condition="!_?" lvalue="$req$" rvalue="!pulsegeo "></out>
// Process which command the user typed
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="on" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Geolocate.Setting.ini">1</out>
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="off" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Geolocate.Setting.ini">0</out>
// Output message to Opmsg explaining which setting was chosen and what it does
<out condition="_?" lvalue="%TRIGGER%" rvalue="off">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#The #c63#"#c1#Gelocation Feature#c63#"#c9# has been turned #c8#OFF</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="off">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c62#When this Setting is Off the Bot will Not display a users location when they enter your room</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#The #c63#"#c1#Gelocation Feature#c63#"#c9# has been turned #c4#ON</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c62#When this Setting is On the Bot will display users locations as they enter your room</out>
</command>

<command type="script" usergroup="Pulse_Admin_Users">
<in>!Pulsehost on</in>
<in>!Pulsehost off</in>
// Check if the command was typed at the start of a sentence, if not break
<out type="push" extdata="req">%TRIGGER%</out>
<out type="push" extdata="req"><operator type="strleft" lvalue="$req$" rvalue="11"/></out>
<out type="break" condition="!_?" lvalue="$req$" rvalue="!pulsehost "></out>
// Process which command the user typed
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="on" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Currently.Hosting.Display.Setting.ini">1</out>
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="off" extdata="C:\Pri.Script.Dependencies\Pulse.Protection\.Currently.Hosting.Display.Setting.ini">0</out>
// Output message to Opmsg explaining which setting was chosen and what it does
<out condition="_?" lvalue="%TRIGGER%" rvalue="off">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#The #c63#"#c1#Currently Hosting Feature#c63#"#c9# has been turned #c8#OFF</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="off">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c62#When this Setting is Off the Bot will Not display rooms that users are hosting</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c9#The #c63#"#c1#Currently Hosting Feature#c63#"#c9# has been turned #c4#ON</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Pulse #c63#(#c62#v1.0#c63#): #c62#When this Setting is On the Bot will display the rooms that users are hosting</out>
</command>

</config>