<config>


//////////////
//
//  Proxy Blocker v1.6.4 by Pri (4th of July 2015)
//  This script requires Metis v2.82 or higher & RoboMX v2.08 http://bit.ly/ldk6C3
//  Website: http://www.renmx.com
//  Forum: http://www.mxpulse.com/board
//
///////  COMMANDS
//
//  !Download - Forcibly check for recent Proxy Servers to Ban that were used in other rooms
//  !Proxy [IP Address] - Check if an IP Address is a known Proxy Server or not
//  !ProxyPardon [IP Address] - Allows you to whitelist an IP to allow them to bypass the Proxy Blocker when they enter
//  !Proxy Status - Check the status of the Proxy Blocker and its API's
//  !Proxy Verbose On/Off - Allow the script to notify you when a user who enters your room is NOT using a Proxy Server (Default is Off)
//  !ProxyLockdown On/Off - Allow the script to lock down your room when a large proxy spam attack is detected inside your room (Default is Off)
//
///////  SERVER SUPPORT
//
//  WCS, RCS, ZCS, RSWCS, and FXServer are all supported out of the box
//  ZCS support is limited, WCS, RSWCS or FXServe are recommended.
//
//////////////


<OnEnter type="script">
// Clear some variables for a clean run
<out type="pop" extdata="Proxy_UI_Result"/>
<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>
// Break here if a Private IP Was detected
<out type="break" condition="==" lvalue="%USERVAR[Private_IP_Detected]%" rvalue="1"></out>
// Check that the bot is running a version of Metis that can make web queries
<out type="push" extdata="Metis_Check" condition="!=" lvalue="%USERVAR[Metis_Check]%" rvalue="6042117849"><operator type="readweb" nvalue="http://metis.mxpulse.com/metis.check.ini" lvalue="l" rvalue="1"/></out>
<out type="break" condition="?" lvalue="%USERVAR[Metis_Check]%" rvalue="Error: "></out>
<out condition="!=" lvalue="$Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#You appear to be running an outdated version of Metis.</out>
<out condition="!=" lvalue="$Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#You can download the latest one here#c63#: #c62#http://bit.ly/ldk6C3</out>
<out condition="!=" lvalue="$Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#To install this file replace your old Metis.r2x file located in your script plugins folder</out>
<out type="break" condition="!=" lvalue="$Metis_Check$" rvalue="6042117849"></out>
// Perform an online check to see if this version of Metis is supported by this script or not (If you're making your own Metis versions and know yours are compatible, contact me and I will add your versions to the compatability check)
<out type="push" extdata="Prox_Script_Compatability_Check" condition="==" lvalue="%USERVAR[Prox_Script_Compatability_Check]%" rvalue=""><operator type="readweb" nvalue="http://metis.mxpulse.com/script.compatibility.ini" lvalue="l" rvalue="1"/></out>
// The proxy blocker now requires version 2.82 of Metis or higher, if the user is not using this version or better tell the admins and break
<out condition="!?" lvalue="%USERVAR[Prox_Script_Compatability_Check]%" rvalue="%VERSION%">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#This script requires Metis v2.82 minimum, please upgrade from v%VERSION%#c63#: #c62#http://bit.ly/ldk6C3</out>
<out type="break" condition="!?" lvalue="%USERVAR[Prox_Script_Compatability_Check]%" rvalue="%VERSION%"></out>
// Check that the scripts folder and settings file has been setup. If it hasn't do it.
<out type="push" extdata="Prox_Setup_Check"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.setup.check.ini" lvalue="l" rvalue="1"/></out>
<out condition="!=" lvalue="$Prox_Setup_Check$" rvalue="2" type="exec" extdata="1">cmd.exe /c MD C:\Pri.Script.Dependencies\Proxy.Blocker\Cache</out>
<out condition="!=" lvalue="$Prox_Setup_Check$" rvalue="2" type="sleep" extdata="3000"></out>
<out condition="!=" lvalue="$Prox_Setup_Check$" rvalue="2" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.setup.check.ini" mode="t">2\nv1.6.4</out>
// Create a Whitelist File if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="Whitelist_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c4#Whitelist Feature#c9#:</out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#A Whitelist file has been created here#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini</out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#You may fill this file with Proxy IP's or Usernames of the people you trust to use Proxy Servers</out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" mode="t">You can place Proxy Server IP's OR Usernames in this file, one entry per line, unlimited size, Please do not delete this line explaining how to use the file!\n</out>
// Create an 'Exile to x Room' file if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="Exileroom_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.exile.room.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Exileroom_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c4#Exile Non-Proxies Feature#c9#:</out>
<out condition="==" lvalue="$Exileroom_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#An Exile File has been created here#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.exile.room.ini</out>
<out condition="==" lvalue="$Exileroom_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#You can put your main room name here for the Proxy Blocker to exile users to it #c63#(#c62#Once Verified#c63#)</out>
<out condition="==" lvalue="$Exileroom_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#If you do not need this feature simply leave the file as-is and users will not be exiled anywhere</out>
<out condition="==" lvalue="$Exileroom_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.exile.room.ini" mode="t">Enter the name of your room on the line directly below this one, Make sure it's the correct address. DO NOT DELETE THIS LINE OR BAD THINGS WILL HAPPEN!\n</out>
// Create a 'Force Login Password' file if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="ForceLoginPass_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.forcelogin.password.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$ForceLoginPass_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c4#Force Login Non-Proxies Feature#c9#:</out>
<out condition="==" lvalue="$ForceLoginPass_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#A Force Login Password File has been created here#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.forcelogin.password.ini</out>
<out condition="==" lvalue="$ForceLoginPass_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#You can put a password here for the Proxy Blocker to log users in with #c63#(#c62#Once Verified#c63#)</out>
<out condition="==" lvalue="$ForceLoginPass_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#If you do not need this feature simply leave the file as-is and users will not be logged in. The command that the bot uses for this is /forcelogin so make sure your server supports this command. FXServe, WCS and RSWCS support it.</out>
<out condition="==" lvalue="$ForceLoginPass_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.forcelogin.password.ini" mode="t">Enter your password on the line directly below this one to have them logged in with it after they enter your room. DO NOT DELETE THIS LINE OR BAD THINGS WILL HAPPEN!\n</out>
// Create the Spam Lockdown settings file if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="Lockdown_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.setting.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Lockdown_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c4#Lockdown Feature#c9#:</out>
<out condition="==" lvalue="$Lockdown_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#This version of Proxy Blocker supports a "Lockdown" feature - It is OFF by default but you can activate it by typing #c4#!ProxyLockdown On</out>
<out condition="==" lvalue="$Lockdown_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#When this feature is active the Proxy Blocker is able to stop any and all users from entering your room for up to a maximum of 1 hour when a large proxy attack against your room is detected</out>
<out condition="==" lvalue="$Lockdown_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.setting.ini" mode="t">0\n</out>
// Download anti-proxy setup data from the MXPulse API
<out type="push" extdata="PBS_Proxy_API_URL" condition="==" lvalue="%USERVAR[PBS_Proxy_API_URL]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="PBS_MXPulse_API_Status" condition="==" lvalue="%USERVAR[PBS_MXPulse_API_Status]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="PBS_MXPulse_PreEmptiveBan_Status" condition="==" lvalue="%USERVAR[PBS_MXPulse_PreEmptiveBan_Status]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="PBS_Local_Script_Cache" condition="==" lvalue="%USERVAR[PBS_Local_Script_Cache]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php" lvalue="l" rvalue="1"/></out>
// Verify that the Proxy_API_URL isn't blank, if it is blank, break as the script won't work without a querying API
<out type="break" condition="==" lvalue="%USERVAR[PBS_Proxy_API_URL]%" rvalue=""></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\Proxy.Blocker\.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\Proxy.Blocker\.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#Proxy Blocker #c63#(#c62#v1.6.4#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#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#Reminder #c62#%USERVAR[ReminderCount]%#c9# of 3</out>
<out type="break" condition="==" lvalue="%IP%" rvalue=""></out>
// Sometimes the creation of the Folder for the Setup Check is too 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="$Prox_Setup_Check$" rvalue="2" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.setup.check.ini" mode="t">2\nv1.6.4</out>
// Download a character for use in the Roomname httpget request
<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>
// Get the roomname, clean it up and add it to the proxy request
<out type="push" extdata="Cleaned_Room">%ROOMNAME%</out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="&amp;lowast;" rvalue="[star]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="&amp;" 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>
// Reference the Whitelist file incase this user has been given permission to use a Proxy Server in this room
// The whitelist checks for both a designated Proxy Server IP Address and the users Username from this file
<out type="push" extdata="Proxy_Permission">0</out>
<out type="push" extdata="Whitelist_Line">0</out>
<out type="push" extdata="Whitelist_Line"><operator type="+" lvalue="$Whitelist_Line$" rvalue="1"/></out>
<out type="push" extdata="Whitelist_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" lvalue="l" rvalue="$Whitelist_Line$"/></out>
<out type="push" extdata="Proxy_Permission" condition="==" lvalue="%NAME%" rvalue="%USERVAR[Whitelist_Result]%">1</out>
<out type="push" extdata="Proxy_Permission" condition="==" lvalue="%IP%" rvalue="%USERVAR[Whitelist_Result]%">1</out>
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="1"></out>
<out type="goto" extdata="-5" condition="!=" lvalue="%USERVAR[Whitelist_Result]%" rvalue=""></out>
// Check the Cache for this IP, if the IP is found don't query the IP with the API and just push it to the API Result variable
<out type="push" extdata="Live_Check_Cache_Date"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%IP%.Live.Cache.ini" lvalue="l" rvalue="1"/></out>
// If the API is requesting the local Cache to be turned off then ignore the cache output and make a web query to the API instead
<out type="push" extdata="Live_Check_Cache_Date" condition="?" lvalue="%USERVAR[PBS_Local_Script_Cache]%" rvalue="OFFLINE">Ignore-Cache</out>
// Check the Cache output for a proxy or not and push those variables so that duplicate queries are not made within the past day for this IP
<out type="push" extdata="Proxy_Server_API_Result">0</out>
<out type="push" extdata="Proxy_Server_API_Result" condition="==" lvalue="%USERVAR[Live_Check_Cache_Date]%" rvalue="Ban Date: D%DAY%-M%MONTH%-Y%YEAR%">Proxy Detected in the Cache</out>
<out type="goto" extdata="3" condition="?" lvalue="%USERVAR[Live_Check_Cache_Date]%" rvalue="D%DAY%-M%MONTH%-Y%YEAR%"></out>
// Check if the MXPulse API is telling the script to turn off or not
<out type="break" condition="!?" lvalue="%USERVAR[PBS_MXPulse_API_Status]%" rvalue="ONLINE"></out>
// Query the Proxy API to see if this IP Address is a proxy or not
<out type="push" extdata="Proxy_Server_API_Result"><operator type="readweb" nvalue="%USERVAR[PBS_Proxy_API_URL]%%IP%&amp;pb=v1.6.4&amp;room=%USERVAR[Cleaned_Room]%" lvalue="l" rvalue="1"/></out>
// Format the API output to make it a little nicer
<out type="push" extdata="Proxy_UI_Result">0</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Proxy Detected in the Cache" rvalue="%USERVAR[Proxy_Server_API_Result]%">Proxy Detected in the Cache</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Public - %IP%" rvalue="%USERVAR[Proxy_Server_API_Result]%">Random Public Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Live - %IP%" rvalue="%USERVAR[Proxy_Server_API_Result]%">Random Public Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Tor - %IP%" rvalue="%USERVAR[Proxy_Server_API_Result]%">Tor Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="0 - %IP%" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
// If the user had permission to use a proxy do not kick them but tell the admins they are using a proxy if they are
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="0"></out>
<out condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#%NAME% #c16#is using a Proxy but has permission and won't be kicked. #c63#(#c62#%USERVAR[Proxy_UI_Result]%#c63#)</out>
// If a match was found, Kick/Ban and alert admins to this users Proxy use unless they had permission in which case skip this part
<out type="goto" extdata="4" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="1"></out>
<out condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0">/banip %IP% 2880</out>
<out condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0">/kick %RAWNAME%</out>
<out condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#%NAME% #c8#is using a Proxy and has had their IP banned for 48 Hours. #c63#(#c62#%USERVAR[Proxy_UI_Result]%#c63#)</out>
// If this user isn't using a proxy server and the room owner has specified Verbose mode to be on then tell the admins that this is user is not using a Proxy Server
<out type="push" extdata="Proxy_Blocker_Verbose_Mode" condition="==" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.verbose.mode.setting.ini" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="2" condition="!=" lvalue="%USERVAR[Proxy_Blocker_Verbose_Mode]%" rvalue="1"></out>
<out condition="==" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#%NAME% #c4#is not using a proxy server #c9#[#c62#Verbose Mode#c9#]</out>
// If the user has setup the exile in the ".exile.room.ini" file then exile this user to that room if they are not a Proxy Server, Just exile if the user is Whitelisted however
<out type="push" extdata="Exileroom_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.exile.room.ini" lvalue="l" rvalue="2"/></out>
<out type="goto" extdata="4" condition="==" lvalue="%USERVAR[Exileroom_Result]%" rvalue=""></out>
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="1"></out>
<out type="goto" extdata="2" condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0"></out>
<out>/exile %RAWNAME% %USERVAR[Exileroom_Result]%</out>
// If the user has setup the forcelogin voice feature then log this user in if they are not a proxy
<out type="push" extdata="ForceLoginPass_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.forcelogin.password.ini" lvalue="l" rvalue="2"/></out>
<out type="goto" extdata="4" condition="==" lvalue="%USERVAR[ForceLoginPass_Result]%" rvalue=""></out>
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="1"></out>
<out type="goto" extdata="2" condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0"></out>
<out>/forcelogin %RAWNAME% %USERVAR[ForceLoginPass_Result]%</out>
// Create a cache for this IP so that we don't query it again atleast within 24 hours - Don't save this if the API doesn't want a cache created
<out type="goto" extdata="3" condition="?" lvalue="%USERVAR[PBS_Local_Script_Cache]%" rvalue="OFFLINE"></out>
<out condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%IP%.Live.Cache.ini" mode="t">Ban Date: D%DAY%-M%MONTH%-Y%YEAR%\nProxy Type: Live detection from the API\nBanned By: Banned after it entered your room by the Proxy Blocker Software</out>
<out condition="==" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%IP%.Live.Cache.ini" mode="t">Cached Date: D%DAY%-M%MONTH%-Y%YEAR%\nProxy Type: Not a proxy, normal IP Address\nCached Created By: Proxy Blocker Software</out>
// Check for recent bans on the API and cache those
<out type="self" condition="!=" lvalue="%USERVAR[Proxy_Previous_Download_Minute]%" rvalue="%MINUTE%">!botpreempban</out>
// If there is 3 positive detections in the last 60 seconds then send /limit 5 to the server to stop any other connections
<out type="push" extdata="Proxy_Spam_Counter" condition="!=" lvalue="%MINUTE%" rvalue="$Prox_Last_Minute$">0</out>
<out type="push" extdata="Prox_Last_Minute" condition="!=" lvalue="%MINUTE%" rvalue="$Prox_Last_Minute$">%MINUTE%</out>
<out type="push" extdata="Proxy_Spam_Counter" condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0"><operator type="+" lvalue="$Proxy_Spam_Counter$" rvalue="1"/></out>
<out type="push" extdata="MINUTEUNTILNEXTHOUR"><operator type="-" lvalue="60" rvalue="%MINUTE%"/></out>
<out type="push" extdata="spam_lockdown_setting"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.setting.ini" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="4" condition="!=" lvalue="%USERVAR[spam_lockdown_setting]%" rvalue="1"></out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/limit 5</out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c8#A proxy based spam attack has been detected in your room. The room has entered into lock down mode. No one will be able to enter your room for %USERVAR[MINUTEUNTILNEXTHOUR]% minutes</out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" mode="t">1\n%HOUR%-%DATE%</out>
If 5 attacks are detected within the past minute tell the admins they can turn the Lockdown feature on (Only give this notice once per day)
<out type="goto" extdata="4" condition="==" lvalue="%USERVAR[spam_lockdown_setting]%" rvalue="1"></out>
<out type="goto" extdata="3" condition="==" lvalue="%USERVAR[Block_Lockdown_Message]%" rvalue="1-%DATE%"></out>
<out condition="==" lvalue="5-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#A large Proxy Spam attack has been detected against your room, you can block this and future large attacks by typing #c4#!ProxyLockdown On</out>
<out type="push" extdata="Block_Lockdown_Message" condition="==" lvalue="5-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">1-%DATE%</out>
// Break here if this is a proxy, only check for updates when the user has not been detected as a proxy
<out type="break" condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0"></out>
// Check for an updated version of this script (Now with Auto Update if wget is found!)
<out type="push" extdata="Random_Number">%RANDOMNUM[1337]%</out>
<out type="push" extdata="Version_Info">v1.6.4</out>
<out type="pop" extdata="Version_Release_Message"/>
<out type="push" extdata="Version_Check_Date"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.Version.Check.Date.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Version_Server_Health" condition="!=" lvalue="%USERVAR[Version_Check_Date]%" rvalue="%DATE%"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/Version.ini?rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="5"/></out>
<out type="push" extdata="Version_Info" condition="!=" lvalue="%USERVAR[Version_Check_Date]%" rvalue="%DATE%"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/Version.ini?rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Version_Release_Message" condition="!=" lvalue="%USERVAR[Version_Info]%" rvalue="v1.6.4"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/Version.ini?rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="2"/></out>
// Check if the Version_Server_Health is okay, if it isn't skip this update entirely
<out type="break" condition="!=" lvalue="%USERVAR[Version_Server_Health]%" rvalue="BQ0PC4JUX81KGWL"></out>
// Auto Update Code
<out type="break" condition="==" lvalue="%USERVAR[Version_Info]%" rvalue="v1.6.4"></out>
<out type="push" extdata="wget_check"><operator type="readfile" nvalue="Plugins\wget\wget.exe" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="7" condition="==" lvalue="$wget_check$" rvalue=""></out>
<out type="push" extdata="URL">http://proxy.blocker.mxpulse.com/Version.ini</out>
<out type="push" extdata="Update_Filename"><operator type="readweb" nvalue="$URL$" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="Update_URL"><operator type="readweb" nvalue="$URL$" lvalue="l" rvalue="4"/></out>
<out type="exec" extdata="1">Plugins\wget\wget.exe -q -O Plugins\%USERVAR[Update_Filename]% %USERVAR[Update_URL]%</out>
<out>/opmsg #c4#Proxy Blocker #c63#(#c62#%USERVAR[Version_Info]%#c63#): #c1#Your Proxy Blocker plugin has just downloaded and installed an update.</out>
<out>/mxc load</out>
// Normal Update Code
<out type="goto" extdata="2" condition="!=" lvalue="$wget_check$" rvalue=""></out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c1#A new version (%USERVAR[Version_Info]%) of Proxy Blocker is available.</out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="">/opmsg #c4# · Update Notes#c63#: #c62#%USERVAR[Version_Release_Message]%</out>
<out type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.Version.Check.Date.txt" mode="t">%DATE%</out>
</OnEnter>

<command type="script">
<in>!proxy %PARAM%</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="7"/></out>
<out type="break" condition="!_?" lvalue="$req$" rvalue="!proxy "></out>
// Generate a random number to be used in the query to the API to make sure the results are not from the readweb cache
<out type="push" extdata="Random_Number">%RANDOMNUM[1337]%</out>
// Check the status of the Proxy Blocker API's
<out type="push" extdata="PBS_Proxy_API_URL"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php?rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="PBS_MXPulse_API_Status"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php?rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="PBS_MXPulse_PreEmptiveBan_Status"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php?rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="PBS_Local_Script_Cache"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php?rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="1"/></out>
// Output the status if the user used status as their parameter
<out condition="_?" lvalue="%PARAM%" rvalue="status">#c4#Proxy Blocker v1.6.4 API Status#c63#:</out>
<out condition="_?" lvalue="%PARAM%" rvalue="status">%USERVAR[PBS_MXPulse_API_Status]%</out>
<out condition="_?" lvalue="%PARAM%" rvalue="status">%USERVAR[PBS_MXPulse_PreEmptiveBan_Status]%</out>
<out condition="_?" lvalue="%PARAM%" rvalue="status">%USERVAR[PBS_Local_Script_Cache]%</out>
<out type="break" condition="_?" lvalue="%PARAM%" rvalue="status"></out>
// Check if the user is activating Verbose mode or not
<out type="goto" extdata="8" condition="!_?" lvalue="%PARAM%" rvalue="verbose"></out>
// Process which command the user typed
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="on" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.verbose.mode.setting.ini">1</out>
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="off" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.verbose.mode.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#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#The #c63#"#c1#Proxy Blocker Verbose#c63#"#c9# mode has been turned #c8#OFF</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="off">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#When this setting is OFF the Bot will only notify you when it detects a proxy server has entered the room</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#The #c63#"#c1#Proxy Blocker Verbose#c63#"#c9# mode has been turned #c4#ON</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#When this Setting is ON the Bot will notify you whether a user is using a proxy server or not</out>
<out type="break" condition="_?" lvalue="%PARAM%" rvalue="verbose"></out>
// 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">:%PARAM%</out>
<out type="push" extdata="Private_IP_Detected">0</out>
<out type="push" extdata="Private_IP_Detected" condition="==" lvalue="%PARAM%" rvalue="127.0.0.1">1</out>
<out type="push" extdata="Private_IP_Detected" condition="==" lvalue="%PARAM%" 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 condition="==" lvalue="%USERVAR[Private_IP_Detected]%" rvalue="1">#c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#You cannot check an internal IP with the Proxy Blocker</out>
<out type="break" condition="==" lvalue="%USERVAR[Private_IP_Detected]%" rvalue="1"></out>
// Break if input doesn't contain a dot (just a really basic check to see if this is actually an IP Address, it isn't foolproof but lots more code would be needed to properly verify input with Metis)
<out condition="!?" lvalue="%PARAM%" rvalue=".">#c62#Your parameter #c63#"#c4#%PARAM%#c63#" #c62#is not a valid IP Address. Valid Example#c63#: #c4#!proxy 137.56.163.46</out>
<out type="break" condition="!?" lvalue="%PARAM%" rvalue="."></out>
// Push the PARAM to a variable so that it works inside the readweb operator
<out type="push" extdata="Proxy_Query_IP">%PARAM%</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
// The reason this variable is called Pulse is because it shares this variable among all my scripts to make sure the right Metis is being used, saves queries
<out type="push" extdata="Metis_Check" condition="==" lvalue="%USERVAR[Metis_Check]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/metis.check.ini" lvalue="l" rvalue="1"/></out>
// Check if the user is using a compatible version of Metis or not and also check if the server is online or not
<out type="break" condition="?" lvalue="%USERVAR[Metis_Check]%" rvalue="Error: "></out>
<out condition="!=" lvalue="$Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#You appear to be running an outdated version of Metis.</out>
<out condition="!=" lvalue="$Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#You can download the latest one here#c63#: #c62#http://bit.ly/ldk6C3</out>
<out condition="!=" lvalue="$Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#To install this file replace your old Metis.r2x file located in your script plugins folder</out>
<out type="break" condition="!=" lvalue="$Metis_Check$" rvalue="6042117849"></out>
// Check if the MXPulse API is telling the script to turn off or not
<out condition="!?" lvalue="%USERVAR[PBS_MXPulse_API_Status]%" rvalue="ONLINE">#c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c5#The Proxy Server API Service is currently offline, please try your query again later.</out>
<out type="break" condition="!?" lvalue="%USERVAR[PBS_MXPulse_API_Status]%" rvalue="ONLINE"></out>
// Get the roomname, clean it up and add it to the proxy request
<out type="push" extdata="Cleaned_Room">%ROOMNAME%</out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="&amp;lowast;" rvalue="[star]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="&amp;" 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>
// Query the Proxy API to see if this IP Address is a proxy or not
<out type="push" extdata="Proxy_Server_API_Result"><operator type="readweb" nvalue="%USERVAR[PBS_Proxy_API_URL]%%USERVAR[Proxy_Query_IP]%&amp;pb=v1.6.4&amp;room=%USERVAR[Cleaned_Room]%&amp;rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="1"/></out>
// Format the API output to make it a little nicer
<out type="push" extdata="Proxy_UI_Result">0</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Public - %USERVAR[Proxy_Query_IP]%" rvalue="%USERVAR[Proxy_Server_API_Result]%">Random Public Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Live - %USERVAR[Proxy_Query_IP]%" rvalue="%USERVAR[Proxy_Server_API_Result]%">Random Public Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Tor - %USERVAR[Proxy_Query_IP]%" rvalue="%USERVAR[Proxy_Server_API_Result]%">Tor Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="0 - %USERVAR[Proxy_Query_IP]%" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
// Tell the user if the IP they have queried is a proxy server or not
<out condition="==" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0">#c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#%PARAM%#c63#: #c4#This IP is believed not to be a Proxy Server.</out>
<out condition="!=" lvalue="%USERVAR[Proxy_UI_Result]%" rvalue="0">#c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#%PARAM%#c63#: #c8#Known Proxy Server #c63#(#c62#%USERVAR[Proxy_UI_Result]%#c63#)</out>
</command>


<command type="script">
<in>!ProxyLockdown on</in>
<in>!ProxyLockdown 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="15"/></out>
<out type="break" condition="!_?" lvalue="$req$" rvalue="!ProxyLockdown "></out>
// Check if the Metis version is below v2.83 so we know that %USERMODE% works
<out type="push" extdata="Supports_Usermode">1</out>
<out type="push" extdata="Supports_Usermode" condition="?" lvalue="%VERSION%" rvalue="2.80">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.81">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.82">0</out>
<out type="goto" extdata="3" condition="!=" lvalue="%USERVAR[Supports_Usermode]%" rvalue="1"></out>
// If the user doesn't have an @ in the User List, tell them they need to login to use this command and break
<out condition="!=" lvalue="%USERMODE%" rvalue="@">#c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#Login and show an #c62#@ #c9#in the userlist to use this command.</out>
<out type="break" condition="!=" lvalue="%USERMODE%" rvalue="@"></out>
// Process which command the user typed
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="on" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.setting.ini">1</out>
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="off" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.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#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#The #c63#"#c1#Proxy Blocker Lockdown#c63#"#c9# feature has been turned #c8#OFF</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="off">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#When this setting is off the Bot will not attempt to lockdown your room even when it detects a large proxy based spam attack</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#The #c63#"#c1#Proxy Blocker Lockdown#c63#"#c9# feature has been turned #c4#ON</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#When this Setting is On the Bot will be able to block ALL users from being able to enter your room for a maximum of 60 minutes whenever a large proxy spam attack has been detected inside your room</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#This feature only supports WCS, RCS, RSWCS, FXServe and ZCS - Other servers may not support it</out>
// End any lockdown currently in progress if the user turned this feature off
<out type="goto" extdata="7" condition="_?" lvalue="%TRIGGER%" rvalue="on"></out>
<out type="push" extdata="Spam_Protect_Status"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" lvalue="l" rvalue="1"/></out>
<out type="break" condition="!=" lvalue="$Spam_Protect_Status$" rvalue="1"></out>
<out>/limit 150</out>
<out>/reload</out>
<out>/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#The server has exited Lock Down mode, users are again able to connect to the room, if you want to re-enable this feature for future attacks type #c4#!ProxyLockdown On</out>
<out type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" mode="t">0\n%HOUR%-%DATE%</out>
// If there is 3 positive detections in the last 60 seconds then send /limit 5 to the server to stop any other connections
<out type="break" condition="_?" lvalue="%TRIGGER%" rvalue="off"></out>
<out type="push" extdata="Proxy_Spam_Counter" condition=">" lvalue="$Proxy_Spam_Counter$" rvalue="3">3</out>
<out type="push" extdata="Prox_Last_Minute" condition="!=" lvalue="%MINUTE%" rvalue="$Prox_Last_Minute$">%MINUTE%</out>
<out type="push" extdata="MINUTEUNTILNEXTHOUR"><operator type="-" lvalue="60" rvalue="%MINUTE%"/></out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/limit 5</out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c8#A proxy based spam attack has been detected in your room. The room has entered into lock down mode. No one will be able to enter your room for %USERVAR[MINUTEUNTILNEXTHOUR]% minutes</out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" mode="t">1\n%HOUR%-%DATE%</out>
</command>


<OnRename type="script">
// This part of the script will check if there is any new IP's to be banned anytime someone in your room changes their username.
// I've used this method because I do not want to use an OnTimer event as Metis only allows 1 to be used per Bot and I wouldn't want to 'steal' your only OnTimer and possibly break other scripts you are using.
// Check for recent bans on the API and cache those
<out type="self" condition="!=" lvalue="%USERVAR[Proxy_Previous_Download_Minute]%" rvalue="%MINUTE%">!botpreempban</out>
</OnRename>


<command type="script">
<in>!botpreempban</in>
<in>!download</in>
// If the channel limit is set to 5 but the hour is up, re-set it back to 150
<out type="push" extdata="Spam_Protect_Status"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="6" condition="!=" lvalue="$Spam_Protect_Status$" rvalue="1"></out>
<out type="push" extdata="Spam_Protect_DateTime"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" lvalue="l" rvalue="2"/></out>
<out condition="!=" lvalue="$Spam_Protect_DateTime$" rvalue="%HOUR%-%DATE%">/limit 150</out>
<out condition="!=" lvalue="$Spam_Protect_DateTime$" rvalue="%HOUR%-%DATE%">/reload</out>
<out condition="!=" lvalue="$Spam_Protect_DateTime$" rvalue="%HOUR%-%DATE%">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c62#The server has exited Lock Down mode, users are again able to connect to the room</out>
<out condition="!=" lvalue="$Spam_Protect_DateTime$" rvalue="%HOUR%-%DATE%" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" mode="t">0\n%HOUR%-%DATE%</out>
// Generate a random number to be used in the query to the API to make sure the results are not from the readweb cache
<out type="push" extdata="Random_Number">%RANDOMNUM[1337]%</out>
// Check the status of the Proxy Blocker API's - We want these to cache just so it saves bandwidth and query time
<out type="push" extdata="PBS_Proxy_API_URL" condition="==" lvalue="%USERVAR[PBS_Proxy_API_URL]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="PBS_MXPulse_API_Status" condition="==" lvalue="%USERVAR[PBS_MXPulse_API_Status]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="PBS_MXPulse_PreEmptiveBan_Status" condition="==" lvalue="%USERVAR[PBS_MXPulse_PreEmptiveBan_Status]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="PBS_Local_Script_Cache" condition="==" lvalue="%USERVAR[PBS_Local_Script_Cache]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.php" lvalue="l" rvalue="1"/></out>
// Push the current minute to a variable so another check in the script can make sure this doesn't run more often than once a minute
<out type="push" extdata="Proxy_Previous_Download_Minute">%MINUTE%</out>
// Break here if the Pre-Emptive system has been set to off by the Proxy API
<out type="goto" extdata="2" condition="!_?" lvalue="%TRIGGER%" rvalue="!download"></out>
<out condition="!?" lvalue="%USERVAR[PBS_MXPulse_PreEmptiveBan_Status]%" rvalue="ONLINE">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c5#The Pre-Emptive Ban feature has been temporarily disabled, please try again later.</out>
<out type="break" condition="!?" lvalue="%USERVAR[PBS_MXPulse_PreEmptiveBan_Status]%" rvalue="ONLINE"></out>
// Pick the appropriate command to be used for different servers. Use /banip as the default however.
<out type="push" extdata="Server_Appropriate_BAN_CMD">/banip</out>
<out type="push" extdata="Server_Appropriate_BAN_CMD" condition="_?" lvalue="%SERVER%" rvalue="RCS">/hidecmd /banip</out>
<out type="push" extdata="Server_Appropriate_BAN_CMD" condition="_?" lvalue="%SERVER%" rvalue="WCS">/hidecmd /banip</out>
<out type="push" extdata="Server_Appropriate_UNBAN_CMD">/unban</out>
<out type="push" extdata="Server_Appropriate_UNBAN_CMD" condition="_?" lvalue="%SERVER%" rvalue="RCS">/hidecmd /unban</out>
<out type="push" extdata="Server_Appropriate_UNBAN_CMD" condition="_?" lvalue="%SERVER%" rvalue="WCS">/hidecmd /unban</out>
// Read in recent ban (start line 1000 then go down) - Due to the way this is coded it actually starts with line 1001 but its then reduced to line 1000 before it begins reading the actual webpage
<out type="push" extdata="Proxy_Server_API_Result_Line">1001</out>
// Set the Ban Message to off for a clean run
<out type="push" extdata="IP_Ban_Message">0</out>
// Set the banned IP Count to 0 for a clean run
<out type="push" extdata="Amount_of_Proxies_Banned">0</out>
// Reduce the line we are reading by 1, the reason we read the highest line first is so that Metis can cache all the lines and then reference that, basically for performance
<out type="push" extdata="Proxy_Server_API_Result_Line"><operator type="-" lvalue="%USERVAR[Proxy_Server_API_Result_Line]%" rvalue="1"/></out>
// Read in the webpage on the Line we have selected
<out type="push" extdata="Proxy_Server_API_Result"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/recent.detections.v2.php?rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="%USERVAR[Proxy_Server_API_Result_Line]%"/></out>
// If the divider [:@:] isn't found in the server output then consider the server bugged out or missing data and skip this line
<out type="goto" extdata="18" condition="!?" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="[:@:]"></out>
// Replace the data seperator with something more Metis friendly
<out type="push" extdata="Proxy_Server_API_Result"><operator type="strrep" nvalue="%USERVAR[Proxy_Server_API_Result]%" lvalue="[:@:]" rvalue="^"/></out>
// Find the new seperator and push the variables on both sides (Left = IP, Right = Proxy Type)
<out type="push" extdata="Found_Divider"><operator type="strrfind" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="^"/></out>
<out type="push" extdata="Cache_Line01"><operator type="strleft" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="$Found_Divider$"/></out>
<out type="push" extdata="Found_Divider"><operator type="+" lvalue="%USERVAR[Found_Divider]%" rvalue="1"/></out>
<out type="push" extdata="Cache_Line02"><operator type="strright" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="$Found_Divider$"/></out>
// Check that this Proxy wasn't already banned in the past 24 hours, if it was then just skip forward to the next IP
<out type="push" extdata="Cache_Line03"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%USERVAR[Cache_Line01]%.Live.Cache.ini" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Cache_Line02]%" rvalue="Remove Ban"></out>
<out type="goto" extdata="10" condition="==" lvalue="%USERVAR[Cache_Line03]%" rvalue="Ban Date: D%DAY%-M%MONTH%-Y%YEAR%"></out>
// Create the cache file content
<out type="push" extdata="Cache_File_Content" condition="!=" lvalue="%USERVAR[Cache_Line01]%" rvalue="">Ban Date: D%DAY%-M%MONTH%-Y%YEAR%\nProxy Type: %USERVAR[Cache_Line02]%\nBanned By: Pre-emptive Banning Service</out>
<out type="push" extdata="Cache_File_Content" condition="==" lvalue="%USERVAR[Cache_Line02]%" rvalue="Remove Ban">Unban Date: D%DAY%-M%MONTH%-Y%YEAR%\nProxy Type: Not a proxy, normal IP Address\nUnbanned By: Pre-emptive Banning Service</out>
// Save cache file content to the cache file
<out condition="!=" lvalue="%USERVAR[Cache_Line01]%" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%USERVAR[Cache_Line01]%.Live.Cache.ini" mode="t">%USERVAR[Cache_File_Content]%</out>
// Form the output command for either banning or unbanning IP's in the room
<out type="push" extdata="Output_Command"></out>
<out type="push" extdata="Output_Command" condition="!=" lvalue="%USERVAR[Cache_Line01]%" rvalue="">%USERVAR[Server_Appropriate_BAN_CMD]% %USERVAR[Cache_Line01]% 2880</out>
<out type="push" extdata="Output_Command" condition="_?" lvalue="%USERVAR[Cache_Line02]%" rvalue="Remove Ban">%USERVAR[Server_Appropriate_UNBAN_CMD]% %USERVAR[Cache_Line01]%</out>
// Run the output command
<out condition="!=" lvalue="%USERVAR[Cache_Line01]%" rvalue="">%USERVAR[Output_Command]%</out>
// Save a 1 in the ban message so we know to output it later.
<out type="push" extdata="IP_Ban_Message" condition="?" lvalue="%USERVAR[Output_Command]%" rvalue="/banip">1</out>
// +1 the amount of IP's banned if some IP's were banned
<out type="push" extdata="Amount_of_Proxies_Banned" condition="?" lvalue="%USERVAR[Output_Command]%" rvalue="/banip"><operator type="+" lvalue="%USERVAR[Amount_of_Proxies_Banned]%" rvalue="1"/></out>
// Process this code a few more times or until we reach line 1 in which case finish
<out type="goto" extdata="-20" condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result_Line]%" rvalue="1"></out>
// Proxy Servers were banned message creation
<out type="push" extdata="Proxy_Opmsg_Output" condition=">" lvalue="%USERVAR[Amount_of_Proxies_Banned]%" rvalue="1">%USERVAR[Amount_of_Proxies_Banned]% Proxy Servers have been banned in your room for 48 Hours #c63#(#c62#Pre-Emptive Bans#c63#)</out>
<out type="push" extdata="Proxy_Opmsg_Output" condition="==" lvalue="%USERVAR[Amount_of_Proxies_Banned]%" rvalue="1">%USERVAR[Amount_of_Proxies_Banned]% Proxy Server has been banned in your room for 48 Hours #c63#(#c62#Pre-Emptive Bans#c63#)</out>
// Output to the admins that some IP's were banned if they were banned
<out condition="==" lvalue="%USERVAR[IP_Ban_Message]%" rvalue="1">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#%USERVAR[Proxy_Opmsg_Output]%</out>
<out type="break" condition="==" lvalue="%TRIGGER%" rvalue="!botpreempban"></out>
<out condition="==" lvalue="%USERVAR[IP_Ban_Message]%" rvalue="0">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#No Proxy Servers were found to ban at this time #c63#(#c62#Pre-Emptive Bans#c63#)</out>
</command>

<command type="script">
<in>!ProxyPardon %PARAM%</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="13"/></out>
<out type="break" condition="!_?" lvalue="$req$" rvalue="!ProxyPardon "></out>
// Check if the Metis version is below v2.83 so we know that %USERMODE% works
<out type="push" extdata="Supports_Usermode">1</out>
<out type="push" extdata="Supports_Usermode" condition="?" lvalue="%VERSION%" rvalue="2.80">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.81">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.82">0</out>
<out type="goto" extdata="3" condition="!=" lvalue="%USERVAR[Supports_Usermode]%" rvalue="1"></out>
// If the user doesn't have an @ in the User List, tell them they need to login to use this command and break
<out condition="!=" lvalue="%USERMODE%" rvalue="@">#c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#Login and show an #c62#@ #c9#in the userlist to use this command.</out>
<out type="break" condition="!=" lvalue="%USERMODE%" rvalue="@"></out>
// Do a really basic IP Check by checking if the paramter contains a .
<out condition="!?" lvalue="%PARAM%" rvalue=".">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#Your parameter #c63#"#c4#%PARAM%#c63#" #c62#is not a valid IP Address. Valid Example#c63#: #c4#!ProxyPardon 137.56.163.46</out>
<out type="break" condition="!?" lvalue="%PARAM%" rvalue="."></out>
// Create a Whitelist File if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="Whitelist_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#A Whitelist file has been created here#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini</out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#You may fill this file with Proxy IP's or Usernames of the people you trust to use Proxy Servers</out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" mode="t">You can place Proxy Server IP's OR Usernames in this file, one entry per line, unlimited size, Please do not delete this line explaining how to use the file!\n</out>
// Push the user parameter to a variable
<out type="push" extdata="Pardon_User_IP">%PARAM%</out>
// Process which command the user typed
<out type="file" mode="t" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%USERVAR[Pardon_User_IP]%.Live.Cache.ini">Pardoned Date: D%DAY%-M%MONTH%-Y%YEAR%\nProxy Type: Not a proxy, normal IP Address\nUnbanned By: %NAME%</out>
<out type="file" mode="a" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini">%USERVAR[Pardon_User_IP]%\n</out>
// Output message to Opmsg explaining this users IP has been pardoned
<out>/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#The IP #c63#"#c1#%USERVAR[Pardon_User_IP]%#c63#"#c9# has been added to your local Proxy IP Whitelist</out>
<out>/opmsg #c4#Proxy Blocker #c63#(#c62#v1.6.4#c63#): #c9#To edit the file manually#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini</out>
</command>

</config>