////////////// This software is Alpha and not feature complete // // Link Saver v0.3 by Pri (26th of May 2012) // 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 // // !Links [#] - Browse Links Page by Page (Newest at the top) // !FindLink [Query] - Search for specific links (Newest at the top) // !RemoveLink [Query] - Remove specific links from the index (Requires @ if you're on Metis 2.83 or above) // !UndoRemove - Undo the removal of your previous links (Only the very last ones you removed) // !PrivateLinks - Typing this will set Link Saver Menus to only give results privately to those who use the command (Default) // !PublicLinks - Typing this will set Link Saver Menus to give results to the entire room when someone uses the command // !SetLinkColour [Number] - Set the menu colours to something other than the default Green (#c4#) to better fit your room // /////// SERVER SUPPORT // // WCS, RCS, ZCS, RSWCS, FXServer and Ouka are all supported out of the box // /////// KNOWN ISSUES // // Some page titles may contain encodings that the script is unable to interperate this may result in garbled text // If you find any of this don't worry it won't break anything it will just make things look a little funky // // This script is completely Alpha meaning it is not feature complete. I am planning new additions to the code // but I wanted to see how people respond to it in its current form before I continue with development. // // If you have any suggestions or feature requests don't hesitate to contact me in the Renegades Chat Room on WinMX // or through this scripts topic on my forum: http://www.mxpulse.com/board/viewtopic.php?f=9&t=231 // ////////////// http://%PARAM% https://%PARAM% // This script can detect a URL in any part of a sentence, but we don't want it to do that if the sentence begins with ! or / %TRIGGER% // Check that the scripts folder and settings files have been setup. If they haven't then do so. cmd.exe /c MD C:\Pri.Script.Dependencies\Link.Saver\Cache 1 Link.Index.Content.1.txt // If this is the first setup write the massive customisation settings file ### This is the Link Saver settings file, you can customise many aspects of the Link Saver from here ###\n### Using this file is simple, Just change the output text to what you want, you can use colour codes too! ###\n\n### Change these formats below to alter how things appear in-room, Changes happen as soon as you save this file ###\n\nLink Posted Format: #c4#[Link Saver Name/Version] #c1#[Bitly URL] #c9#- #c63#"#c62#[Page Title]#c63#" #c9#(#c4#[Save Message]#c9#)\nLink Browsing Format: #c1# [Original Link] #c63# | #c62# [Bitly URL]\nLink Searching Format: #c1# [Original Link] #c63# | #c62# [Bitly URL]\nLink Removal Format: #c4#[Link Saver Name/Version] #c1#[Original Link] #c62#Has been removed from the index\n\n### Basic Variable Changes below ###\n\nMaximum Amount Links per Browse Page: 20\nMaximum Amount of !findlink Results: 20\nMaximum Amount of Deletions: 5\n\n### You can use any of these variables below in your custom formats ###\n\n- [Link Saver Name/Version] [Bitly URL] [Page Title] [Save Message] [Original Link] [Short Name]\n- [Raw Name] [Link Number] [Date] [Time]\n\n### The variable [Save Message] is only used when links are posted in the room. It may say (Saved) or (Loaded from Cache) ###\n### In the variable [Short Name] colour codes are removed from the users name to make it look nicer, use [Raw Name] if you want these kept in ### // If the user selected PrivateLinkSaver, work out which server is in use // Skip if this isnt a new install 0 /hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@: /hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@: /message :@:RAWNAME:@::@:SPACE:@: #private :@:RAWNAME:@: #message:@:SPACE:@: // Because ZCS does not report itself as ZCS and instead as WinMX we are just going to assume that WinMX = ZCS /privnotice :@:RAWNAME:@::@:SPACE:@: // Save the command for later use 1\n%USERVAR[Server_Private_Command]% // Check that the user has the correct version of Metis to run this script by querying my server and checking for a file, if this file doesn't display right tell the user to update // The reason this code has Pulse in it is because it's just copy and pasted from the Pulse script and it uses less web queries to share the same variable name this way /opmsg #c4#Link Saver #c63#(#c62#v0.3#c63#): #c9#You appear to be running an outdated version of Metis. /opmsg #c4#Link Saver #c63#(#c62#v0.3#c63#): #c9#You can download the latest one here#c63#: #c62#http://bit.ly/ldk6C3 /opmsg #c4#Link Saver #c63#(#c62#v0.3#c63#): #c9#To install this file replace your old Metis.r2x file located in your script plugins folder // Perform an online check to see if this version of Metis is supported by this script or not // Link Saver requires version 2.82 of Metis at a minimum, if the user is not using this or a higher version tell the admins and break /opmsg #c4#Link Saver #c63#(#c62#v0.3#c63#): #c9#This script requires Metis v2.82 minimum, please upgrade from v%VERSION%#c63#: #c62#http://bit.ly/ldk6C3 // Pop some variables for later use // Load in the menucolour selected by the admins, if nothing found default is #c4# // Check if the script has been set to Public or Private Mode // If the user has selected to use private commands formulate how it should look for this query // Check for an updated version of this script v0.3 /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c9#%USERVAR[Version_Release_Message]% %DATE% // Check which index file is currently in use // Load in the Customisation Settings File to get the format that the user selected 0 // Clear some variables // Display the Bit.ly Shorturl + Page Title using /notice if it's possible /hidecmd /notice #c4# /hidecmd /notice #c4# // Metis thinks that ZCS and WCS v1.8.8 are WinMX Hosted Chatrooms and they both support /hidecmd /notice so we will use that if WinMX is reported as the server /hidecmd /notice #c4# // Push the Trigger to a variable that we can process %TRIGGER% // Push the entire trigger to a text file then read back only the link in to Users_Link variable. // The reason there are so many duplicate replaces here is due to users who post links surrounded by ungodly amount of spaces %USERVAR[Users_Link]%\n // Now read only the link back 0 %USERVAR[READFILTERLINE]% // Check the Cache for this URL, but first remove some characters that cannot be saved to the hard disk such as / ? and : %USERVAR[Users_Link]% // If line 8 says this link was deleted then pop URLDATE so that a new cache is created // Output the Cache to the user if the date is within 1 month // Use the Custom Format read in earlier to create the final output that appears in the room // Depending on if a Title is cached or not show that %USERVAR[Server_Notice_Command]%%USERVAR[Custom_Output_Format]% %USERVAR[Server_Notice_Command]%%USERVAR[Custom_Output_Format]% // Replace some symbols in the URL that won't work in a httpget request %USERVAR[Users_Link]% // Query the API to get the Bit.ly short-url and the Title of the page (Please do not use this in your own software, get your own API key from bit.ly - It's free!) http://link.saver.mxpulse.com/?url=%USERVAR[Users_Link]% // Bitly_URL variable should contain some API conditions such as [ON], [OFF] or [MAINTENANCE] // The script uses these to guage the API's Health and report on its status to the Admins of the room (If required) An unknown error has occurred trying to contact the Link Saver online API The Link Saver online API is currently undergoing maintenance and will be temporarily unavailable The Link Saver online API is currently off, please check RenMX.com for more information #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c9#%USERVAR[API_Health_Message]% // Remove the [ON] message from the API response so it doesn't get output to the room or saved in a cache // Replace some un-metis friendly characters. The API will do most replace work, this is "just in case" // Filter the title a bit for special characters // Break if Title Content includes http or https http://%USERVAR[Original_Link]% // Remove some junk that may have got in to the output for whatever reason // Read in the Link Counter and Add to it by 1 // Use the Custom Format read in earlier to create the final output that appears in the room // Output the URL + Title to the room %USERVAR[Server_Notice_Command]%%USERVAR[Custom_Output_Format]% %USERVAR[Server_Notice_Command]%%USERVAR[Custom_Output_Format]% // Remove colour code from this users name before saving it to the cache[s] %NAME% 0 // Create a Cache for this URL %USERVAR[Original_Link]% %MONTH%\n%USERVAR[Bitly_URL]%\n%USERVAR[Title_Content]%\n%USERVAR[Cleaned_Name]%\n%RAWNAME%\n%DATE%\n%LOCALTIME%\n // Create another cache using the Bitly_URL as the cache name %USERVAR[Bitly_URL]% %MONTH%\n%USERVAR[Bitly_URL]%\n%USERVAR[Title_Content]%\n%USERVAR[Cleaned_Name]%\n%RAWNAME%\n%DATE%\n%LOCALTIME%\n // Break if this entry is already in the index // Load in the current amount of entries in the index file %USERVAR[Original_Link]% // Add to the count by 1 // Save the Count $Link_Counter$ // Save the new Link entry to the index $Link_Content$\n !links !Links !links %PARAM% // Check that the command was used at the beginning of a sentance %TRIGGER% // Pop a variable for later use // Load in the menucolour selected by the admins, if nothing found default is #c4# // Check if the script has been set to Public or Private Mode // If the user has selected to use private commands formulate how it should look for this query // Check which index file is currently in use // Check if the Index File exsists or not /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c9#You don't have any links saved yet, try posting a link now :) // Load in the Customisation Settings File to get the format that the user selected 0 $Custom_Format$ $Custom_Format$ // Replace some of the chosen format options with their real values (Static) $Custom_Browse_Format$ // Send the user the top of the menu %USERVAR[Server_Private_Command]% #c62#<· #c4#%USERVAR[Menu_Colour]%Your Submitted Links#c63#: // +1 the Param for the next Log Command 2 2 // Take the Parameter and Multiply it by the room owners chosen link amount (Default is 20) %PARAM% 1 1 // Read in the current amount of Log Entries // Start reading through the Log and stop when a maximum of 20 links are found or no links are found // Load in some information about this entry under the circumstance that the user wishes them to be loaded in their custom format %USERVAR[Index_Line_Result]% $Custom_Browse_Format_Saved$ // Replace some of the chosen format options with their real values (Dynamic) // Output the custom format with the link %USERVAR[Server_Private_Command]%#c1# #c1# #c4#%USERVAR[Menu_Colour]% · %USERVAR[Custom_Browse_Format]% // Let the user know that the ending has completed, Display to the user the next command prompt to view [n] more %USERVAR[Server_Private_Command]%#c1# #c1# #c1# #c4#%USERVAR[Menu_Colour]%Type #c63#"#c62#!FindLink [Link Name]#c63#" #c4#%USERVAR[Menu_Colour]% to search for a link #c62#·> %USERVAR[Server_Private_Command]%#c1# #c1# #c1# #c4#%USERVAR[Menu_Colour]%Type #c63#"#c62#!Links %USERVAR[NextNum]%#c63#" #c4#%USERVAR[Menu_Colour]%to view %USERVAR[Custom_Result_Amount]% more #c62#·> !findlink %PARAM% // Check that the command was used at the beginning of a sentance %TRIGGER% // Pop a variable for later use // Load in the menucolour selected by the admins, if nothing found default is #c4# // Check if the script has been set to Public or Private Mode // If the user has selected to use private commands formulate how it should look for this query // Check which index file is currently in use // Check if the Index File exsists or not /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c9#You don't have any links saved yet, try posting a link now :) // Load in the Customisation Settings File to get the format that the user selected 0 $Custom_Format$ $Custom_Format$ // Replace some of the chosen format options with their real values (Static) $Custom_Searching_Format$ // Send the user the top of the menu %USERVAR[Server_Private_Command]% #c62#<· #c4#%USERVAR[Menu_Colour]%Results for your Query#c63#: #c62#%PARAM% // Read in the current amount of Log Entries // Start reading through the Log and sending the user data and making a count so that the search stops at 20 results maximum 0 // Load in some information about this entry under the circumstance that the user wishes them to be loaded in their custom format %USERVAR[Index_Line_Result]% $Custom_Searching_Format_Saved$ // Replace some of the chosen format options with their real values (Dynamic) // Output the custom format with the link %USERVAR[Server_Private_Command]%#c1# #c1# #c4#%USERVAR[Menu_Colour]% · %USERVAR[Custom_Searching_Format]% // Output to the user the next Log command to view more entries %USERVAR[Server_Private_Command]%#c1# #c1# #c1# #c4#%USERVAR[Menu_Colour]%You received #c62#%USERVAR[SENTLINE]% #c4#Result #c62#·> %USERVAR[Server_Private_Command]%#c1# #c1# #c1# #c4#%USERVAR[Menu_Colour]%You received #c62#%USERVAR[SENTLINE]% #c4#Results #c62#·> !undoremove // Check that the command was used at the beginning of a sentance %TRIGGER% // Check if the Metis version is below v2.83 so we know that %USERMODE% works 1 0 0 0 // If the user doesn't have an @ in the User List, tell them they need to login to use this command and break #c4#Link Saver #c63#(#c62#v0.3#c63#): #c62#Login and show an #c62#@ #c9#in the userlist to use this command. // Display the removal message[s] using /notice if it's possible /hidecmd /notice #c4# /hidecmd /notice #c4# // ZCS and WCS v1.8.8 both report themselves as WinMX and they both support /hidecmd /notice so we will use that if WinMX is reported as the server /hidecmd /notice #c4# // Check which index file is currently in use // If the index file is Link.Index.Content.1.txt then write to Link.Index.Content.2.txt and vice versa Link.Index.Content.2.txt Link.Index.Content.1.txt // Save the new Index File Name $Write_To$ // Read back in the old count (before the erase) and put it back in to the new counter $Original_Link_Count$ // Tell the user that the previously removed links have been put back %USERVAR[Server_Notice_Command]%Link Saver #c63#(#c62#v0.3#c63#): #c62#Your previously erased link[s] have been restored back !removelink %PARAM% // Check that the command was used at the beginning of a sentance %TRIGGER% // Check if the Metis version is below v2.83 so we know that %USERMODE% works 1 0 0 0 // If the user doesn't have an @ in the User List, tell them they need to login to use this command and break #c4#Link Saver #c63#(#c62#v0.3#c63#): #c62#Login and show an #c62#@ #c9#in the userlist to use this command. // Pop a variable for later use // Load in the menucolour selected by the admins, if nothing found default is #c4# // Check if the script has been set to Public or Private Mode // If the user has selected to use private commands formulate how it should look for this query // Check which index file is currently in use // If the index file is Link.Index.Content.1.txt then write to Link.Index.Content.2.txt and vice versa Link.Index.Content.2.txt Link.Index.Content.1.txt // Wipe the Write_To file // Check if the Index File exsists or not /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c9#You don't have any links saved yet, try posting a link now :) // Load in the Customisation Settings File to get the format that the user selected 0 $Custom_Format$ $Custom_Format$ // Replace some of the chosen format options with their real values (Static) $Custom_Removed_Format$ // Display the removal message[s] using /notice if it's possible /hidecmd /notice #c4# /hidecmd /notice #c4# // ZCS and WCS v1.8.8 both report themselves as WinMX and they both support /hidecmd /notice so we will use that if WinMX is reported as the server /hidecmd /notice #c4# // Read in the current amount of Log Entries $Original_Link_Count$ 0 0 // Start reading through the Index File to locate the link[s] the user wants removed // If this entry isn't one we want to delete then forward it to the new index file $Index_Line_Result$ ~~~ %USERVAR[Index_Line_Result]%\n // Load in some information about this entry under the circumstance that the user wishes them to be loaded in their custom format %USERVAR[Index_Line_Result]% %USERVAR[Custom_Removed_Format_Saved]% // Replace some of the chosen format options with their real values (Dynamic) // Keep a counter of how many files have been deleted, when it matches the Maximum set in the configuration file, stop deleting. // Write a delete marker on the cache file Deleted\n // Output the custom format with the link %USERVAR[Server_Notice_Command]%%USERVAR[Custom_Removed_Format]% // If no links were found to be removed tell the admins that and break %USERVAR[Server_Notice_Command]%#c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c9#Unable to find any links which matched your remove query // Save the new Link Count $Total_Link_Count$ $Original_Link_Count$ // Save the new Index File Name $Write_To$ !privatelinks !publiclinks // Check if the command was typed at the start of a sentence, if not break %TRIGGER% // Check if the Metis version is below v2.83 so we know that %USERMODE% works 1 0 0 0 // If the user doesn't have an @ in the User List, tell them they need to login to use this command and break #c4#Link Saver #c63#(#c62#v0.3#c63#): #c62#Login and show an #c62#@ #c9#in the userlist to use this command. // Process which command the user typed 1\n 0 // Output to the Admins if it was set to Public Mode /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c1#Link Saver Has been set to Public Mode /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c62#When this is set to Public, all Link Saver Browse/Search results will be shown to the entire room // Break if the user selected to use Public // If the user selected PrivateLinkSaver, work out which server is in use 0 /hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@: /hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@: /message :@:RAWNAME:@::@:SPACE:@: #private :@:RAWNAME:@: #message:@:SPACE:@: // Because ZCS does not report itself as ZCS and instead as WinMX we are just going to assume that WinMX = ZCS /privnotice :@:RAWNAME:@::@:SPACE:@: // Save the command for later use %USERVAR[Server_Private_Command]% // Server not recognised Message /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c9#Link Saver cannot be set to Private in your room as the Server #c63#(#c62#%SERVER%#c63#)#c9# is not supported by the script currently 0 // Output to the Admins if it was set to Private Mode /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c1#Link Saver Has been set to Private Mode /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#c63#): #c62#When this is set to Private, only those who use the Link Searching/Browsing commands will see results // Check that WCS 1.8.8 is in use if the Server is reporting itself as WinMX 1 /stats WCS Version: %PARAM% // Tell the user that WCS was detected and that they may have seen some temporary garbled text /opmsg #c4#%USERVAR[Menu_Colour]%Link Saver #c63#(#c62#v0.3#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 // If WCS was detected then save that 1\n/hidecmd /privnotice :@:RAWNAME:@::@:SPACE:@: // Push 0 to Checking for WCS 0 !setlinkscolour %PARAM% !setlinkscolor %PARAM% // Check if the command was typed at the start of a sentence, if not break %TRIGGER% // Check if the Metis version is below v2.83 so we know that %USERMODE% works 1 0 0 0 // If the user doesn't have an @ in the User List, tell them they need to login to use this command and break #c4#Link Saver #c63#(#c62#v0.3#c63#): #c62#Login and show an #c62#@ #c9#in the userlist to use this command. // Encapsulate parameter with colour tags if none are present and save to file %PARAM%\n #c%PARAM%#\n // Output to the Admins what colour it has been set to /opmsg #c4#%PARAM%Link Saver #c63#(#c62#v0.3#c63#): #c1#Link Saver Has set its colours to#c63#: %PARAM% ||||| /opmsg #c4##c%PARAM%#Link Saver #c63#(#c62#v0.3#c63#): #c1#Link Saver Has set its colours to#c63#: #c%PARAM%# |||||