old but nice request script

Do you have script in mind but no ability to make it, type in what it should do, and you might be lucky.

old but nice request script

Postby timur » Wed Jul 16, 2008 2:50 am

hello

before i tell my prob sorry for my english ^^

(the scripter is offline)
ok i have a request script an old request script this one have a prob the hub bot check from #yourchan the #requestchan he dont join #requestchan

but the new service from q is invisible also the hub bot must join the #requestchan and than check allone can anyone edit the cript please ...

Code: Select all
 #
 #    Request Hub Bot
 #      alias request.tcl
 #      alias Watchdog
 #      by #p0wl
 #     
 
 # - NameSpace - #

     namespace eval ::request {
        
     # - Load Scripts - #
     
          # Settings
         
           source scripts/settings.tcl
     
          # Types
         
           source scripts/types.tcl
         
           

     # - Settings - #

          # Channels

              # Channel: Main

            set channel(main) [settings channel main]

       
              # Channel: intern

            set channel(intern) [settings channel intern]


              # Channel: Support

            set channel(support) [settings channel support] 


          # Info

              # Hp

            set info(hp) [settings info hp]


          # File

              # Blacklist File

            set file(blist) [settings file blist]


              # Stats File

            set file(stats) [settings file stats]


          # Time

              # Blacklist Standart Time in Hours

            set time(blist,standart) [settings time blist]

              # Host Block Time in Minutes

            set time(host,block) [settings time host,block]


              # Chan Time in Minutes

            set time(chan,block) [settings time chan,chan]


              # Request Timeout in Seconds

            set time(out) [settings time out]

           
          # Hosts

              # Bad Hosts

            set badhosts [settings badhost]


     # - Setudef - #

          # Request

           setudef flag request


     # - Binds - #

          # Public

              # Admin
           bind pub  nm|- .request   ::request::admin
           bind pub  nm|- .req       ::request::admin

              # Bot
           bind pub  nm|- .bot       ::request::pubbot

              # Load
           bind pub  nm|- .load      ::request::doload
           bind pub  nm|- .reload    ::request::doload

              # Unblock
           bind pub  nm|- .unblock   ::request::unblock
           bind pub  nm|- .ub        ::request::unblock

              # Blacklist
           bind pub  nm|- .blacklist ::request::blacklist
           bind pub  nm|- .blist     ::request::blacklist

              # All Users
           bind pub   -|- ?request   ::request::pub
           bind pub   -|- !request   ::request::pub

          # Join/Part

              # Join
           bind join  -|- *          ::request::rawjoin

          # BOT

              # Me
           bind bot   -|- "ME"       ::request::bot

              # Stats
           bind bot   -|- "STATS"    ::request::bot

              # Blacklist
           bind bot   -|- BLACKLIST  ::request::bot

              # Getsettings
           bind bot   -|- GETSET     ::request::bot


          # RAW

              # Who
           bind raw   -|- 354        ::request::raw

              # List
           bind raw   -|- 322        ::request::raw

              # Whois
           bind raw   -|- 319        ::request::raw

              # Names
           bind raw   -|- 353        ::request::raw

              # Names End
           bind raw   -|- 366        ::request::raw

          # Time

              # Sync
           bind time  -|- "23 *"     ::request::sync

     # - Procs - #

          # pubbot

       proc pubbot { nick host hand chan arg } {

             set arg [split $arg]

             switch -- [string toupper [lindex $arg 0]] {

                 BROADCAST {

                     if {[lindex $arg 1] == ""} {
                         putserv "privmsg $chan :\002Wrong Usage\002 Try $::lastbind [lindex $arg 0] <text>"
                         return
                     }

                     putallbots "BROADCAST [lrange $arg 1 end]"

                     putserv "privmsg $chan :\002Done\002. Sent to [llength [bots]] Bots."

                 }

                 ADD {

                     if {[lindex $arg 1] == "" || [string index [lindex $arg 2] 0] != "#" || [lindex $arg 3] == ""} {
                         putserv "privmsg $chan :\002Wrong Usage\002 Try $::lastbind [lindex $arg 0] <bot> <#chan> <owner>"
                         return
                     }
                     
                     if {[lindex $arg 1] == "all"} {
                        
                        foreach bot [bots] {
                           
                            putbot $bot "ADD [lindex $arg 2] [lindex $arg 3]"
                           
                         }
                        
                          putserv "privmsg $chan :\002Done\002 Added \037[llength [bots]]\037 Bots for [lindex $arg 2] with owner [lindex $arg 3]"
                         
                          return
                           
                     }
                     



                     if {[islinked [lindex $arg 1]]} {
                         set bot [lindex $arg 1]
                     } elseif {[islinked [nick2hand [lindex $arg 1]]]} {
                         set bot [nick2hand [lindex $arg 1]]
                     } else {
                         putserv "privmsg $chan :\002Error\002 Don't know any bot matching [lindex $arg 1]"
                         return
                     }

                     putbot $bot "ADD [lindex $arg 2] [lindex $arg 3]"
                     
                     putserv "privmsg $chan :\002Done\002 Added \037$bot\037 for [lindex $arg 2] with owner [lindex $arg 3]"

                 }

                 REMOVE - DEL {

                     if {[lindex $arg 1] == "" || [string index [lindex $arg 2] 0] != "#" || [lindex $arg 2] == ""} {
                         putserv "privmsg $chan :\002Wrong Usage\002 Try $::lastbind [lindex $arg 0] <bot> <#chan>"
                         return
                     }
                     
                     if {[lindex $arg 1] == "all"} {
                        
                        foreach bot [bots] {
                           
                            putbot $bot "DEL [lindex $arg 2]"
                           
                         }
                        
                          putserv "privmsg $chan :\002Done\002 Removed \037[llength [bots]]\037 Bots from [lindex $arg 2]"
                         
                          return
                           
                     }

                     if {[islinked [lindex $arg 1]]} {
                         set bot [lindex $arg 1]
                     } elseif {[islinked [nick2hand [lindex $arg 1]]]} {
                         set bot [nick2hand [lindex $arg 1]]
                     } else {
                         putserv "privmsg $chan :\002Error\002 Don't know any bot matching [lindex $arg 1]"
                         return
                     }

                     putbot $bot "DEL [lindex $arg 2]"
                     
                     putserv "privmsg $chan :\002Done\002 Removed \037$bot\037 from [lindex $arg 2]"

                 }

                 CHANFLAG {

                     if {[string index [lindex $arg 2] 0] != "#" || [lindex $arg 3] == ""} {
                         putserv "privmsg $chan :\002Wrong Usage\002 Try $::lastbind [lindex $arg 0] <bot> <#chan> <+/-CHANFLAG>"
                         return
                     }
                     
                     if {[lindex $arg 1] == "all"} {
                        
                        foreach bot [bots] {
                           
                            putbot $bot "CHANFLAG [lindex $arg 2] [lindex $arg 3]"
                           
                         }
                        
                          putserv "privmsg $chan :\002Done\002 Chanflag \037[llength [bots]]\037 Bots for [lindex $arg 2] changed"
                         
                          return
                           
                     }

                     if {[islinked [lindex $arg 1]]} {
                         set bot [lindex $arg 1]
                     } elseif {[islinked [nick2hand [lindex $arg 1]]]} {
                         set bot [nick2hand [lindex $arg 1]]
                     } else {
                         putserv "privmsg $chan :\002Error\002 Don't know any bot matching [lindex $arg 1]"
                         return
                     }

                     putbot $bot "CHANFLAG [lindex $arg 2] [lindex $arg 3]"
                     
                     putserv "privmsg $chan :\002Done\002 Chanflag \037$bot\037 for [lindex $arg 2] changed."

                 }

                 INFO {

                     if {[lindex $arg 1] == ""} {
                         putserv "privmsg $chan :\002Wrong Usage\002 Try $::lastbind [lindex $arg 0] <#channel/bot>"
                         return
                     }
                     
                     if {[string index [lindex $arg 1] 0] == "#"} {

                         foreach bot [bots] {

                             if {[lsearch [string toupper [join [getuser $bot XTRA channels]]] [string toupper [lindex $arg 1]]] >= 0} {

                                 lappend founded "$bot ([getuser $bot XTRA type])"

                             }

                         }

                         if {![info exists founded]} {

                             putserv "privmsg $chan :\002Error\002 Can't find any bot on \037[lindex $arg 1]\037"

                         } else {

                             putserv "privmsg $chan :\002Bots\002 on \037[lindex $arg 1]\037: $founded"

                         }
                         
                     } else {
                        
                        if {[islinked [lindex $arg 1]]} {
                             set bot [lindex $arg 1]
                         } elseif {[islinked [nick2hand [lindex $arg 1]]]} {
                             set bot [nick2hand [lindex $arg 1]]
                         } else {
                             putserv "privmsg $chan :\002Error\002 Don't know any thing matching [lindex $arg 1]"
                             return
                         }
                         
                         putserv "privmsg $chan :\002$bot\002 Info: \037Type\037 [getuser $bot XTRA type] \037Chans\037 [llength [getuser $bot XTRA channels]]"
                         
                     }
                         
                     
                     

                 }

                 STATS {

                     if {[lindex $arg 1] == ""} {

                         set chans 0

                         foreach bot [bots] {

                             incr chans [llength [join [getuser $bot XTRA channels]]]
                             set curr [getuser $bot XTRA type]

                             if {![info exists ctype($curr)]} { set ctype($curr) 0 }
                             incr ctype($curr)

                         }

                         putserv "privmsg $chan :\002Stats\002 \037[llength [bots]]\037 Bots on \037$chans\037 Channels."

                         foreach ty [array names ctype] {

                             putserv "privmsg $chan :\002Stats\002 Type: \037$ty\037 Chans: \037$ctype($ty)\037"

                         }

                         return

                     }

                     if {[set f [lsearch [string toupper [array names ::request::type *,trigger]] [string toupper "[lindex $arg 1],trigger"]]] >= 0} {

                         set chans 0

                         foreach bot [bots] {

                             if {![string equal -nocase [getuser $bot XTRA type] [lindex $arg 1]]} { continue }

                             incr chans [llength [join [getuser $bot XTRA channels]]]

                         }

                         putserv "privmsg $chan :\002Stats\002 Type: \037[lindex [split [lindex [array names ::request::type *,trigger] $f] ,] 0]\037 Channels: \037$chans\037"

                         return

                     } else {

                         putserv "privmsg $chan :\002Stats\002 \037Error\037 No such Type: \037[lindex $arg 1]\037"

                     }

                 }                         

             }


       }



          # Getbot

       proc getbot { type chan } {

             set best 0
             set min 20

             foreach bot [bots] {

                 if {![islinked $bot]} { continue }

                 if {[string equal -nocase [getuser $bot XTRA type] $type]} {

                      if {[lsearch [string toupper [join [getuser $bot XTRA channels]]] [string toupper $chan]] >= 0} { set best 0; break }

                      if {[llength [join [getuser $bot XTRA channels]]] < $min} {

                           set best $bot
                           set min [llength [join [getuser $bot XTRA channels]]]

                      }
 
                 }

             }

             if {$best == 0} { return 0 }

             utimer 10 [putbot $best "REQUEST SYNC"]

             return $best

       }

          # Sync

       proc sync { args } {

             ::request::loadbots

             foreach bot [bots] {

                 if {![islinked $bot]} {

                     link $bot

                 }

             }

             return 1

       }


          # Bot

       proc bot {from command text} {

             switch -- [string toupper $command] {

                 ME {

                     set type [lindex [split $text :] 0]

                     setuser $from XTRA type $type

                     setuser $from XTRA channels [join [lrange [split $text :] 1 end]]

                 }

                 BLACKLIST {

                     set chan [lindex [split $text :] 0]

                     set reason [lrange [split $text :] 1 end]

                     ::request::blist:add $chan $from $reason $::request::time(blist,standart)

                     putbot $from "REQUEST SYNC" 

                 }

                 GETSET { 

                     if {[set pr [lsearch [string toupper [array names ::request::type *,trigger]] [string toupper "[lindex [split $text] 0],trigger"]]] < 0} {

                         return

                     }

                     set typ [lindex [split [lindex [array names ::request::type *,trigger] $pr] ,] 0]

                     putbot $from "REQUEST SET $typ $::request::type($typ,minuser) $::request::type($typ,rights)"

                 }

              }


       }

   
          # loadbots

       proc loadbots {} {

             foreach bot [bots] {

                 if {![islinked $bot]} {

                     link $bot

                     lappend nolink $bot

                     continue

                 }

             }

             if {[info exists nolink]} {

                 putlog "\002BOTNET\002 No Link to [llength $nolink] Bots: $nolink"

             }

             putallbots "REQUEST SYNC"

       }

                 

          # DoLoad

       proc doload { nick host hand chan arg } {

            set sta [::request::load]

            if {$sta != 1} {

                 putserv "privmsg $chan :\002Error\002 Can't load request script! Please contact #p0wl"
                 return

            }

            putserv "privmsg $chan :\002Request\002 \037Loaded!\037 Request enabled, checking auths in $::request::channel(main)"

            if {[string equal -nocase $::lastbind ".reload"]} { return }

            putserv "privmsg $chan :\002Request\002 You have to enable the Type specific Requests! Try \037.request <type> on\037 or \037.requests status\037"

            set total 0

            foreach ars [array names ::request::type *,trigger] {

                 incr total

                 lappend types [lindex [split $ars ,] 0]

            }

            putserv "privmsg $chan :\002Request\002 \037Settings\037 I know \037$total\037 Bot Types ($types). I know [llength [bots]] Bots."

       }

          # Pub

       proc pub { nick host hand chan arg } {

             if {![string equal -nocase $::request::channel(main) $chan] && ![string equal -nocase $::request::channel(intern) $chan] && ![string equal -nocase $::request::channel(support) $chan]} { return }

             set arg [split $arg]

             if {[info exists ::request::as(pub)] && $::request::as(pub) > [unixtime]} {

                 putserv "notice $nick :Trigger has just been used. Please wait [duration [expr {$::request::as(pub) - [unixtime]}]]."
                 return

             }

             if {[onchan [lindex $arg 1] $chan]} { set nick [lindex $arg 1] }

             switch -- [string toupper [lindex $arg 0]] {

                 HP - HOMEPAGE {

                     putserv "privmsg $chan :($nick) \002RequestHomepage\002 $::request::info(hp)"

                     set ::request::as(pub) [expr {[unixtime] + 10}]

                 }

                 BOTS - TYPES - TYPE {

                     set tol 0

                     set types [list]

                     foreach ars [array names ::request::type *,trigger] {

                         lappend types [lindex [split $ars ,] 0]

                         incr tol

                     }

                     putserv "privmsg $chan :($nick) \002Bot-Types\002 We have \037$tol\037 Bot Types: $types"

                     set ::request::as(pub) [expr {[unixtime] + 10}]

                 }

                 SUPPORT {

                     if {[string equal -nocase $::request::channel(support) $::request::channel(main)]} {

                         putserv "privmsg $chan :($nick) \002Support\002 Just ask here! No need to Qry!"

                     } else {

                         putserv "privmsg $chan :($nick) \002Support\002 Join $::request::channel(support) and stay tuned."

                     }

                     set ::request::as(pub) [expr {[unixtime] + 5}]

                 }

                 P0WL {

                     putserv "privmsg $chan :\002#p0wl\002 $nick: m0wl!"

                     set ::request::as(pub) [expr {[unixtime] + 2}]

                 }

                 HELP {

                     foreach ars [array names ::request::type *,trigger] {

                         putserv "privmsg $chan :($nick) \002Request\002 To Request a \037[lindex [split $ars ,] 0]\037 Bot (You need $::request::type([lindex [split $ars ,] 0],minuser) Users) type /msg $::botnick $::request::type($ars) #yourchannel"

                     }

                     set ::request::as(pub) [expr {[unixtime] + 30}]

                 }

                 default {

                     if {[onchan [lindex $arg 0] $chan]} { set nick [lindex $arg 0] }

                     foreach ars [array names ::request::type *,trigger] {

                         putserv "privmsg $chan :($nick) \002Request\002 To Request a \037[lindex [split $ars ,] 0]\037 Bot (You need $::request::type([lindex [split $ars ,] 0],minuser) Users) type /msg $::botnick $::request::type($ars) #yourchannel"

                     }

                     set ::request::as(pub) [expr {[unixtime] + 30}]

                 }

             }

       }




          # Unblock

       proc unblock { nick host hand chan arg } {

             if {[lindex [split $arg] 0] == "" || [lindex [split $arg] 0] == "*"} {

                 array unset ::request::block
                 putserv "privmsg $chan :\002Done\002 Unblocked \037all\037 blocked Channels and nicks."

             } elseif {([string equal -nocase [lindex [split $arg] 0] "#"]) || ([string equal -nocase [lindex [split $arg] 0] "#*"])} {

                 foreach ars [array names ::request::block] {

                     if {[string equal -nocase [string index $ars 0] "#"]} {

                         unset ::request::block($ars)

                     }

                 }

                 putserv "privmsg $chan :\002Done\002 Unblocked \037all\037 blocked Channels."

             } else {

                 set total 0

                 foreach ars [array names ::request::block] {

                     if {[string match -nocase [lindex [split $arg] 0] $ars]} {

                         incr total

                         unset ::request::block($ars)

                     }

                 }

                 if {$total == 0} {

                     putserv "privmsg $chan :\002Error\002 Can't find any block matching [lindex [split $arg] 0]"

                 } else {

                     putserv "privmsg $chan :\002Done\002 Unblocked \037$total\037 blocks."

                 }

             }

       }

          # Admin

       proc admin { nick host hand chan arg } {

             set arg [split $arg]

             foreach ars [array names ::request::type] {

                 if {[string equal -nocase [lindex $arg 0] [lindex [split $ars ,] 0]]} {

                     switch -- [string toupper [lindex $arg 1]] {

                         ON {

                             channel set $chan +[lindex [split $ars ,] 0]
                             putserv "privmsg $chan :\002Request\002 \037Status\037 enabled \037[lindex [split $ars ,] 0]\037."

                         }

                         OFF {

                             channel set $chan -[lindex [split $ars ,] 0]
                             putserv "privmsg $chan :\002Request\002 \037Status\037 disabled \037[lindex [split $ars ,] 0]\037."

                         }

                         default {

                             set status [string map {1 on 0 off} [channel get $chan [lindex [split $ars ,] 0]]]
                             putserv "privmsg $chan :\002Request\002 \037Status\037 [lindex [split $ars ,] 0] is \037$status\037."

                         }

                     }

                     return

                 }

             }

             switch -- [string toupper [lindex $arg 0]] {

                 ON {

                     channel set $chan +request
                     putserv "privmsg $chan :\002Request\002 \037enabled\037"

                 }

                 OFF {

                     channel set $chan -request
                     putserv "privmsg $chan :\002Request\002 \037disabled\037"

                 }

                 STATUS {

                     set totalstatus [string map {1 on 0 off} [channel get $chan request]]

                     foreach ars [array names ::request::type *,trigger] {

                        lappend status "[lindex [split $ars ,] 0] [string map {1 on 0 off} [channel get $chan [lindex [split $ars ,] 0]]]"

                     }

                     putserv "privmsg $chan :\002Request\002 \037Status\037 $status"
                     putserv "privmsg $chan :\002Request\002 \037Total Status\037 \002$totalstatus\002"

                 }

                 STATS {

                     set total1 0; set total0 0

                     foreach ars [array names ::request::type *,trigger] {

                         if {[lindex $arg 1] == "" || [string equal -nocase [lindex $arg 1] all]} {

                             set curr1 [::request::stats [lindex [split $ars ,] 0] show1]
                             set curr0 [::request::stats [lindex [split $ars ,] 0] show0]

                             putserv "privmsg $chan :\002Request\002 \037Stats\037 [lindex [split $ars ,] 0] oK: $curr1 failed: $curr0"
                             incr total1 $curr1
                             incr total0 $curr0

                         } elseif {[string equal -nocase [lindex $arg 1] [lindex [split $ars ,] 0]]} {

                             putserv "privmsg $chan :\002Request\002 \037Stats\037 [lindex [split $ars ,] 0] oK: [::request::stats [lindex [split $ars ,] 0] show1] failed: [::request::stats [lindex [split $ars ,] 0] show0]"
                             return

                         }

                     }

                     putserv "privmsg $chan :\002Request\002 \037Stats\037 \002Total\002 oK: $total1 failed: $total0"
 
                 }

             }

       }




          # WriteStats

       proc writestats {} {

             set f [open $::request::file(stats) w]

             foreach ars [array names ::request::count] {

                 puts $f "[lindex [split $ars ,] 0] [lindex [split $ars ,] 1] $::request::count($ars)"

             }

             close $f

       }



          # LoadStats

       proc loadstats {type do} {

              if {![file exists ::request::file(stats)]} {

                 set f [open $::request::file(stats) w]
                 close $f

              }

              set founded 0

              set f [open $::request::file(stats) r]

              while {![eof $f]} {

                 gets $f line

                 if {$line == "" || $line == " "} { continue }

                 if {[string equal -nocase $type [lindex [split $line] 0]] && [string equal -nocase $do [lindex [split $line] 1]]} {

                      set founded [lindex [split $line] 2]

                 }

             }

             close $f

             return $founded

       }



          # Stats

       proc stats {type do} {

             if {[string equal -nocase show0 $do]} {

                 if {![info exists ::request::count($type,0)]} {

                     return [::request::loadstats $type 0]

                 } else {

                     return $::request::count($type,0)

                 }

             }

             if {[string equal -nocase show1 $do]} {

                 if {![info exists ::request::count($type,1)]} {

                     return [::request::loadstats $type 1]

                 } else {

                     return $::request::count($type,1)

                 }

             }

             if {![info exists ::request::count($type,$do)]} {

                 set ::request::count($type,$do) [expr {[::request::loadstats $type $do] + 1}]

             } else {

                 incr ::request::count($type,$do)

             }

             return 1

       }



          # Blist Check

       proc blist:check { name } {

             set founded 0

             set f [open $::request::file(blist) r]

             while {![eof $f]} {

                 set line [gets $f]

                 if {($line == "") || ($line == " ")} { continue }

                 set currname [lindex $line 0]

                 set currtime [lindex $line 3]

                 if {($currtime != 0) && ($currtime < [unixtime])} {

                      set rewrite 1

                      continue

                 }

                 if {[string match -nocase $name $currname]} {

                      set founded [string range $line 0 end]

                 }

                 append newfile "$line\n"

             }

             close $f

             if {[info exists rewrite] && [info exists newfile]} {

                 set f [open $::request::file(blist) w]

                 puts $f $newfile

                 close $f
 
             }

             if {[info exists founded]} {

                 return $founded

             } else {

                 return 0

             }

       }


          # Blist Add

       proc blist:add {name by reason time} {

             if {[string index $name 0] != "#"} {

                 if {[onchan $name]} {

                     set name *![getchanhost $name]

                 } elseif {[string match -nocase *@* $name] && [string match -nocase *!* $name]} {

                     set name $name

                 } elseif {[string match -nocase *@* $name]} {

                     set name *!$name

                 } elseif {[string match -nocase *!* $name]} {

                     set name $name@*

                 } else {

                     set name $name!*@*

                 }

             }

             if {($time != 0)} {

                 set time [expr {[unixtime] + $time *60*60}]

             }

             if {![file exists $::request::file(blist)]} {

                 set f [open $::request::file(blist) w]
                 close $f

             }

             if {[::request::blist:check $name] != 0} {

                 return "Allready added."

             }

             set f [open $::request::file(blist) a]

             puts $f [list $name $by $reason $time]

             close $f

             return "1 $name"

       }


          # Blist Del

       proc blist:del {name} {

             if {![file exists $::request::file(blist)]} {
                 return "Can't find $::request::file(blist)"
             }

             if {[string index $name 0] != "#"} {

                 if {[onchan $name]} {

                     set name *![getchanhost $name]
 
                 } elseif {[string match -nocase *@* $name] && [string match -nocase *!* $name]} {

                     set name $name

                 } elseif {[string match -nocase *@* $name]} {

                     set name *!$name

                 } elseif {[string match -nocase *!* $name]} {
     
                     set name $name@*

                 } else {

                     set name $name!*@*
     
                 }

             }

             if {[::request::blist:check $name] == "0"} {

                 return "Can't find $name on Blacklist."

             }

             set newfile ""

             set f [open $::request::file(blist) r]

             while {![eof $f]} {

                 gets $f line
 
                 if {($line == "") || ($line == " ")} { continue }

                 if {![string match -nocase $name [lindex [split $line] 0]]} {

                     append newfile "$line\n"

                 }

             }

             close $f

             set f [open $::request::file(blist) w]

             puts $f $newfile

             close $f

             return 1

       }


          # Blist Match

       proc blist:match {name} {

             set f [open $::request::file(blist) r]

             while {![eof $f]} {
                 gets $f line

                 if {($line == "") || ($line == " ")} { continue }

                 if {[string match -nocase $name [lindex [split $line] 0]]} {

                     lappend founded $line

                 }

             }

             close $f

             if {![info exists founded]} {

                 return ""

             } else {

                 return $founded

             }

       }


          # Blist Info
       proc blist:info {name} {

             if {![file exists $::request::file(blist)]} {
                 return "Can't find $::request::file(blist)"
             }

             if {[string index $name 0] != "#"} {

                 if {[onchan $name]} {

                     set name *![getchanhost $name]

                 } elseif {[string match -nocase *@* $name] && [string match -nocase *!* $name]} {

                     set name $name

                 } elseif {[string match -nocase *@* $name]} {

                     set name *!$name

                 } elseif {[string match -nocase *!* $name]} {

                     set name $name@*

                 } else {

                     set name $name!*@*

                 }

             }

             if {[::request::blist:check $name] == 0} {

                 return "Can't find $name on Blacklist."

             }

             set f [open $::request::file(blist) r]

             while {![eof $f]} {

                 gets $f line

                 if {($line == "") || ($line == " ")} { continue }

                 if {[string match -nocase $name [lindex [split $line] 0]]} {

                     set founded [join $line]

                 }

             }

             close $f

             return $founded

       }


          # Blist stats
       proc blist:stats {} {

             set total 0
             set chans 0
             set nicks 0

             set f [open $::request::file(blist) r]

             while {![eof $f]} {

                 gets $f line

                 if {($line == "") || ($line == " ")} { continue }

                 if {[string index $line 0] == "#"} {

                     incr chans

                 } else {

                     incr nicks

                 }

                 incr total

             }

             close $f

             return "$total $chans $nicks"

       }


          # Pub

       proc blacklist {nick host hand chan arg} {

             set arg [split $arg]

             switch -- [string tolower [lindex $arg 0]] {

                 add {

                     if {[lindex $arg 1] == "" || [lindex $arg 2] == ""} {
                         putserv "notice $nick :\002Error\002 \037Wrong usage\037 Try $::lastbind [lindex $arg 0] <#chan/nick/host> <reason> \[time\]"
                         return
                     }

                     if {[string is digit [lindex $arg [expr {[llength $arg] - 1}]]]} {

                         set time [lindex $arg [expr {[llength $arg] - 1}]]
                         set reason [lrange $arg 2 end-1]

                     } else {

                         set time $::request::time(blist,standard)
                         set reason [lrange $arg 2 end]

                     }
 
     
                     set error [::request::blist:add [lindex $arg 1] $nick $reason $time]

                     if {[lindex [split $error] 0] == 1} {

                        putserv "privmsg $chan :\002Done\002 Added \037[lindex [split $error] 1]\037"

                     } else {
   
                        putserv "privmsg $chan :\002Error\002 $error"

                     }

                 }

                 del - remove {

                     if {[lindex $arg 1] == ""} {
                        putserv "notice $nick :\002Error\002 \037Wrong usage\037 Try $::lastbind [lindex $arg 0] <#chan/nick/host>"
                        return
                     }

                     set error [::request::blist:del [lindex $arg 1]]

                     if {$error == 1} {

                        putserv "privmsg $chan :\002Done\002"

                     } else {
   
                        putserv "privmsg $chan :\002Error\002 $error"

                     }

                 }

                 info - status {

                     if {[lindex $arg 1] == ""} {
                        putserv "notice $nick :\002Error\002 \037Wrong usage\037 Try $::lastbind [lindex $arg 0] <#chan/nick/host>"
                        return
                     }

                     set error [::request::blist:check [lindex $arg 1]]

                     if {$error == 0} {

                        putserv "privmsg $chan :\002Blacklist\002 Can't find \037[lindex $arg 1]\037 on the BlackList."

                     } else {
     
                        if {[lindex $error 3] == 0} {

                           putserv "privmsg $chan :\002Blacklist Info\002 For \037[lindex $error 0]\037: Added by \037[lindex $error 1]\037 Time Remaining: \037BANNED FOREAVER!\037"

                        } else {
   
                           putserv "privmsg $chan :\002Blacklist Info\002 For \037[lindex $error 0]\037: Added by \037[lindex $error 1]\037 Time Remaining: \037[duration [expr {[lindex $error 3] - [unixtime]}]]\037"

                        }

                        putserv "privmsg $chan :\002Blacklist Info\002 \037Reason\037 [lindex $error 2]"

                     }

                 }

                 stats {

                     set error [split [::request::blist:stats]]

                     putserv "privmsg $chan :\002Stats\002 \037Total\037 [lindex $error 0] \037Blacklisted Chans\037 [lindex $error 1] \037Blacklisted Nicks/Hosts\037 [lindex $error 2]"

                 }

                 help {

                     puthelp "notice $nick :\002Blacklist\002 \037Hinzufügen\037 $::lastbind add <#chan/nick/host> <reason> \[time\]"
                     puthelp "notice $nick :\002Blacklist\002 \037Entfernen\037  $::lastbind del <#chan/nick/host>"
                     puthelp "notice $nick :\002Blacklist\002 \037Info\037       $::lastbind info <#chan/nick/host>"
                     puthelp "notice $nick :\002Blacklist\002 \037Statistik\037  $::lastbind stats"
                     puthelp "notice $nick :\002Blacklist\002 \037Suchen\037     $::lastbind <*mask*>"

                 }

                 default {

                     if {[lindex $arg 1] == ""} {

                         set matches [::request::blist:match *]

                     } else {

                         set matches [::request::blist:match [lindex $arg 1]]

                     }

                     putserv "privmsg $chan :\002Blacklist\002 Listing Matches..."

                     foreach error $matches {

                         puthelp "privmsg $chan :\002Blacklist\002 Match: \037[lindex $error 0]\037: Added by \037[lindex $error 1]\037 Reason: \037[lindex $error 2]\037"

                     }

                     puthelp "privmsg $chan :\002Blacklist\002 End of list."

                 }

             }

       }





          # Finish
     
       proc finish {typ} {

             if {![info exists ::request::curr($typ,chan)] || ![info exists ::request::curr($typ,nick)] || ![info exists ::request::curr($typ)]} {
                 return
             } else {
                 set nick $::request::curr($typ,nick)
                 set chan $::request::curr($typ,chan)
             }

             if {![info exists ::request::curr($typ,op)]} {
                 putquick "notice $nick :\002Request\002 \037Failed\037 Can't find this Channel. Try /mode $::request::curr($typ,chan) -sp"
                 ::request::stats $typ 0
             } elseif {$::request::curr($typ,op) == 0} {
                 putquick "notice $nick :\002Request\002 \037Failed\037 Can't find you on this Channel. Try /mode $::request::curr($typ,chan) -sp"
                 ::request::stats $typ 0
             } elseif {$::request::curr($typ,op) == 2} {
                 putquick "notice $nick :\002Request\002 \037Failed\037 You need to be opped on $::request::curr($typ,chan)"
                 ::request::stats $typ 0
             } elseif {![info exists ::request::curr($typ,users)]} {
                 putquick "notice $nick :\002Request\002 \037Failed\037 Can't find your Channel! Try /mode $::request::curr($typ,chan) -sp"
                 ::request::stats $typ 0
             } elseif {$::request::curr($typ,users) < $::request::type($typ,minuser)} {
                 putquick "notice $nick :\002Request\002 \037Failed\037 You need at least $::request::type($typ,minuser) Users! You have $::request::curr($typ,users)"
                 ::request::stats $typ 0
             } elseif {![info exists ::request::curr($typ,chanbot)]} {
                 putquick "notice $nick :\002Request\002 \037Failed\037 You need [chanbot 1] or [chanbot 0] on your Channel!"
                 ::request::stats $typ 0
             } else {
                 putquick "notice $nick :\002Request\002 \037Successfull\037 Adding $::request::curr($typ,bot)"
                 putserv "privmsg $::request::channel(intern) :\002$typ Request\002 \037Successfull\037 by \037$nick\037 for \037$::request::curr($typ,chan)\037. Added \037$::request::curr($typ,bot)\037"
                 ::request::stats $typ 1

                 putbot $::request::curr($typ,bot) "ADD $chan $nick"
             }

             utimer 5 [unset ::request::curr($typ)]

             foreach ars [array names ::request::curr $typ,*] {

                 unset ::request::curr($ars)

             }

       }

          # Badhost
       proc badhost {address} {

             set founded 0

             foreach ars [split $::request::badhosts] {

                 if {[string match -nocase $ars $address]} {

                      set founded 1

                 }

             }

             return $founded
       }

          # Load

       proc loadauths {} {

             set time 1

             foreach nick [chanlist $::request::channel(main)] {

                 if {![info exists ::request::auth([getchanhost $nick])]} {

                      if {[regexp -nocase -- {@(.+?)\.users.quakenet.org} [getchanhost $nick] -> auth]} {

                           set ::request::auth([getchanhost $nick]) $auth

                      } else {

                          utimer $time [list puthelp "who $nick n%auh"]
                          incr time 2

                      }

                 }

            }
 
            return 1

       }



          # Raw

       proc raw { from keyword text } {

             switch -exact $keyword {

                # Who

                 354 {

                   if {[lindex [split $text] 3] == 0} { return }

                   set ::request::auth([lindex [split $text] 1]@[lindex [split $text] 2]) [lindex [split $text] 3]

                 }

                # List

                 322 {

                   set chan [lindex [split $text] 1]

                   foreach ars [array names ::request::curr *,chan] {

                       if {[string equal -nocase $chan $::request::curr($ars)]} {

                          set typ [lindex [split $ars ","] 0]

                          break

                       }

                   }
                   
                   

                   if {![info exists typ]} { return }

                   set ::request::curr($typ,users) [lindex [split $text] 2]

                 }

                # Whois

                 319 {

                   set nick [lindex [split $text] 1]

                   foreach ars [array names ::request::curr *,nick] {

                       if {[string equal -nocase $nick $::request::curr($ars)]} {

                          set typ [lindex [split $ars ","] 0]

                          break

                       }

                   }

                   if {![info exists typ]} { return }

                   set founded 0

                   foreach chan [lindex [split $text ":"] 1] {

                       if {[string equal -nocase @$::request::curr($typ,chan) $chan]} {

                           set founded 1

                           break

                       }

                       if {[string equal -nocase +$::request::curr($typ,chan) $chan] || [string equal -nocase $::request::curr($typ,chan) $chan]} {

                           set founded 2

                           break

                       }

                   }

                   set ::request::curr($typ,op) $founded

                 }

                # Names

                 353 {

                   set chan [lindex [split $text] 2]

                   foreach ars [array names ::request::curr *,chan] {

                       if {[string equal -nocase $chan $::request::curr($ars)]} {

                          set typ [lindex [split $ars ","] 0]

                          break

                       }

                   }

                   if {![info exists typ]} { return }

                   foreach ni [split [lindex [split $text ":"] 1]] {

                       if {[string equal "@Q" $ni]} {

                            set chanbot Q
                            break
                       }

                       if {[string equal "@Q9" $ni]} {

                            set chanbot Q9
                            break
                       }

                       if {[string equal "@L" $ni]} {

                            set chanbot L
                            break
                       }

                   }

                   if {![info exists chanbot]} { return }

                   set ::request::curr($typ,chanbot) $chanbot

                       

                 }

                # End of Names

                 366 {

                   set chan [lindex [split $text] 1]

                   foreach ars [array names ::request::curr *,chan] {

                       if {[string equal -nocase $chan $::request::curr($ars)]} {

                          set typ [lindex [split $ars ","] 0]

                          break

                       }

                   }

                   if {![info exists typ]} { return }

                   ::request::finish $typ

                }

             }


       }

          # Priv

       proc priv { nick host hand arg } {

             foreach ars [array names ::request::type *,trigger] {

                 if {[string equal -nocase $::lastbind $::request::type($ars)]} {

                     set type [lindex [split $ars ,] 0]

                 }

             }

             if {![channel get $::request::channel(main) request]} {
                 putserv "notice $nick :\002Error\002 Request currently disabled. Try again later."
             } elseif {![channel get $::request::channel(main) $type]} {
                 putserv "notice $nick :The \002$type\002 Request is currently disabled. Try again later."
             } elseif {![onchan $nick $::request::channel(main)]} {
                 putserv "notice $nick :\002Error\002 You have to be in $::request::channel(main). Try /join $::request::channel(main)."
                 ::request::stats $type 0
             } elseif {[::request::getauth $host] == 0} {
                 putserv "notice $nick :\002Error\002 You're not authed. Please auth with Q before requesting."
                 ::request::stats $type 0
             } elseif {[set chan [lindex [split $arg] 0]] == ""} {
                 putserv "notice $nick :\002Error\002 Wrong usage! Try /msg $::botnick $type #yourchan"
                 ::request::stats $type 0
             } elseif {[llength [bots]] == 0} {
                 putserv "notice $nick :\002Error\002 Request currently disabled. No Bots aviable."
                 ::request::stats $type 0
             } elseif {[set bot [::request::getbot $type $chan]] == 0} {
                 putserv "notice $nick :\002Error\002 Can't find Bot with typ $type for your Chan. Maybe there's also a bot in your chan."
                 ::request::stats $type 0
             } elseif {[::request::badhost $host]} {
                 putserv "notice $nick :\002Error\002 You have a bad Hostmask. Try /mode $nick +x"
                 ::request::stats $type 0
             } elseif {[set rep [::request::blist:check $chan]] != "0"} {
                 putserv "notice $nick :\002Request\002 \037Failed\037 Your Channel is Blacklisted! \037Reason\037: [lindex $rep 2]"
                 ::request::stats $type 0
             } elseif {[set rep [::request::blist:check *!$host]] != "0"} {
                 putserv "notice $nick :\002Request\002 \037Failed\037 Your Host is Blacklisted! \037Reason\037: [lindex $rep 2]"
                 ::request::stats $type 0
             } elseif {[set rep [::request::blist:check $nick!*@*]] != "0"} {
                 putserv "notice $nick :\002Request\002 \037Failed\037 Your Nick is Blacklisted! \037Reason\037: [lindex $rep 2]"
                 ::request::stats $type 0
             } elseif {[info exists ::request::curr($type)] && ($::request::curr($type) > [unixtime])} {
                 putserv "notice $nick :\002Request\002 \037Blocked\037 Theres another request. You have to wait [duration [expr {$::request::curr($type) - [unixtime]}]]."
                 ::request::stats $type 0
             } elseif {([info exists ::request::block($host)]) && ($::request::block($host) > [unixtime])} {
                 putserv "notice $nick :\002Request\002 \037Blocked\037 (Host) You have to wait [duration [expr {$::request::block($host) - [unixtime]}]]."
                 ::request::stats $type 0
             } elseif {([info exists ::request::block($chan)]) && ($::request::block($chan) > [unixtime])} {
                 putserv "notice $nick :\002Request\002 \037Blocked\037 (Chan) $chan is blocked. Wait [duration [expr {$::request::block($chan) - [unixtime]}]]."
                 ::request::stats $type 0
             } else {
                 if {![info exists bot]} {
                   set bot [::request::getbot $type $chan]
                 }
                 if {$bot == 0} {
                   putserv "notice $nick :\002Error\002 Can't find Bot with typ $type"
                 }

                 set ::request::block($host) [expr {[unixtime] + $::request::time(host,block)*60}]
                 set ::request::block($chan) [expr {[unixtime] + $::request::time(chan,block)*60}]

                 set ::request::curr($type) [expr {[unixtime] + $::request::time(out)}]
                 set ::request::curr($type,nick) $nick
                 set ::request::curr($type,chan) $chan
                 set ::request::curr($type,bot) $bot

                 putquick "whois $nick"
                 putquick "list $chan"
                 putquick "names $chan"
                 putquick "notice $nick :\002Request\002 Please wait... Checking Chan"

             }

       }

          # Load

       proc load {} {

             foreach trig [array names ::request::type *,trigger] {

                  setudef flag [lindex [split $trig ,] 0]

                  bind msg -|- $::request::type($trig) ::request::priv

             }

             if {![validchan ::request::channel(main)]} {

                  channel add $::request::channel(main)

                  channel set $::request::channel(main) +request

             }

             if {![file exists $::request::file(blist)]} {

                  set f [open $::request::file(blist) w]

                  close $f

             }

             if {![info exists ::request::showmsg]} {

                  puthelp "privmsg #p0wl :\002Request\002 Loaded. \037Main Channel\037: $::request::channel(main) \037Bots\037 [llength [bots]]"

                  set ::request::showmsg 1

             }

             foreach timer [timers] {

                 if {[string equal -nocase [lindex [split $timer] 1] "::request::loadauths"]} {

                     set founded 1

                 }

             }

             if {![info exists founded]} {

                 utimer 10 [list ::request::loadauths]

             }

             return 1

       }

          # GetAuth

       proc getauth { host } {

            if {[info exists ::request::auth($host)]} {

                 return $::request::auth($host)

            } else {

                 return 0

            }

       }

          # Join

       proc rawjoin { nick host hand chan } {

              # Auth

            if {![info exists ::request::auth($host)]} {

                 if {[regexp -nocase -- {@(.+?)\.users.quakenet.org} [getchanhost $nick] -> auth]} {

                      set ::request::auth($host) $auth

                 } else {

                      putquick "who $nick n%auh"

                 }

            } else {

                 if {[regexp -nocase -- {@(.+?)\.users.quakenet.org} [getchanhost $nick] -> auth]} {

                      set ::request::auth($host) $auth

                 }
 
            }

       }

       putlog "\002Reqest\002 by \037#p0wl\037 Loaded. Type .load in $::request::channel(main) to load."

}
timur
 

Re: old but nice request script

Postby jonlar » Wed Jul 16, 2008 11:48 am

jonlar
 

Re: old but nice request script

Postby timur » Wed Jul 16, 2008 1:13 pm

yes this script is it ^^

please help us this is a good request script
timur
 

Re: old but nice request script

Postby jonlar » Wed Jul 16, 2008 2:28 pm

i would like but i just know MSL. We have to find somebody like Sumsar or Lukemob or .....
jonlar
 

Re: old but nice request script

Postby Lukemob » Wed Jul 16, 2008 4:48 pm

Hello timur, I'm glad and happy for your interrests in our forum - welcome here.

Please check for my reply here: viewtopic.php?f=13&t=152&p=467#p467

Thank you.. ;)
Lukemob
 


Return to TCL Scripting Request

Who is online

Users browsing this forum: No registered users and 2 guests

cron