<config>


//////////////
//
//  Urban Dictionary v0.3a by Pri (11th of November 2010)
//  This script requires Metis v2.80 & RoboMX v2.08
//  Website: www.mxpulse.com/board
//
///////  COMMANDS
//
//  !Urban [Query] - Perform a query to locate information about something from Urban Dictionary
//  !PrivateUrban - Typing this will set Urban Dictionary to only give results privately to those who use the command
//  !PublicUrban - Typing this will set Urban Dictionary to give results to the entire room when someone uses the command
//  !SetUrbanColour [Number] - Set the menu colours to something other than the default Green (#c4#) to better fit your room
//  !UrbanResult [Number] - Set the maximum amount of results urban is allowed to display. Choose a number between 1 and 10
//
///////  SERVER SUPPORT
//
//  WCS, RCS, ZCS, RSWCS, FXServer and Ouka are all supported out of the box
//
//////////////


<usergroup name="Urban_Admin_Users" case="0">
// This usergroup is only for your admins so that they can control some of the special commands.
// Everyone even if they are not in this usergroup will be able to type !Urban [Query] and see the results
*  ®ÊN  Pri  *
</usergroup>


<command type="script">
<in>!urban %PARAM%</in>
// Check that the command was used at the beginning of a sentance
<out type="push" extdata="CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="CMD_REQ"><operator type="strleft" lvalue="$CMD_REQ$" rvalue="7"/></out>
<out type="break" condition="!_?" lvalue="$CMD_REQ$" rvalue="!urban "></out>
// Push PARAM to Variable
<out type="push" extdata="Urban_Query">%PARAM%</out>
// Check that the scripts folder and settings file has been setup. If it hasn't do it.
<out type="push" extdata="Urban_Setup_Check"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Urban.Dictionary\.Urban.Dictionary.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Urban_Setup_Check$" rvalue="" type="exec" extdata="1">cmd.exe /c MD C:\Pri.Script.Dependencies\Urban.Dictionary</out>
<out condition="==" lvalue="$Urban_Setup_Check$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Urban.Dictionary.ini" mode="t">1</out>
// Load in the admins chosen specific amount of results, If nothing is selected the default is 3
<out type="push" extdata="Result_Maximum"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Urban.Dictionary\.Result.Maximum.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Result_Maximum" condition="==" lvalue="$Result_Maximum$" rvalue="">3</out>
// Load in the menucolour selected by the admins, if nothing found default is #c4#
<out type="pop" extdata="Server_Private_Command"/>
<out type="push" extdata="Menu_Colour"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Urban.Dictionary\.Menu.Colour.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Menu_Colour" condition="!?" lvalue="$Menu_Colour$" rvalue="#c"></out>
// Set the script up to use Private Mode by default
<out type="goto" extdata="10" condition="==" lvalue="$Urban_Setup_Check$" rvalue="1"></out>
<out type="push" extdata="Server_Private_Command">0</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="WCS">/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="RCS">/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="FXServer">/message :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="Ouka">#private :@:RAWNAME:@: #message:@:SPACE:@:</out>
// Because ZCS does not report itself as ZCS and instead as WinMX we are just going to assume that WinMX = ZCS
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="WinMX">/privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Urban_Checking_For_WCS" condition="?" lvalue="%SERVER%" rvalue="WinMX">1</out>
<out condition="?" lvalue="%SERVER%" rvalue="WinMX">/stats</out>
// Save the command for later use
<out type="file" mode="t" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Public.Private.Server.Settings.ini">1\n%USERVAR[Server_Private_Command]%</out>
// Check if the script has been set to Public or Private Mode
<out type="push" extdata="Private_Public_Setting"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Urban.Dictionary\.Public.Private.Server.Settings.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Server_Private_Command" condition="==" lvalue="$Private_Public_Setting$" rvalue="1"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Urban.Dictionary\.Public.Private.Server.Settings.ini" lvalue="l" rvalue="2"/></out>
// If the user has selected to use private commands formulate how it should look for this query
<out type="push" extdata="Server_Private_Command"><operator type="strrep" nvalue="$Server_Private_Command$" lvalue=":@:RAWNAME:@:" rvalue="%RAWNAME%"/></out>
<out type="push" extdata="Server_Private_Command"><operator type="strrep" nvalue="$Server_Private_Command$" lvalue=":@:SPACE:@:" rvalue=" "/></out>
// Check for an updated version of this script
<out type="push" extdata="Version_Info">v0.3a</out>
<out type="pop" extdata="Version_Release_Message"/>
<out type="push" extdata="Version_Check_Date"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Urban.Dictionary\.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://urban.mxpulse.com/version.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Version_Release_Message" condition="!=" lvalue="%USERVAR[Version_Info]%" rvalue="v0.3a"><operator type="readweb" nvalue="http://urban.mxpulse.com/version.ini" lvalue="l" rvalue="2"/></out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="">/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c9#%USERVAR[Version_Release_Message]%</out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Version.Check.Date.txt" mode="t">%DATE%</out>
// Check for a Cached Version, if one exsists skip the re-downloading of the results. Caches are only valid for 1 month
<out type="push" extdata="Cache_Status"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Urban.Dictionary\Urban.Cache.$Urban_Query$.txt" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="15" condition="==" lvalue="$Cache_Status$" rvalue="%MONTH%.%YEAR%.v0.3a.%USERVAR[Menu_Colour]%"></out>
// Create the URL to query
<out type="push" extdata="OPENLYREADTHIS">http://www.urbandictionary.com/define.php?term=%PARAM%</out>
// Query the first 1000 lines of the Urban Page
<out type="push" extdata="string03"><operator type="readweb" nvalue="$OPENLYREADTHIS$" lvalue="c" rvalue="1000" /></out>
// Filter the results for reading back later on
<out type="push" extdata="string03"><operator type="strrep" nvalue="$string03$" lvalue="<div class=&quot;definition&quot;>" rvalue="\n#c4#%USERVAR[Menu_Colour]%"/></out>
<out type="push" extdata="string03"><operator type="strrep" nvalue="$string03$" lvalue="<div class=&quot;example&quot;>" rvalue="\n#c1#"/></out>
<out type="push" extdata="string03"><operator type="strrep" nvalue="$string03$" lvalue="</div>" rvalue="\nSkip"/></out>
<out type="push" extdata="string03"><operator type="strrep" nvalue="$string03$" lvalue="\nSkip\nSkip" rvalue="\nSkip"/></out>
<out type="push" extdata="string03"><operator type="strrep" nvalue="$string03$" lvalue="<br/>" rvalue=" "/></out>
<out type="push" extdata="string03"><operator type="strrep" nvalue="$string03$" lvalue="&amp;quot;" rvalue="&quot;"/></out>
<out type="push" extdata="string03"><operator type="strrem" lvalue="$string03$" rvalue="<strong class=&quot;highlight&quot;>"/></out>
<out type="push" extdata="string03"><operator type="strrem" lvalue="$string03$" rvalue="</strong>"/></out>
<out type="push" extdata="string03"><operator type="strrem" lvalue="$string03$" rvalue="&quot; class=&quot;urbantip&quot;>"/></out>
<out type="push" extdata="string03"><operator type="strrem" lvalue="$string03$" rvalue="<a href=&quot;/define.php?term="/></out>
<out type="push" extdata="string03"><operator type="strrem" lvalue="$string03$" rvalue="</a>"/></out>
// Save the filtered output to file for reading back
<out type="file" mode="t" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\Urban.Cache.$Urban_Query$.txt">%MONTH%.%YEAR%.v0.3a.%USERVAR[Menu_Colour]%\n$string03$\n</out>
// Display the results in the chat
// Locate the Definition and Examples from the cached page
<out type="push" extdata="Result_Count">0</out>
<out type="push" extdata="ESRLINE">0</out>
<out type="push" extdata="ESRLINE"><operator type="+" lvalue="$ESRLINE$" rvalue="1"/></out>
<out type="push" extdata="Page_Content"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Urban.Dictionary\Urban.Cache.$Urban_Query$.txt" lvalue="l" rvalue="$ESRLINE$"/></out>
<out condition="?" lvalue="$Page_Content$" rvalue="#c4#%USERVAR[Menu_Colour]%">%USERVAR[Server_Private_Command]%%USERVAR[Page_Content]%</out>
<out condition="?" lvalue="$Page_Content$" rvalue="#c1#">%USERVAR[Server_Private_Command]%%USERVAR[Page_Content]%</out>
<out type="push" extdata="Result_Count" condition="?" lvalue="$Page_Content$" rvalue="#c1#"><operator type="+" lvalue="$Result_Count$" rvalue="1"/></out>
<out type="goto" extdata="3" condition="==" lvalue="$Result_Count$" rvalue="$Result_Maximum$"></out>
<out condition="?" lvalue="$Page_Content$" rvalue="#c1#">%USERVAR[Server_Private_Command]%#c1# #c1#</out>
<out type="goto" extdata="-7" condition="!=" lvalue="$Page_Content$" rvalue=""></out>
// Tell the user how many results they received
<out condition="!=" lvalue="$Cache_Status$" rvalue="%MONTH%.%YEAR%.v0.3a.%USERVAR[Menu_Colour]%">%USERVAR[Server_Private_Command]%#c9#Listing Complete, you received %USERVAR[Result_Count]% results #c63#(#c62#Web#c63#)</out>
<out condition="==" lvalue="$Cache_Status$" rvalue="%MONTH%.%YEAR%.v0.3a.%USERVAR[Menu_Colour]%">%USERVAR[Server_Private_Command]%#c9#Listing Complete, you received %USERVAR[Result_Count]% results #c63#(#c62#Cache#c63#)</out>
</command>


<command type="script" condition="==" lvalue="$Urban_Checking_For_WCS$" rvalue="1">
<in>WCS Version: %PARAM%</in>
// Tell the user that WCS was detected and that they may have seen some temporary garbled text
<out>/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c9#WCS %PARAM% has been detected, You may have seen some /privnotice commands above this is normal during WCS %PARAM% detection due to a bug in the server</out>
// If WCS was detected then save that
<out type="file" mode="t" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Public.Private.Server.Settings.ini">1\n/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
// Push 0 to Checking for WCS
<out type="push" extdata="Urban_Checking_For_WCS">0</out>
</command>


<command type="script" usergroup="Urban_Admin_Users">
<in>!privateurban</in>
<in>!publicurban</in>
// Check if the command was typed at the start of a sentence, if not break
<out type="push" extdata="CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="CMD_REQ"><operator type="strleft" lvalue="$CMD_REQ$" rvalue="2"/></out>
<out type="break" condition="!_?" lvalue="$CMD_REQ$" rvalue="!p"></out>
// Process which command the user typed
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="!privateurban" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Public.Private.Server.Settings.ini">1\n</out>
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="!publicurban" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Public.Private.Server.Settings.ini">0</out>
// Output to the Admins if it was set to Public Mode
<out condition="_?" lvalue="%TRIGGER%" rvalue="!publicurban">/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c1#Urban Dictionary Has been set to Public Mode</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="!publicurban">/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c62#When this is set to Public, all Urban results will be shown to the entire room</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="!publicurban">/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c8#Warning#c63#: #c5#Urban Dictionary can contain very strong and graphic language!</out>
// Break if the user selected to use Public
<out type="break" condition="_?" lvalue="%TRIGGER%" rvalue="!publicurban"></out>
// If the user selected PrivateUrban, work out which server is in use
<out type="push" extdata="Server_Private_Command">0</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="WCS">/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="RCS">/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="FXServer">/message :@:RAWNAME:@::@:SPACE:@:</out>
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="Ouka">#private :@:RAWNAME:@: #message:@:SPACE:@:</out>
// Because ZCS does not report itself as ZCS and instead as WinMX we are just going to assume that WinMX = ZCS
<out type="push" extdata="Server_Private_Command" condition="?" lvalue="%SERVER%" rvalue="WinMX">/privnotice :@:RAWNAME:@::@:SPACE:@:</out>
// Save the command for later use
<out type="file" mode="a" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Public.Private.Server.Settings.ini">%USERVAR[Server_Private_Command]%</out>
// Server not recognised Message
<out condition="==" lvalue="$Server_Private_Command$" rvalue="0">/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c9#Urban Dictionary cannot be set to Private in your room as the Server #c63#(#c62#%SERVER%#c63#)#c9# is not supported by the script currently</out>
<out type="file" mode="t" condition="==" lvalue="$Server_Private_Command$" rvalue="0" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Public.Private.Server.Settings.ini">0</out>
<out type="break" condition="==" lvalue="$Server_Private_Command$" rvalue="0"></out>
// Output to the Admins if it was set to Private Mode
<out condition="_?" lvalue="%TRIGGER%" rvalue="!privateurban">/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c1#Urban Dictionary Has been set to Private Mode</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="!privateurban">/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c62#When this is set to Private, only those who use the !Urban command will see results</out>
// Check that WCS 1.8.8 is in use if the Server is reporting itself as WinMX
<out type="push" extdata="Urban_Checking_For_WCS" condition="?" lvalue="%SERVER%" rvalue="WinMX">1</out>
<out condition="?" lvalue="%SERVER%" rvalue="WinMX">/stats</out>
</command>


<command type="script" usergroup="Urban_Admin_Users">
<in>!seturbancolour %PARAM%</in>
<in>!seturbancolor %PARAM%</in>
// Check if the command was typed at the start of a sentence, if not break
<out type="push" extdata="CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="CMD_REQ"><operator type="strleft" lvalue="$CMD_REQ$" rvalue="13"/></out>
<out type="break" condition="!_?" lvalue="$CMD_REQ$" rvalue="!seturbancolo"></out>
// Encapsulate parameter with colour tags if none are present and save to file
<out type="file" mode="t" condition="?" lvalue="%PARAM%" rvalue="#c" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Menu.Colour.ini">%PARAM%\n</out>
<out type="file" mode="t" condition="!?" lvalue="%PARAM%" rvalue="#c" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Menu.Colour.ini">#c%PARAM%#\n</out>
// Output to the Admins what colour it has been set to
<out condition="?" lvalue="%PARAM%" rvalue="#c">/opmsg #c4#%PARAM%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c1#Urban Dictionary Has set its colours to#c63#: %PARAM% |||||</out>
<out condition="!?" lvalue="%PARAM%" rvalue="#c">/opmsg #c4##c%PARAM%#Urban Dictionary #c63#(#c62#v0.3a#c63#): #c1#Urban Dictionary Has set its colours to#c63#: #c%PARAM%# |||||</out>
// Load the colours in to memory so they can be used on all menus straight away
<out type="push" extdata="Menu_Colour"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Urban.Dictionary\.Menu.Colour.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Menu_Colour" condition="!?" lvalue="$Menu_Colour$" rvalue="#c">#c4#</out>
</command>


<command type="script" usergroup="Urban_Admin_Users">
<in>!urbanresult %PARAM%</in>
// Check if the command was typed at the start of a sentence, if not break
<out type="push" extdata="CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="CMD_REQ"><operator type="strleft" lvalue="$CMD_REQ$" rvalue="13"/></out>
<out type="break" condition="!_?" lvalue="$CMD_REQ$" rvalue="!urbanresult "></out>
// only allow %PARAM% which contain 1 to 10
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="1">1</out>
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="2">1</out>
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="3">1</out>
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="4">1</out>
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="5">1</out>
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="6">1</out>
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="7">1</out>
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="8">1</out>
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="9">1</out>
<out type="push" extdata="Allow_Save" condition="==" lvalue="%PARAM%" rvalue="10">1</out>
// Encapsulate parameter with colour tags if none are present and save to file
<out type="file" mode="t" condition="==" lvalue="$Allow_Save$" rvalue="1" extdata="C:\Pri.Script.Dependencies\Urban.Dictionary\.Result.Maximum.ini">%PARAM%</out>
// Output to the Admins what colour it has been set to
<out condition="==" lvalue="$Allow_Save$" rvalue="1">/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c1#Urban Dictionary has set its maximum amount of results to %PARAM%</out>
<out condition="!=" lvalue="$Allow_Save$" rvalue="1">/opmsg #c4#%USERVAR[Menu_Colour]%Urban Dictionary #c63#(#c62#v0.3a#c63#): #c1#You didn't supply a valid result amount, please choose a number between 1 and 10</out>
</command>


</config>