Public paste
protection
By: cr | Date: Aug 23 2006 19:43 | Format: None | Expires: never | Size: 2.9 KB | Hits: 2172

  1. # -- protection
  2.  
  3.                 # -- variables
  4.                
  5.                         set secure(trigger)      "$"
  6.                        
  7.                         set secure(version)      "1.5 Beta"
  8.                         set secure(author)       "CrankY (cr@m2x.eu and #cr on irc.ec)"
  9.                        
  10.                 # -- settings
  11.        
  12.                         set secure(chanflags)    "A U b w t v o"
  13.                         set secure(modules)      "email DNS badchan"
  14.                        
  15.                         set secure(trust,file)   "database/trustlist.db"
  16.                         set secure(bchan,file)   "database/badchan.db"
  17.                        
  18.                 # -- setudef
  19.                
  20.                         # -- flag
  21.                        
  22.                                 setudef flag protection
  23.                                
  24.                         # -- str
  25.                        
  26.                                 setudef str secure_modules
  27.                                 setudef str secure_chanflags
  28.                                 setudef str secure_topic
  29.                                 setudef str secure_welcome
  30.                                 setudef str secure_id
  31.                                
  32.                                 setudef str secure_enabled
  33.                        
  34.                 # -- copyright
  35.                
  36.                         putlog "protection-script version $secure(version) scripted by $secure(author)"
  37.                        
  38.         # -- bindings
  39.        
  40.                 bind PUB   mn|mn   "$secure(trigger)protection" secure:script:protection
  41.                 bind PUB   mn|mn   "$secure(trigger)module"     secure:script:module
  42.                
  43.         # -- procs
  44.  
  45.                 proc secure:script:module {nickname hostname handle channel arguments} {
  46.                         global lastbind secure
  47.                        
  48.                         if {![channel get $channel "protection"]} {
  49.                                 putserv "PRIVMSG $channel :enable protection first."
  50.                                 return 0
  51.                         }
  52.                        
  53.                         set option  [lindex [split $arguments] 1]
  54.                         set lmodule [lindex [split $arguments] 0]
  55.                        
  56.                         if {$option == "" || $lmodule == ""} {
  57.                                 putserv "PRIVMSG $channel :usage: $lastbind 37module37 37on/off37."
  58.                                 return 0
  59.                         }
  60.                        
  61.                         if {![string match "*$lmodule*" "$secure(modules)"]} {
  62.                                 putserv "PRIVMSG $channel :unknown module '37$lmodule37'. - available modules are: [string map {" " ","} "$secure(modules)"]"
  63.                                 return 0
  64.                         }
  65.                        
  66.                         switch -- $option {
  67.                                
  68.                                 "on" {
  69.                                         if {![string match "*$lmodule*" "[channel get $channel "secure_modules"]"]} {
  70.                                                 putserv "PRIVMSG $channel :module '37$lmodule37'successfully loaded."
  71.                                                 channel set $channel secure_modules "[channel get $channel "secure_modules"] $lmodule"
  72.                                         } else {
  73.                                                 putserv "PRIVMSG $channel :module '37$lmodule37' is already loaded."
  74.                                         }
  75.                                 }
  76.                                
  77.                                 "off" {
  78.                                         if {![string match "*$lmodule*" "[channel get $channel "secure_modules"]"]} {
  79.                                                 putserv "PRIVMSG $channel :module '37$lmodule37' is not loaded."
  80.                                         } else {
  81.                                                 putserv "PRIVMSG $channel :module '37$lmodule37' successfully unloaded."
  82.                                                 channel set $channel secure_modules "[string map ""$lmodule" """ "[channel get $channel "secure_modules"]"]"
  83.                                         }
  84.                                 }
  85.                                
  86.                         }
  87.                        
  88.                 }
  89.        
  90.                 proc secure:script:protection {nickname hostname handle channel arguments} {
  91.                         global lastbind
  92.                        
  93.                         set option [lindex [split $arguments] 0]
  94.                        
  95.                         if {$option == ""} {
  96.                                 putquick "PRIVMSG $channel :usage: $lastbind 37on/off/status37"
  97.                                 return 0
  98.                         }
  99.                        
  100.                         switch -- $option {
  101.                                
  102.                                 "on" {
  103.                                 }
  104.                                
  105.                                 "off" {
  106.                                 }
  107.                                
  108.                                 "status" {
  109.                                 }
  110.                                
  111.                         }
  112.                        
  113.                 }
  114.        
  115.