Shadow19

Commands filter for DPE

Aug 19th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.62 KB | None | 0 0
  1. if direction == ">"
  2.     if decoy["done"] and data
  3.         if data.getAttr("t")
  4.             if data.getAttr("t")[0..1] == "//"
  5.                 args = data.getAttr("t").strip.split(" ")
  6.                 cmd = args[0].delete("^[a-zA-Z0-9\/\?]")[2..-1]
  7.                 argu = args[1..-1].join(" ")
  8.                 xdata = deepCopy(data)
  9.                 data = false #Making your message completely silent.
  10.                 Dir.mkdir("filters/commands") unless File.directory?("filters/commands")
  11.                 cmd_c = [Dir["#{File.expand_path(File.dirname(__FILE__))}/filters/commands/#{cmd}.rb"][0],Dir["#{File.expand_path(File.dirname(__FILE__))}/filters/commands/#{cmd}-*.rb"][0],Dir["#{File.expand_path(File.dirname(__FILE__))}/filters/commands/*-#{cmd}-*.rb"][0],Dir["#{File.expand_path(File.dirname(__FILE__))}/filters/commands/*-#{cmd}.rb"][0]].reject{|c|c == nil}[0] rescue (cmd_c = false)
  12.                 if cmd_c
  13.                     begin
  14.                         eval(File.binread(cmd_c))
  15.                     rescue Exception
  16.                         decoy["<"].print(
  17.                             packet(
  18.                                 {
  19.                                     "m"=>{
  20.                                         "t"=>"An error occured in &quot;#{cmd}&quot; command.",
  21.                                         "u"=>"0"
  22.                                     }
  23.                                 }
  24.                             )
  25.                         )
  26.                     end
  27.                 elsif cmd == "" or cmd == "?"
  28.                     decoy["<"].print(
  29.                         packet(
  30.                             {
  31.                                 "m"=>{
  32.                                     "t"=>"To create commands, you must create a file or files named command_name.rb in the filters folder, replace command_name with the command name of your choosing, you can also do command-cmd-cmnd.rb which will trigger when &quot;//command&quot; or &quot;//cmd&quot; or &quot;//cmnd&quot; is typed.",
  33.                                     "u"=>"0"
  34.                                 }
  35.                             }
  36.                         )
  37.                     )
  38.                 else
  39.                     decoy["<"].print(
  40.                         packet(
  41.                             {
  42.                                 "m"=>{
  43.                                     "t"=>"The command &quot;#{cmd}&quot; does not exist.",
  44.                                     "u"=>"0"
  45.                                 }
  46.                             }
  47.                         )
  48.                     )
  49.                 end
  50.             end
  51.         end
  52.     end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment