!request script v1.5 (For bot services)

Release your script here.
State:
- Author
- What it does
- Perhaps a little guide.
- Also, if the snippet is of any use to the community, it has a chance of getting posted on the main page, so don't hesitate to submit/ask!

!request script v1.5 (For bot services)

Postby Lukemob » Fri Jul 25, 2008 4:04 pm

Author: Lukemob
Description: Request system for bot services... (The last free version)
Commands:
!request type/botname #channel - Request a bot to a channel
!request status ?on/off? - Switching global request status to on/off
!request status ?pro/fun/vip? ?on/off? - Switching request status of each type of bot to on/off
!bots - A list of bots
!stopscan - Stops a scan for bot
!suspend #channel Reason - Suspends a channel
!unsuspend #channel - Unsuspends a channel
!chaninfo #channel - Shows why the channel got suspended
!status - Shows a status of the botservice
!version - Shows a current version of the script
!checkflags - Makes the bot to check for flags at Q
!scanmethod - Switching the method of requesting the bot (BOTNET/QUERY)
/msg Bot_to_request removebot #chan - Removes a bot requested by an user from a channel #chan
Notes:
- All the bots should be in one private channel (To reach the full working system)
- Each variable, marked as a set-able variable should be set (To reach the full working system)
- While the scanmethod is in BOTNET mode, the bots should be connected, otherwise the script won't work
Thanks to:
- My script testers: FragUK and davEyw

----------------------------------------------

So, now comes the scripts...

request.tcl (should be loaded only in request bot)
Code: Select all
##########################
#### Script by Lukemob ###
##########################

# set here the channel, where the people will request
set request(channel) ""

# set here the private channel
set request(private) ""

# set here the trigger
set request(trigger) "?"

# set here all the bots available for request
# example: set request(bots,pro) "bot1 bot2 bot3" etc.
set request(bots,pro) ""
set request(bots,fun) ""
set request(bots,vip) ""

# set here the number of needed users in channel, to get a bot
# example: set request(required,pro) "20"
set request(required,pro) "20"
set request(required,fun) "20"
set request(required,vip) "20"

# set here the bots which shouldn't be used while gathering the statistics info
# e.g. hub, sbnc, etc.
# note: it's better to set handle and nick too, because of !scanmethod
set botcheck(exceptlist) ""

####### !! DO NOT CHANGE ANYTHING UNDER THIS LINE !! ######
####### !! DO NOT CHANGE ANYTHING UNDER THIS LINE !! ######
####### !! DO NOT CHANGE ANYTHING UNDER THIS LINE !! ######

setudef flag reqstat
setudef flag busy
setudef flag vipbots
setudef flag funbots
setudef flag probots
setudef flag checkbot
setudef flag botcheck
setudef flag botnetscan

bind pub - "${request(trigger)}request" pub:request
bind pub - "${request(trigger)}bots" pub:bots
bind pub m "${request(trigger)}stopscan" pub:stopscan
bind pub m "${request(trigger)}suspend" pub:suspend
bind pub m "${request(trigger)}unsuspend" pub:unsuspend
bind pub - "${request(trigger)}chaninfo" pub:chaninfo
bind pub - "${request(trigger)}status" pub:status
bind pub - "${request(trigger)}version" pub:version
bind pub m "${request(trigger)}checkflags" pub:checkflags
bind pub m "${request(trigger)}scanmethod" pub:scanmethod
bind bot - "req" bot:request_status
bind msg - "req" msg:request_status
bind raw - "315" raw:endofwho
bind raw - "319" raw:channels

set req(nick) ""
set req(host) ""
set req(chan) ""
set req(bot) ""
set req(type) ""

set botcheck(bots) "0"
set botcheck(chans) "0"

namespace eval ::request::settings {
   variable author "Lukemob"
   variable version "1.5.1"
}
set request(type) "vip fun pro"

if {$::server != ""} {
   if {![onchan $::botnick $request(channel)]} {
      channel add $request(channel)
   }
   if {![onchan $::botnick $request(private)]} {
      channel add $request(private)
   }
}

proc pub:checkflags {nick host hand chan arg} {
   global req request
   if {[channel get $request(channel) botnetscan]}   {
      if {[bots] == ""} { putquick "notice $nick :No bots on botnet."; return }
      foreach b [bots] {
         putbot $b "req checkflags"
      }
      putquick "privmsg $chan :Checking for flags..."
   } else {
      if {$request(bots,pro) == "" && $request(bots,fun) == "" && $request(bots,vip) == ""} {
         putquick "notice $nick :No bots set."
      } else {
         lappend bots "$request(bots,pro) $request(bots,fun) $request(bots,vip)"
         set bots "[join [string map [list "\{" "" "\}" ""] $bots]]"
         
         foreach b $bots {
            putserv "privmsg $b :req checkflags"
         }
         putquick "privmsg $chan :Checking for flags..."
      }
   }
}

proc pub:request {nick host hand chan arg} {

   global request req

   if {[string equal -nocase $chan $request(channel)] || [string equal -nocase $chan $request(private)]} {
      if {[lindex $arg 0] == ""} {
         putquick "privmsg $chan :Please use: ${request(trigger)}request type/botname #channel"
      } else {
         set nd "[lindex $arg 0]"
         if {$nd == "status"} {
            if {[matchattr $hand m]} {
               if {[lindex $arg 1] == ""} {
                  if {[channel get $chan reqstat]} {
                     set status "ON"
                  } else {
                     set status "OFF"
                  }
                  putquick "privmsg $chan :Request status is currently: $status"
                  putquick "privmsg $chan :Please use: ${request(trigger)}request status ?pro|fun|vip? ?on|off?"
               } elseif {[lindex $arg 1] == "on"} {
                  if {![channel get $request(channel) reqstat]} {
                     channel set $request(channel) +reqstat
                     putquick "privmsg $chan :Request was globally enabled."
                     if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                        die "Heh, no copyright - no script!"
                     }
                  } else {
                     putquick "privmsg $chan :Request seems to be already globally enabled."
                  }
               } elseif {[lindex $arg 1] == "off"} {
                  if {[channel get $request(channel) reqstat]} {
                     channel set $request(channel) -reqstat
                     putquick "privmsg $chan :Request was globally disabled."
                  } else {
                     putquick "privmsg $chan :Request seems to be already globally disabled."
                     if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                        die "Heh, no copyright - no script!"
                     }
                  }
               } elseif {[lindex $arg 1] == "pro"} {
                  if {[lindex $arg 2] == ""} {
                     if {[channel get $chan probots]} {
                        set status "ON"
                     } else {
                        set status "OFF"
                     }
                     putquick "privmsg $chan :Request status is currently: $status for probots"
                     putquick "privmsg $chan :Please use: ${request(trigger)}request status ?pro|fun|vip? ?on|off?"
                  } elseif {[lindex $arg 2] == "on"} {
                     if {![channel get $request(channel) probots]} {
                        channel set $request(channel) +probots
                        putquick "privmsg $chan :Request for probots was globally enabled."
                     } else {
                        putquick "privmsg $chan :Request for probots seems to be already enabled."
                     }
                  } elseif {[lindex $arg 2] == "off"} {
                     if {[channel get $request(channel) probots]} {
                        channel set $request(channel) -probots
                        putquick "privmsg $chan :Request for probots was globally disbled."
                        if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                           die "Heh, no copyright - no script!"
                        }
                     } else {
                        putquick "privmsg $chan :Request for probots seems to be already disabled."
                     }
                  }
               } elseif {[lindex $arg 1] == "fun"} {
                  if {[lindex $arg 2] == ""} {
                     if {[channel get $chan funbots]} {
                        set status "ON"
                     } else {
                        set status "OFF"
                     }
                     putquick "privmsg $chan :Request status is currently: $status for funbots"
                     putquick "privmsg $chan :Please use: ${request(trigger)}request status ?pro|fun|vip? ?on|off?"
                  } elseif {[lindex $arg 2] == "on"} {
                     if {![channel get $request(channel) funbots]} {
                        channel set $request(channel) +funbots
                        putquick "privmsg $chan :Request for funbots was globally enabled."
                     } else {
                        putquick "privmsg $chan :Request for funbots seems to be already enabled."
                     }
                  } elseif {[lindex $arg 2] == "off"} {
                     if {[channel get $request(channel) funbots]} {
                        channel set $request(channel) -funbots
                        putquick "privmsg $chan :Request for funbots was globally disbled."
                        if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                           die "Heh, no copyright - no script!"
                        }
                     } else {
                        putquick "privmsg $chan :Request for funbots seems to be already disabled."
                     }
                  }
               } elseif {[lindex $arg 1] == "vip"} {
                  if {[lindex $arg 2] == ""} {
                     if {[channel get $chan vipbots]} {
                        set status "ON"
                     } else {
                        set status "OFF"
                     }
                     putquick "privmsg $chan :Request status is currently: $status for vipbots"
                     putquick "privmsg $chan :Please use: ${request(trigger)}request status ?pro|fun|vip? ?on|off?"
                  } elseif {[lindex $arg 2] == "on"} {
                     if {![channel get $request(channel) vipbots]} {
                        channel set $request(channel) +vipbots
                        putquick "privmsg $chan :Request for vipbots was globally enabled."
                        if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                           die "Heh, no copyright - no script!"
                        }
                     } else {
                        putquick "privmsg $chan :Request for vipbots seems to be already enabled."
                     }
                  } elseif {[lindex $arg 2] == "off"} {
                     if {[channel get $request(channel) vipbots]} {
                        channel set $request(channel) -vipbots
                        putquick "privmsg $chan :Request for vipbots was globally disbled."
                     } else {
                        putquick "privmsg $chan :Request for vipbots seems to be already disabled."
                     }
                  }
               }
            }
         } elseif {[lsearch -exact $request(type) [string tolower $nd]] != "-1"} {
            if {[channel get $request(channel) reqstat]} {
               if {[string match *.users.quakenet.org* $host]} {
                  if {[channel get $request(channel) ${nd}bots]} {
                     if {![channel get $request(channel) busy]} {
                        if {$request(bots,$nd) != ""} {
                           if {[lindex $arg 1] != "" && [string index [lindex $arg 1] 0] == "#"} {
                              if {[file exists suspend.txt]} {
                                 set f [open suspend.txt r]
                                 set fdata [read -nonewline $f]
                                 close $f
                                 set flines [split $fdata \n]
                                 set found "0"
                                 foreach line $flines {
                                    if {[string equal -nocase [lindex $line 0] [lindex $arg 1]]} {
                                       set reason "[lindex [split $line ":"] 1]"
                                       set found "1"
                                    }
                                 }
                                 if {$found} {
                                    putquick "privmsg $chan :\[$nick\]: Channel name [lindex $arg 1] has been suspended. Reason: $reason"
                                    return
                                 }
                              } else {
                                 set f [open suspend.txt w]
                                 close $f
                              }
                              if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                                 die "Heh, no copyright - no script!"
                              }
                              set req(chan) "[lindex $arg 1]"
                              set req(nick) "$nick"
                              set req(host) "$host"
                              set req(type) "$nd"
                              putquick "privmsg $chan :Please wait, I'm going to check your channel... Do not rename now!"
                              channel add $req(chan)
                              channel set $chan +busy
                              putserv "who $req(chan)"
                           } else {
                              putquick "notice $chan :Wrong usage. Please use: ${request(trigger)}request type/botnick \002#channel\002"
                           }
                        } else {
                           putquick "privmsg $chan :There are currently no \002$nd\002 bots available."
                        }
                     } else {
                        putquick "privmsg $chan :Please wait, there's \002another\002 request in progress."
                        if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                           die "Heh, no copyright - no script!"
                        }
                     }
                  } else {
                     putquick "privmsg $chan :Request for \002$nd\002 bots is currently disabled."
                  }
               } else {
                  putquick "privmsg $chan :You are not \002authed\002, or have not set \002mode +x\002. (\002//mode \$me +x\002)"
               }
            } else {
               putquick "privmsg $chan :Request is globally \002disabled.\002"
            }
         } elseif {[lsearch -exact [string tolower $request(bots,pro)] [string tolower $nd]] != "-1" || [lsearch -exact [string tolower $request(bots,fun)] [string tolower $nd]] != "-1" || [lsearch -exact [string tolower $request(bots,vip)] [string tolower $nd]] != "-1"} {
            if {[channel get $request(channel) reqstat]} {
               if {[string match *.users.quakenet.org* $host]} {
                  if {[lsearch -exact [string tolower $request(bots,pro)] [string tolower $nd]] != "-1"} {
                     set tp "pro"
                  } elseif {[lsearch -exact [string tolower $request(bots,fun)] [string tolower $nd]] != "-1"} {
                     set tp "fun"
                  } elseif {[lsearch -exact [string tolower $request(bots,vip)] [string tolower $nd]] != "-1"} {
                     set tp "vip"
                  }
                  if {[channel get $request(channel) ${tp}bots]} {
                     if {![channel get $request(channel) busy]} {
                        if {$request(bots,$tp) != ""} {
                           if {[lindex $arg 1] != "" && [string index [lindex $arg 1] 0] == "#"} {
                              if {[file exists suspend.txt]} {
                                 set f [open suspend.txt r]
                                 set fdata [read -nonewline $f]
                                 close $f
                                 set flines [split $fdata \n]
                                 set found "0"
                                 foreach line $flines {
                                    if {[string equal -nocase [lindex $line 0] [lindex $arg 1]]} {
                                       set reason "[lindex [split $line ":"] 1]"
                                       set found "1"
                                    }
                                 }
                                 if {$found} {
                                    putquick "privmsg $chan :\[$nick\]: Channel name [lindex $arg 1] has been suspended. Reason: $reason"
                                    return
                                 }
                              } else {
                                 set f [open suspend.txt w]
                                 close $f
                              }
                              if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                                 die "Heh, no copyright - no script!"
                              }
                              set req(chan) "[lindex $arg 1]"
                              set req(nick) "$nick"
                              set req(host) "$host"
                              set req(type) "$tp"
                              set req(bot) "$nd"
                              putquick "privmsg $chan :Please wait, I'm going to check your channel... Do not rename now!"
                              channel add $req(chan)
                              channel set $chan +busy
                              putserv "who $req(chan)"
                           } else {
                              putquick "notice $chan :Wrong usage. Please use: ${request(trigger)}request type/botnick \002#channel\002"
                           }
                        } else {
                           putquick "privmsg $chan :There are currently no \002$tp\002 bots available."
                        }
                     } else {
                        putquick "privmsg $chan :Please wait, there's \002another\002 request in progress."
                     }
                  } else {
                     putquick "privmsg $chan :Request for \002$tp\002 bots is currently disabled."
                  }
               } else {
                  putquick "privmsg $chan :You are not \002authed\002, or have not set \002mode +x\002! (//mode \$me +x)"
               }
            } else {
               putquick "privmsg $chan :Request is globally \002disabled\002."
            }
         }
      }
   }
   if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
      die "Heh, no copyright = no uses"
   }
}
proc pub:stopscan {nick host hand chan arg} {
   global req request
   if {[channel get $request(channel) busy]} {
      if {$req(chan) != "" && [botonchan $req(chan)]} { channel remove $req(chan) }
      channel set $request(channel) -busy
      putquick "privmsg $request(channel) :Scanning stopped by admin $nick"
      set req(nick) ""
      set req(host) ""
      set req(chan) ""
      set req(bot) ""
      set req(type) ""
   }
}
proc raw:endofwho {from raw arg} {
   global req request
   if {[channel get $request(channel) busy]} {
      if {[string equal -nocase [lindex $arg 1] $req(chan)]} {
         if {[botonchan [lindex $arg 1]]} {
            if {[string match *s* [getchanmode $req(chan)]] || [string match *p* [getchanmode $req(chan)]]} {
               putquick "privmsg $request(channel) :\[$req(nick)\]: Request stopped. Channel mode +s/+p was detected on channel $req(chan)"
               channel set $request(channel) -busy
               channel remove $req(chan)
            } elseif {![onchan Q $req(chan)]} {
               putquick "privmsg $request(channel) :\[$req(nick)\]: Request stopped. Q bot was not found on channel $req(chan)"
               channel set $request(channel) -busy
               channel remove $req(chan)
            } elseif {![isop $req(nick) $req(chan)]} {
               putquick "privmsg $request(channel) :\[$req(nick)\]: Request stopped. You are not opped on channel $req(chan)"
               channel set $request(channel) -busy
               channel remove $req(chan)
            } elseif {[llength [chanlist $req(chan)]] < "$request(required,$req(type))"} {
               putquick "privmsg $request(channel) :\[$req(nick)\]: Request stopped. Only [expr [llength [chanlist $req(chan)]] - 1] users on $req(chan). You need at least $request(required,$req(type)) unique users."
               channel set $request(channel) -busy
               channel remove $req(chan)
            } else {
               set hasbotpro "0"
               if {[info exists request(bots,pro)]} {
                  foreach p $request(bots,pro) {
                     if {[lsearch -exact [chanlist $req(chan)] $p] != "-1"} {
                        set hasbotpro "1"
                        break
                     }
                  }
               }
               set hasbotfun "0"
               if {[info exists request(bots,fun)]} {
                  foreach f $request(bots,fun) {
                     if {[lsearch -exact [chanlist $req(chan)] $f] != "-1"} {
                        set hasbotfun "1"
                        break
                     }
                  }
               }
               set hasbotvip "0"
               if {[info exists request(bots,vip)]} {
                  foreach v $request(bots,vip) {
                     if {[lsearch -exact [chanlist $req(chan)] $v] != "-1"} {
                        set hasbotvip "1"
                        break
                     }
                  }
               }
               if {$req(type) == "pro" && $hasbotpro == "1"} {
                  putquick "privmsg $request(channel) :\[$req(nick)\]: Request stopped. One of our pro bots is already on channel $req(chan)"
                  channel set $request(channel) -busy
                  channel remove $req(chan)
                  return
   
               } elseif {$req(type) == "fun" && $hasbotfun == "1"} {
                  putquick "privmsg $request(channel) :\[$req(nick)\]: Request stopped. One of our fun bots is already on channel $req(chan)"
                  channel set $request(channel) -busy
                  channel remove $req(chan)
                  return
               } elseif {$req(type) == "vip" && $hasbotvip == "1"} {
                  putquick "privmsg $request(channel) :\[$req(nick)\]: Request stopped. One of our vip bots is already on channel $req(chan)"
                  channel set $request(channel) -busy
                  channel remove $req(chan)
                  return
               }
               if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                  die "Heh, no copyright - no script!"
               }
               channel remove $req(chan)
               if {$req(bot) != ""} {
                  channel set $request(channel) +checkbot
                  putquick "whois $req(bot)"
               } else {
                  channel set $request(channel) +checkbot
                  set trybot "[lindex $request(bots,$req(type)) [rand [llength $request(bots,$req(type))]]]"
                  putquick "whois $trybot"
               }
            }
         } else {
            putquick "privmsg $request(channel) :\[$req(nick)\]: Request stopped. Couldn't join the channel for unknown reason."
            channel set $request(channel) -busy
            return
         }
      }
   }
   if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
      die "Heh, no copyright - no script!"
   }
}
proc pub:bots {nick host hand chan arg} {
   global req request
   if {[string equal -nocase $chan $request(channel)] || [string equal -nocase $chan $request(private)]} {
      if {$request(bots,pro) != ""} {
         putquick "privmsg $chan :Available Pro bots: $request(bots,pro)"
      }
      if {$request(bots,fun) != ""} {
         putquick "privmsg $chan :Available Fun bots: $request(bots,fun)"
      }
      if {$request(bots,vip) != ""} {
         putquick "privmsg $chan :Available Vip bots: $request(bots,vip)"
      }
      if {$request(bots,pro) == "" && $request(bots,fun) == "" && $request(bots,vip) == ""} {
         putquick "privmsg $chan :No bots available at the moment."
      }
   }
   if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
      die "Heh, no copyright - no script!"
   }
}
proc pub:scanmethod {nick host hand chan arg} {
   global req request botcheck
   if {[channel get $request(channel) botnetscan]} {
      putserv "notice $nick :Contacting bots has been switched to 'TCLDEBUG-QUERY'"
      channel set $request(channel) -botnetscan
   } else {
      putserv "notice $nick :Contacting bots has been switched to 'BOTNET'"
      channel set $request(channel) +botnetscan
   }
}
proc raw:channels {from raw arg} {
   global req request botcheck
   if {[channel get $request(channel) checkbot]} {
      if {[llength [lindex [split [lindex $arg 2] ":"] 1]] < "20"} {
         set handle "[string map {"\[" "" "\]" "" "\{" "" "\}" "" "-" "" "`" "" "_" "" "|" ""} $req(nick)]"
         set handhost "*!*@[lindex [split $req(host) "@"] 1]"
         set bot "[lindex $arg 1]"
         
         if {[channel get $request(channel) botnetscan]} {
            if {[bots] != ""} {
               if {[nick2hand $bot] != ""} {
                  putbot [nick2hand $bot] "req +chan $req(chan) $handle $handhost"
               } else {
                  set owners ""
                  foreach u [userlist n] {
                     lappend owners [hand2nick $u]
                  }
                  putquick "privmsg $request(private) :WARNING FOR OWNERS/ADMINS: ($owners)"
                  putquick "privmsg $request(private) :Problem while resolving a bot's hand of bot '\002$bot\002' (botnet nick). Please fix this problem, otherwise request won't work properly!"
                  putquick "privmsg $request(private) :Trying manual adding the bot to channel, check in next 2 minutes for bot if it's in channel. Or add manually bot '$bot' to channel '$req(chan)' with owner '$handle' and owner's host '$handhost'"
                  putquick "privmsg $bot :addchan $req(chan) $handle $handhost"
                  putquick "privmsg $request(private) :\002TCLDEBUG\002 (help command for manual adding): $bot channel add $req(chan); adduser $handle $handhost; chattr $handle -|n $req(chan)"
               }
            } else {
               putquick "privmsg $request(private) :No bots have been found on botnet."
               putquick "privmsg $request(private) :Trying adding over TCLDEBUG:"
               putquick "privmsg $request(private) :$bot channel add $req(chan); adduser $handle $handhost; chattr $handle -|n"
            }
         } else {
            putquick "privmsg $bot :req +chan $req(chan) $handle $handhost"
            if {![onchan $bot $request(private)]} {
               putserv "privmsg $request(private) :I can't find '$bot', which is being requested here!"
            }
         }
         putquick "privmsg $request(channel) :\[$req(nick)\]: Request accepted. The bot will join your channel shortly..."
         putquick "privmsg $request(channel) :\[$req(nick)\]: To get the full bot protection enabled, do not forget to put +amo on the bot (/msg Q chanlev $req(chan) $bot +amo)"
         if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
            die "Im afraid of copyright stealers!"
         }
         channel set $request(channel) -busy
         channel set $request(channel) -checkbot
         
         set req(nick) ""
         set req(host) ""
         set req(chan) ""
         set req(bot) ""
         set req(type) ""
         return
      } else {
         if {$req(bot) != ""} { putquick "privmsg $request(channel) :\[$req(nick)\]: Bot $req(bot) is full, trying to contact another free bot..." }
         set trybot "[lindex $request(bots,$req(type)) [rand [llength $request(bots,$req(type))]]]"
         putquick "whois $trybot"
      }
   }
}
proc pub:status {nick host hand chan arg} {
   global request req botcheck
   if {[string equal -nocase $chan $request(channel)]} {
      if {[channel get $request(channel) botnetscan]} {
         if {![channel get $request(channel) botcheck]} {
            if {[bots] == ""} { putquick "notice $nick :No bots in botnet!"; return }
            channel set $request(channel) +botcheck
            putquick "privmsg $chan :Please wait... gathering the info (This may take a while)"
            foreach bot [bots] {
               if {[lsearch -exact [string tolower $botcheck(exceptlist)] [string tolower $bot]] == "-1"} {
                  putbot $bot "req status"
               }
            }
            utimer 30 [list bot:send_status]
            if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
               die "Heh, no copyright - no script!"
            }
         } else {
            putquick "privmsg $chan :Flood protection enabled. (2 minutes)"
         }
      } else {
         if {![channel get $request(channel) botcheck]} {
            if {$request(bots,pro) == "" && $request(bots,fun) == "" && $request(bots,vip) == ""} {
               putquick "notice $nick :No bots set."
            } else {
               channel set $request(channel) +botcheck
               putquick "privmsg $chan :Please wait... gathering the info (This may take a while)"
               lappend bots "$request(bots,pro) $request(bots,fun) $request(bots,vip)"
               set bots "[join [string map [list "\{" "" "\}" ""] $bots]]"
               
               foreach bot $bots {
                  if {[lsearch -exact [string tolower $botcheck(exceptlist)] [string tolower $bot]] == "-1"} {
                     putserv "privmsg $bot :req status"
                  }
               }
               utimer 30 [list msg:send_status]
               if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
                  die "Heh, no copyright - no script!"
               }
            }
         } else {
            putquick "privmsg $chan :Flood protection enabled. (2 minutes)"
         }
      }
   }
}
proc bot:request_status {from cmd arg} {
   global req request botcheck
   if {$cmd == "req"} {
      switch -- [string tolower [lindex [split $arg] 0]] {
         "status" {
            if {[lindex [split $arg] 1] != ""}  {
               incr botcheck(chans) [lindex [split $arg] 1]
               incr botcheck(bots)
            }
         }
      }
   }
   if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
      die "Heh, no copyright - no script!"
   }
}
proc msg:request_status {nick host hand arg} {
   global req request botcheck
   switch -- [string tolower [lindex [split $arg] 0]] {
      "status" {
         if {[lindex [split $arg] 1] != ""}  {
            incr botcheck(chans) [lindex [split $arg] 1]
            incr botcheck(bots)
         }
      }
   }
   if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
      die "Heh, no copyright - no script!"
   }
}
proc bot:send_status {} {
   global req request botcheck
   putserv "privmsg $request(channel) :We are active on $botcheck(chans)/[expr $botcheck(bots) * 20] channels, there are $botcheck(bots) of [expr [llength [bots]] - [llength $botcheck(exceptlist)]] bots online. There is space for further [expr [expr $botcheck(bots) * 20] - $botcheck(chans)] channels, [string range "[expr [expr $botcheck(chans).0 / [expr [llength [bots]].0 * 20.0]] * 100.0]" 0 3]% of our total capacity is used."
   utimer 120 [list channel set $request(channel) -botcheck]
   set botcheck(chans) "0"
   set botcheck(bots) "0"
}
proc msg:send_status {} {
   global req request botcheck
   lappend bots "$request(bots,pro) $request(bots,fun) $request(bots,vip)"
   set bots "[string map [list "\{" "" "\}" ""] $bots]"
   
   putserv "privmsg $request(channel) :We are active on $botcheck(chans)/[expr $botcheck(bots) * 20] channels, there are $botcheck(bots) of [expr [llength $bots] - [llength $botcheck(exceptlist)]] bots online. There is space for further [expr [expr $botcheck(bots) * 20] - $botcheck(chans)] channels, [string range "[expr [expr $botcheck(chans).0 / [expr [llength $bots].0 * 20.0]] * 100.0]" 0 3]% of our total capacity is used."
   utimer 120 [list channel set $request(channel) -botcheck]
   set botcheck(chans) "0"
   set botcheck(bots) "0"
}
proc pub:version {nick host hand chan arg} {
   global req request
   putquick "notice $nick :Script by $::request::settings::author. Version: v$::request::settings::version"
   if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
      die "Heh, no copyright - no script!"
   }
}
proc pub:chaninfo {nick host hand chan arg} {
   global req request
   if {$arg != "" && [string index [lindex $arg 0] 0] == "#"} {
      if {![file exists suspend.txt]} { set n [open suspend.txt w]; close $n }
      if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
         die "Heh, no copyright - no script!"
      }
      set f [open suspend.txt r]
      set fdata [read -nonewline $f]
      close $f
      set flines [split $fdata \n]
      set found "0"
      foreach line $flines {
         if {[lindex $line 0] == "[lindex $arg 0]"} {
            set found "1"
            set reason "[string range [lrange $line 1 end] 1 end]"
         }
      }
      if {!$found} {
         putquick "privmsg $chan :Channel [lindex $arg 0] is not in suspend list."
      } else {
         putquick "privmsg $chan :Suspended channel: [lindex $arg 0] Reason: $reason"
      }
   } else {
      putquick "notice $nick :Wrong usage. Please use: ${request(trigger)}chaninfo #channel"
   }
}
proc pub:suspend {nick host hand chan arg} {
   global req request
   if {[string equal -nocase $chan $request(channel)] || [string equal -nocase $chan $request(private)]} {
      if {$arg != "" && [string index [lindex $arg 0] 0] == "#" && [llength $arg] >= "2"} {
         if {![file exists suspend.txt]} { set n [open suspend.txt w]; close $n }
         if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
            die "Heh, no copyright - no script!"
         }
         set f [open suspend.txt r]
         set fdata [read -nonewline $f]
         close $f
         set flines [split $fdata \n]
         set found "0"
         foreach line $flines {
            if {[string equal -nocase [lindex $line 0] [lindex $arg 0]]} {
               set found "1"
            }
         }
         if {!$found} {
            set f [open suspend.txt "a"]
            puts $f "[lindex $arg 0] :[lrange $arg 1 end]"
            close $f
            putquick "privmsg $chan :Channel [lindex $arg 0] has been suspended with reason: [lrange $arg 1 end]"
            suspend [lindex $arg 0]
         } else {
            putquick "privmsg $chan :Channel [lindex $arg 0] is already in suspend list."
         }
      } else {
         putquick "notice $nick :Wrong usage. Please use: ${request(trigger)}suspend #channel reason"
      }
   }
}
proc suspend {chan} {
   global req request
   if {[channel get $request(channel) botnetscan]} {
      if {[bots] == ""} {
         putserv "privmsg $request(private) :Warning: Couldn't find any linked bots."
         putserv "privmsg $request(private) :Trying to suspend over query..."
         
         lappend bots "$request(bots,pro) $request(bots,fun) $request(bots,vip)"
         set bots "[join [string map [list "\{" "" "\}" ""] $bots]]"
         
         foreach b $bots {
            putserv "privmsg $b :req suspend $chan"
         }
      } else {
         foreach b [bots] {
            putbot $b "req suspend $chan"
         }
      }
   } else {
      if {$request(bots,pro) == "" && $request(bots,fun) == "" && $request(bots,vip) == ""} {
         putquick "privmsg $request(private) :No bots set."
      } else {
         lappend bots "$request(bots,pro) $request(bots,fun) $request(bots,vip)"
         set bots "[join [string map [list "\{" "" "\}" ""] $bots]]"
         
         foreach b $bots {
            putserv "privmsg $b :req suspend $chan"
         }
      }
   }
}
proc pub:unsuspend {nick host hand chan arg} {
   global req request
   if {[string equal -nocase $chan $request(channel)] || [string equal -nocase $chan $request(private)]} {
      if {[lindex $arg 0] != "" && [string index [lindex $arg 0] 0] == "#"} {
         set f [open suspend.txt r]
         set fdata [read -nonewline $f]
         close $f
         set flines [split $fdata \n]
         set found "0"
         set i "-1"
         foreach line $flines {
            incr i
            if {[string equal -nocase [lindex $line 0] [lindex $arg 0]]} {
               set found "1"
               set flines "[lreplace $flines $i $i]"
               set w [open suspend.txt "w"]
               puts $w [join $flines "\n"]
               close $w
            }
         }
         if {$found} {
            putquick "privmsg $chan :Channel [lindex $arg 0] has been removed from suspend list."
         } else {
            putquick "privmsg $chan :Channel [lindex $arg 0] is probably not in suspend list."
         }
      } else {
         putquick "notice $nick :Wrong usage. Please use: ${request(trigger)}unsuspend #channel"
      }
   }
}
if {![info exists ::request::settings::author] || [info exists ::request::settings::author] && ![string equal "/gijl0dbH8D1" [encrypt lreq $::request::settings::author]]} {
   die "Sorry but you must keep the copyrights on!"
}
putlog "Request.tcl v$::request::settings::version loaded. Script by $::request::settings::author"


bots.tcl (should be loaded in every bot)
Code: Select all
##########################
#### Script by Lukemob ###
##########################

bind msg n|n "removebot" msg:removebot
bind bot - "req" bot:request_status
bind msg - "req" msg:request_status
bind notc - "*" notc:qmessage

# set here the channel where the bot will post the result, e.g. private chan for bots
set bot(mainchan) ""
# set here the channel, the bot will msg to the chan which is going to be removed
# e.g. " Removing channel #lukemob ( Service by #lukemob ) "
set bot(adchan) ""
# set here the channels which you dont want the bot to check while checking flags
set bot(exceptchans) ""

####### !! DO NOT CHANGE ANYTHING UNDER THIS LINE !! ######
####### !! DO NOT CHANGE ANYTHING UNDER THIS LINE !! ######
####### !! DO NOT CHANGE ANYTHING UNDER THIS LINE !! ######

# leave that blank
set bot(auth) ""
# leave that blank
set bot(chkflg) "0"
# check for timer
if {[info exists ::checkflgtime]} {
   foreach c [timers] {
      if {[lindex $c 2] == "$::checkflgtime"} {
         killtimer $::checkflgtime
      }
   }
   unset ::checkflgtime
}
set ::checkflgtime "[timer 60 checkflags]"

proc msg:removebot {nick host hand arg} {
   global bot
   if {[lindex [split $arg] 0] != ""} {
      set remchan "[lindex [split $arg] 0]"
      if {[string index $remchan 0] == "#"} {
         if {[botonchan $remchan]} {
            putquick "privmsg $remchan :Removing channel $remchan ( Service by $bot(adchan) )"
            delchan $remchan
            putquick "notice $nick :Removed channel $remchan."
            if {[info exists bot(mainchan)] && $bot(mainchan) != ""} { putserv "privmsg $bot(mainchan) :Removed channel $remchan. Requested by: $nick" }
         }
      }
   }
}
proc bot:request_status {from cmd arg} {
   global bot
   if {$cmd == "req"} {
      switch -- [string tolower [lindex [split $arg] 0]] {
         "status" {
            putbot $from "req status [llength [channels]]"
         }
         "checkflags" {
            if {[string match *.users.quakenet.org [getchanhost $::botnick]]} {
               checkflags
            } else {
               putquick "privmsg $bot(mainchan) :Warning: Bot is not authed or have not set mode +x"
            }
         }
         "+chan" {
            set addchan "[lindex [split $arg] 1]"
            set owner "[string range [string map {"\[" "" "\{" "" "\}" "" "|" "" "\]" "" "`" "" "-" "" "_" ""} [lindex [split $arg] 2]] 0 8]"
            set ownhost "[lindex [split $arg] 3]"
            if {$addchan != "" && $owner != "" && $ownhost != ""} {
               channel add $addchan
               adduser $owner $ownhost
               chattr $owner -|n $addchan
               if {[info exists bot(mainchan)] && $bot(mainchan) != ""} { putserv "privmsg $bot(mainchan) :Added channel $addchan. Requested by: $from" }
               timer 1 [list saychan $addchan]
            }
         }
         "-chan" {
            set delchan "[lindex [split $arg] 1]"
            if {[string index $delchan 0] == "#"} {
               putquick "privmsg $delchan :Service by $bot(adchan)"
               delchan $delchan
               if {[info exists bot(mainchan)] && $bot(mainchan) != ""} { putserv "privmsg $bot(mainchan) :Removed channel $delchan. Requested by: $from" }
            }
         }
         "suspend" {
            if {[lindex [split $arg] 1] != ""} {
               set suspend "[lindex [split $arg] 1]"
               
               if {[botonchan $suspend]} {
                  putserv "privmsg $suspend :Channel has been suspended by $bot(adchan) - Join $bot(adchan) for more informations"
                  putserv "privmsg $bot(mainchan) :Channel $suspend suspended."
                  delchan $u
               }
            }
         }
      }
   }
}
proc checkflags {} {
   global bot
   set bot(chkflg) "1"
   timer 1 [list set bot(chkflg) "0"]
   foreach c [channels] {
      if {[lsearch -exact [string tolower $bot(exceptchans)] [string tolower $c]] == "-1"} {
         putquick "privmsg Q :chanlev $c $::botnick"
      }
   }
   set ::checkflgtime "[timer 60 checkflags]"
}
proc notc:qmessage {nick host hand arg dest} {
   global bot
   if {$nick == "Q" && $dest == "$::botnick" && $bot(chkflg) == "1"} {
      if {[join [lrange [split $arg] 0 1]] == "Flags for"} {
         if {[string match *o* [join [lindex [split $arg] end]]]} {
            return
         } else {
            set wchan "[string range [join [lindex [split $arg] end-1]] 0 end-1]"
            set flags "[join [lindex [split $arg] end]]"
            putquick "privmsg $bot(mainchan) :Warning: Channel $wchan with flags: $flags"
            if {[botonchan $wchan]} { putquick "privmsg $wchan :Warning: I have strange flags at Q on $wchan.. I'm going to be removed on next warning.." }
         }
      } elseif {[join [lrange [split $arg] 0 5]] == "You do not have sufficient access"} {
         set wchan "[join [lindex [split $arg] 7]]"
         putquick "privmsg $bot(mainchan) :Warning: Channel $wchan with NO flags"
         if {[botonchan $wchan]} { putquick "privmsg $wchan :Warning: I have no flags at Q on $wchan.. I'm going to be removed on next warning.." }
      }
   }
}
proc msg:request_status {nick host hand arg} {
   global bot
   switch -- [string tolower [lindex [split $arg] 0]] {
      "status" {
         putserv "privmsg $nick :req status [llength [channels]]"
      }
      "checkflags" {
         if {[string match *.users.quakenet.org [getchanhost $::botnick]]} {
            checkflags
         } else {
            putquick "privmsg $bot(mainchan) :Warning: Bot is not authed or have not set mode +x"
         }
      }
      "+chan" {
         set addchan "[lindex [split $arg] 1]"
         set owner "[string range [string map {"\[" "" "\{" "" "\}" "" "|" "" "\]" "" "`" "" "-" "" "_" ""} [lindex [split $arg] 2]] 0 8]"
         set ownhost "[lindex [split $arg] 3]"
         if {$addchan != "" && $owner != "" && $ownhost != ""} {
            channel add $addchan
            adduser $owner $ownhost
            chattr $owner -|n $addchan
            if {[info exists bot(mainchan)] && $bot(mainchan) != ""} { putserv "privmsg $bot(mainchan) :Added channel $addchan. Requested by: $nick" }
            timer 1 [list saychan $addchan]
         }
      }
      "-chan" {
         set delchan "[lindex [split $arg] 1]"
         if {[string index $delchan 0] == "#"} {
            putquick "privmsg $delchan :Service by $bot(adchan)"
            delchan $delchan
            if {[info exists bot(mainchan)] && $bot(mainchan) != ""} { putserv "privmsg $bot(mainchan) :Removed channel $delchan. Requested by: $nick" }
         }
      }
      "suspend" {
         if {[lindex [split $arg] 1] != ""} {
            set suspend "[lindex [split $arg] 1]"

            if {[botonchan $suspend]} {
               putserv "privmsg $suspend :Channel has been suspended by $bot(adchan) - Join $bot(adchan) for more informations"
               putserv "privmsg $bot(mainchan) :Channel $suspend suspended."
               delchan $u
            }
         }
      }
   }
}
proc saychan {chan} {
   global bot
   if {[botonchan $chan]} {
      putquick "privmsg $chan :Hello, I'm bot from $bot(adchan). To get the full protection, please give me +amo at the Q (/msg Q chanlev $chan $::botnick +amo). Enjoy!"
   }
}
proc delchan {chan} {
   if {[validchan $chan]} {
      if {[userlist -|v&-|o&-|m&-|n $chan] != ""} {
         foreach u [userlist -|v&-|o&-|m&-|n $chan] {
            deluser $u
         }
      }
      channel remove $chan
      return 1
   } else {
      return 0
   }   
}
putlog "Bots.tcl (a part of Request.tcl) loaded. Script by Lukemob"


MSL mIRC version of bots.tcl
Code: Select all
;#set here the private channel
set %mainchan #private
;#set here the channels, which you dont want to check the flags for
set %exceptchan #chan1 #chan2
;#set here the channel, which the bot will be using while suspending, leaving etc.
set %adchan #channel

on *:text:req *:?:{
  if ($2 == status) {
    msg $nick :req status $chan(0)"
  }
  elseif ($2 == checkflags) {
    if (*.users.quakenet.org iswm $address($me,2)) {
      var %x 1, %y $chan(0)
      while (%x <= %y) {
        if (!$istok(%exceptchan, $chan(%x),32)) {
          msg Q chanlev $chan(%x) $me
        }
      }
    }
  }
  elseif ($2 == +chan) {
    if ($3) && ($left($3,1) == $chr(35)) {
      if ($me !ison $3) {
        join $3
        msg %mainchan Added channel $3 $+ . Requested by: $nick
      }
    }
  }
  elseif ($2 == -chan) {
    if ($3) && ($left($3,1) == $chr(35)) {
      if ($me ison $3) {
        part $3
        msg %mainchan Removed channel $3 $+ . Requested by: $nick
      }
    }
  }
  elseif ($2 == suspend) {
    if ($3) && ($left($3,1) == $chr(35)) {
      if ($me ison $3) {
        msg $3 Channel has been suspended by an admin of %adchan
        part $3
        timer 1 2 msg %mainchan Channel $3 suspended.
      }
    }
  }
}
on *:notice:*:*:{
  if ($nick == Q) {
    if ($gettok($1-,1-2,32) == Flags for) {
      if (o isin $right($1-,1)) { return }
      else {
        msg %mainchan Warning: Channel $right($1-,2) with flags: $right($1-,1)
      }
    }
    elseif ($gettok($1-, 1-6, 32) == You do not have sufficient access) {
      msg %mainchan Warning: Channel $gettok($1-,8,32) with NO flags
    }
  }
}


I hope you enjoy this last version of script...

Thanks, Lukemob
Lukemob
 

Re: !request script v1.5 (For bot services)

Postby jonlar » Sat Jul 26, 2008 4:16 pm

For all those who are not able to Code TCL.... Great Work. Thanks a lot
jonlar
 

Re: !request script v1.5 (For bot services)

Postby Cristian » Sat Jul 26, 2008 4:39 pm

Oh my, what a beautiful script, nice work.

Lukemob you are one generous man.
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: !request script v1.5 (For bot services)

Postby boderox » Sat Jul 26, 2008 4:43 pm

very nice work ;D
boderox
 

Re: !request script v1.5 (For bot services)

Postby Lukemob » Sat Jul 26, 2008 4:47 pm

Thanks... and again thanks. I'm really glad you like and find my script as usefull.

I hope this script will make a joy to all the users, which are going to use it...
Lukemob
 

Re: !request script v1.5 (For bot services)

Postby jonlar » Sun Aug 17, 2008 7:51 pm

well. i always get Tcl error [pub:request]: bad search mode "-all": must be -exact, -glob, or -regexp if i try !request botname/-typ #channel
jonlar
 

Re: !request script v1.5 (For bot services)

Postby Lukemob » Tue Sep 02, 2008 1:52 pm

Over TCL debug use:

bot return $::errorInfo

after you get this error and submit the result ;-)
Lukemob
 

Re: !request script v1.5 (For bot services)

Postby boderox » Sat Sep 06, 2008 5:20 pm

can u add on request this :

?bots
-BS|Request- kick0r (2) {o_O} (0) Hack0r (2) Pr0 (5) {Oo} (2) B0tn3t (1)
-BS|Request- End of botlist. (Bot(s): 6 - Channel(s): 12/108)



and its not work ..
if {$req(bot) != ""} { putquick "privmsg $request(channel) :\[$req(nick)\]: Bot $req(bot) is full, trying to contact another free bot..." }
set trybot "[lindex $request(bots,$req(type)) [rand [llength $request(bots,$req(type))]]]"
putquick "whois $trybot"
}

i have bot full channels.. and request bot always add more channels :S
boderox
 

Re: !request script v1.5 (For bot services)

Postby boderox » Sat Sep 06, 2008 5:26 pm

and if u can add too:

on checkflags..
bot auto warn 3 times
and auto suspend channel with no flags :>
or 3 kicks
or 3 bans
:]
its nice
thx
boderox
 

Re: !request script v1.5 (For bot services)

Postby boderox » Sun Sep 07, 2008 4:09 pm

maybe suspended's channels
auto removed ? :S
i always need to suspend some channels
all times be removed automaticly :S
boderox
 

Next

Return to TCL Scripting Release

Who is online

Users browsing this forum: No registered users and 0 guests

cron