Advertisement
Guest User

CommandCleaner.xml

a guest
Oct 20th, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.89 KB | None | 0 0
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE muclient>
  3. <!-- Saved on Sunday, October 20, 2013, 11:56 PM -->
  4. <!-- MuClient version 4.77 -->
  5.  
  6. <!-- Plugin "CommandCleaner" generated by Plugin Wizard -->
  7.  
  8. <muclient>
  9. <plugin
  10.   name="CommandCleaner"
  11.   author="Vakieh"
  12.   id="d03e046d8561ad6eb7cc3958"
  13.   language="Lua"
  14.   purpose="Clears the command bar if it is left idle"
  15.   save_state="y"
  16.   date_written="2013-10-20 23:54:54"
  17.   requires="4.77"
  18.   version="1.0"
  19.   >
  20. <description trim="n">
  21. <![CDATA[
  22. Command Cleaner moves old entered commands into the command history if you leave them alone for a certain length of time - thus preventing accidental command entries if you start something like a channel comment then get distracted.
  23.  
  24. The cleared commands can be retrieved from the command history if necessary, by pressing the up arrow.
  25.  
  26. Usage:
  27. CommandCleaner:help
  28. - this help description and status display
  29.        
  30. CommandCleaner:setInterval ##
  31. - set the number of seconds between checks. Because of the way timers work, the actual time to clear the command bar is between the interval and 2x the interval, i.e with an interval of 15 it could be anywhere from 15-30 seconds.
  32.  
  33. Default is 60 seconds.
  34. ]]>
  35. </description>
  36.  
  37. </plugin>
  38.  
  39.  
  40. <!--  Get our standard constants -->
  41.  
  42. <include name="constants.lua"/>
  43.  
  44. <!--  Plugin help  -->
  45.  
  46. <aliases>
  47.   <alias
  48.   script="OnHelp"
  49.   match="CommandCleaner:help"
  50.   enabled="y"
  51.  >
  52.   </alias>
  53.  
  54.   <alias
  55.   script="setInterval"
  56.   match="CommandCleaner:setInterval (?<seconds>[0-9]+)"
  57.    regexp="y"
  58.    enabled="y"
  59.   >
  60.   </alias>
  61. </aliases>
  62.  
  63. <script>
  64. <![CDATA[
  65.  
  66. require "serialize"
  67.  
  68. function interval_handle ()
  69.    if previous == GetCommand() then
  70.        PushCommand()
  71.        check(AddTimer("interval_timer", 0, 0, interval, "", timer_flag.Enabled + timer_flag.Replace + timer_flag.Temporary, "interval_handle"))
  72.    end
  73.    previous = GetCommand()
  74. end
  75.  
  76. function setInterval (name, line, wildcards)
  77.    seconds = wildcards.seconds
  78.    seconds = tonumber(seconds)
  79.    if seconds ~= nil and seconds > 0 then
  80.        interval = seconds
  81.        world.Note("Setting command clearing interval to " .. interval .. " seconds.")
  82.    else
  83.        world.Note("Error, cannot set interval to " .. wildcards.seconds .. ".")
  84. end;
  85. end
  86.  
  87. function OnHelp ()
  88.    world.Note (world.GetPluginInfo (world.GetPluginID (), 3))
  89.    world.Note("Currently clearing command buffer when idle for at least " .. interval .. " seconds.")
  90. end
  91.  
  92. function OnPluginSaveState()
  93.    SetVariable("interval", interval)
  94. end
  95.  
  96. function OnPluginInstall()
  97.    OnPluginEnable()
  98. end
  99.  
  100. function OnPluginEnable()
  101.    previous = ""
  102.    interval = tonumber(GetVariable("interval")) or 60
  103.    check(AddTimer("interval_timer", 0, 0, interval, "", timer_flag.Enabled + timer_flag.Replace + timer_flag.Temporary, "interval_handle"))
  104. end
  105. ]]>
  106. </script>
  107.  
  108. </muclient>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement