Shadow19

The block command for commands filter in DPE

Jan 1st, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.73 KB | None | 0 0
  1. Thread.new(decoy) do |decoy|
  2.     if args[1] == "+"
  3.         if args[2].class == String
  4.             if args[2][/[^\d]/]
  5.                 id = getId(args[2])
  6.                 if id and !id[/[^\d]/]
  7.                     if !decoy["block"].index(id)
  8.                         decoy["block"].push(id)
  9.                         File.binwrite("filters/block.list",decoy["block"].to_s)
  10.                         decoy["<"].print(
  11.                             packet(
  12.                                 {
  13.                                     "m"=>{
  14.                                         "t"=>"#{id} was added to blocklist.",
  15.                                         "u"=>"0",
  16.                                         "i"=>"1"
  17.                                     }
  18.                                 }
  19.                             )
  20.                         )
  21.                     else
  22.                         decoy["<"].print(
  23.                             packet(
  24.                                 {
  25.                                     "m"=>{
  26.                                         "t"=>"#{args[2]} is already blocked.",
  27.                                         "u"=>"0",
  28.                                         "i"=>"1"
  29.                                     }
  30.                                 }
  31.                             )
  32.                         )
  33.                     end
  34.                 else
  35.                     decoy["<"].print(
  36.                         packet(
  37.                             {
  38.                                 "m"=>{
  39.                                     "t"=>"Invalid username: &quot;#{args[2]}&quot;.",
  40.                                     "u"=>"0",
  41.                                     "i"=>"1"
  42.                                 }
  43.                             }
  44.                         )
  45.                     )
  46.                 end
  47.             else
  48.                 decoy["block"].push(args[2])
  49.                 File.binwrite("filters/block.list",decoy["block"].to_s)
  50.                 decoy["<"].print(
  51.                     packet(
  52.                         {
  53.                             "m"=>{
  54.                                 "t"=>"#{args[2]} was added to blocklist.",
  55.                                 "u"=>"0",
  56.                                 "i"=>"1"
  57.                             }
  58.                         }
  59.                     )
  60.                 )
  61.             end
  62.         end
  63.     elsif args[1] == "-"
  64.         if args[2][/[^\d]/]
  65.             id = getId(args[2])
  66.             if id and !id[/[^\d]/]
  67.                 if decoy["block"].index(id)
  68.                     decoy["block"].delete(id)
  69.                     File.binwrite("filters/block.list",decoy["block"].to_s)
  70.                     decoy["<"].print(
  71.                         packet(
  72.                             {
  73.                                 "m"=>{
  74.                                     "t"=>"#{id} was removed from blocklist.",
  75.                                     "u"=>"0",
  76.                                     "i"=>"1"
  77.                                 }
  78.                             }
  79.                         )
  80.                     )
  81.                 else
  82.                     decoy["<"].print(
  83.                         packet(
  84.                             {
  85.                                 "m"=>{
  86.                                     "t"=>"#{args[2]} is not blocked.",
  87.                                     "u"=>"0",
  88.                                     "i"=>"1"
  89.                                 }
  90.                             }
  91.                         )
  92.                     )
  93.                 end
  94.             else
  95.                 decoy["<"].print(
  96.                     packet(
  97.                         {
  98.                             "m"=>{
  99.                                 "t"=>"Invalid username: &quot;#{args[2]}&quot;.",
  100.                                 "u"=>"0",
  101.                                 "i"=>"1"
  102.                             }
  103.                         }
  104.                     )
  105.                 )
  106.             end
  107.         else
  108.             decoy["block"].delete(args[2])
  109.             File.binwrite("filters/block.list",decoy["block"].to_s)
  110.             decoy["<"].print(
  111.                 packet(
  112.                     {
  113.                         "m"=>{
  114.                             "t"=>"#{args[2]} was removed from blocklist.",
  115.                             "u"=>"0",
  116.                             "i"=>"1"
  117.                         }
  118.                     }
  119.                 )
  120.             )
  121.         end
  122.     else
  123.         decoy["<"].print(
  124.             packet(
  125.                 {
  126.                     "m"=>{
  127.                         "t"=>"_//block +/- ID/USERNAME",
  128.                         "u"=>"0",
  129.                         "i"=>"1"
  130.                     }
  131.                 }
  132.             )
  133.         )
  134.     end
  135. end
Advertisement
Add Comment
Please, Sign In to add comment