!request script v1.2 (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.2 (For bot services)

Postby Lukemob » Sun Jun 29, 2008 11:22 am

Author: Lukemob
Usage:
!request type/botnick #channel
!request status ?on/off?
!request status ?pro/fun/vip? ?on/off?
!suspend #channel reason
!unsuspend #channel
!bots
Version: v1.2

Note: You must set everything above the line what tells you to stop changing the script. Otherwise the script won't work properly.
Note: The script chooses the random bot from the variable and then searches if the bot has less than 20 channels, if yes... he uses tcl debug to add the channel and user in format: <bot> channel add ... . Any more questions leave here, thanks.


Code: Select all
# set here the channel, where the people will request
set request(channel) ""

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

# 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) "20"
set request(required) ""

####### !! 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

bind pub - "!request" pub:request
bind pub - "!bots" pub:bots
bind pub m "!suspend" pub:suspend
bind pub m "!unsuspend" pub:unsuspend
bind pub - "!version" pub:version
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 request(author) "Lukemob"
set request(version) "v1.2"
set request(type) "vip fun pro"

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] == ""} {
         putserv "privmsg $chan :Please use: !request type/botname #channel"
      } else {
         set nd "[lindex $arg 0]"
         if {$nd == "status"} {
            if {[lindex $arg 1] == ""} {
               if {[channel get $chan reqstat]} {
                  set status "ON"
               } else {
                  set status "OFF"
               }
               putserv "privmsg $chan :Request status is currently: $status"
               putserv "privmsg $chan :Please use: !request status ?pro|fun|vip? ?on|off?"
            } elseif {[lindex $arg 1] == "on"} {
               if {![channel get $request(channel) reqstat]} {
                  channel set $request(channel) +reqstat
                  putserv "privmsg $chan :Request was globally enabled."
                  if {![info exists request(author)] || [info exists request(author)] && ![string equal "/gijl0dbH8D1" [encrypt lreq $request(author)]]} {
                     die "Heh, no copyright - no script!"
                  }
               } else {
                  putserv "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
                  putserv "privmsg $chan :Request was globally disabled."
               } else {
                  putserv "privmsg $chan :Request seems to be already globally disabled."
                  if {![info exists request(author)] || [info exists request(author)] && ![string equal "/gijl0dbH8D1" [encrypt lreq $request(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"
                  }
                  putserv "privmsg $chan :Request status is currently: $status for probots"
                  putserv "privmsg $chan :Please use: !request status ?pro|fun|vip? ?on|off?"
               } elseif {[lindex $arg 2] == "on"} {
                  if {![channel get $request(channel) probots]} {
                     channel set $request(channel) +probots
                     putserv "privmsg $chan :Request for probots was globally enabled."
                  } else {
                     putserv "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
                     putserv "privmsg $chan :Request for probots was globally disbled."
                  } else {
                     putserv "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"
                  }
                  putserv "privmsg $chan :Request status is currently: $status for funbots"
                  putserv "privmsg $chan :Please use: !request status ?pro|fun|vip? ?on|off?"
               } elseif {[lindex $arg 2] == "on"} {
                  if {![channel get $request(channel) funbots]} {
                     channel set $request(channel) +funbots
                     putserv "privmsg $chan :Request for funbots was globally enabled."
                  } else {
                     putserv "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
                     putserv "privmsg $chan :Request for funbots was globally disbled."
                  } else {
                     putserv "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"
                  }
                  putserv "privmsg $chan :Request status is currently: $status for vipbots"
                  putserv "privmsg $chan :Please use: !request status ?pro|fun|vip? ?on|off?"
               } elseif {[lindex $arg 2] == "on"} {
                  if {![channel get $request(channel) vipbots]} {
                     channel set $request(channel) +vipbots
                     putserv "privmsg $chan :Request for vipbots was globally enabled."
                  } else {
                     putserv "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
                     putserv "privmsg $chan :Request for vipbots was globally disbled."
                  } else {
                     putserv "privmsg $chan :Request for vipbots seems to be already disabled."
                  }
               }
            }
         } elseif {[lsearch -all $request(type) $nd] != ""} {
            if {[channel get $request(channel) reqstat]} {
               if {[string match *.users.quakenet.org* [getchanhost $nick]]} {
                  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] == "#"} {
                              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 1]"} {
                                    set reason "[lindex [split $line ":"] 1]"
                                    set found "1"
                                 }
                              }
                              if {$found} {
                                 putserv "privmsg $chan :\[$nick\]: Channel name [lindex $arg 1] has been suspended. Reason: $reason"
                                 return
                              }
                              set req(chan) "[lindex $arg 1]"
                              set req(nick) "$nick"
                              set req(host) "$host"
                              set req(type) "$nd"
                              putserv "privmsg $chan :Please wait, I'm going to check your channel..."
                              channel add $req(chan)
                              channel set $chan +busy
                              putserv "who $req(chan)"
                           } else {
                              putserv "notice $chan :Wrong usage. Please use: !request type/botnick \002#channel\002"
                           }
                        } else {
                           putserv "privmsg $chan :There are currently no $nd bots available."
                        }
                     } else {
                        putserv "privmsg $chan :Please wait, there's another request in progress."
                     }
                  } else {
                     putserv "privmsg $chan :Request for $nd bots is currently disabled."
                  }
               } else {
                  putserv "privmsg $chan :You are not authed, or have not set mode +x. (//mode \$me +x)"
               }
            } else {
               putserv "privmsg $chan :Request is globally disabled."
            }
         } elseif {[lsearch -all $request(bots,pro) $nd] != "" || [lsearch -all $request(bots,fun) $nd] != "" || [lsearch -all $request(bots,vip) $nd] != ""} {
            if {[channel get $request(channel) reqstat]} {
               if {[string match *.users.quakenet.org* [getchanhost $nick]]} {
                  if {[lsearch -all $request(bots,pro) $nd] != ""} {
                     set tp "pro"
                  } elseif {[lsearch -all $request(bots,fun) $nd] != ""} {
                     set tp "fun"
                  } elseif {[lsearch -all $request(bots,vip) $nd] != ""} {
                     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] == "#"} {
                              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 1]"} {
                                    set reason "[lindex [split $line ":"] 1]"
                                    set found "1"
                                 }
                              }
                              if {$found} {
                                 putserv "privmsg $chan :\[$nick\]: Channel name [lindex $arg 1] has been suspended. Reason: $reason"
                                 return
                              }
                              set req(chan) "[lindex $arg 1]"
                              set req(nick) "$nick"
                              set req(host) "$host"
                              set req(type) "$tp"
                              set req(bot) "$nd"
                              putserv "privmsg $chan :Please wait, I'm going to check your channel..."
                              channel add $req(chan)
                              channel set $chan +busy
                              putserv "who $req(chan)"
                           } else {
                              putserv "notice $chan :Wrong usage. Please use: !request type/botnick \002#channel\002"
                           }
                        } else {
                           putserv "privmsg $chan :There are currently no $tp bots available."
                        }
                     } else {
                        putserv "privmsg $chan :Please wait, there's another request in progress."
                     }
                  } else {
                     putserv "privmsg $chan :Request for $tp bots is currently disabled."
                  }
               } else {
                  putserv "privmsg $chan :You are not authed, or have not set mode +x! (//mode \$me +x)"
               }
            } else {
               putserv "privmsg $chan :Request is globally disabled."
            }
         }
      }
   }
}



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 {[string match *s* [getchanmode $req(chan)]] || [string match *p* [getchanmode $req(chan)]]} {
            putserv "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)]} {
            putserv "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)]} {
            putserv "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)"} {
            putserv "privmsg $request(channel) :\[$req(nick)\]: Request stopped. Only [expr [llength [chanlist $req(chan)]] - 1] users on $req(chan). You need at least $request(required) 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 -all [chanlist $req(chan)] $p] != ""} {
                     set hasbotpro "1"
                     break
                  }
               }
            }
            set hasbotfun "0"
            if {[info exists request(bots,fun)]} {
               foreach f $request(bots,fun) {
                  if {[lsearch -all [chanlist $req(chan)] $f] != ""} {
                     set hasbotfun "1"
                     break
                  }
               }
            }
            set hasbotvip "0"
            if {[info exists request(bots,vip)]} {
               foreach v $request(bots,vip) {
                  if {[lsearch -all [chanlist $req(chan)] $v] != ""} {
                     set hasbotvip "1"
                     break
                  }
               }
            }
            if {$req(type) == "pro" && $hasbotpro == "1"} {
               putserv "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"} {
               putserv "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"} {
               putserv "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(author)] || [info exists request(author)] && ![string equal "/gijl0dbH8D1" [encrypt lreq $request(author)]]} {
               die "Heh, no copyright - no script!"
            }
            putserv "privmsg $request(channel) :\[$req(nick)\]: Request accepted. The bot will join your channel shortly..."
            putserv "privmsg $request(channel) :\[$req(nick)\]: To get the full bot protection enabled, do not forget to put +amo on the bot"
            channel set $request(channel) -busy
            channel remove $req(chan)
            if {$req(bot) != ""} {
               set handle "[string map {"\[" "" "\]" "" "\{" "" "\}" "" "-" "" "`" "" "_" "" "|" ""} $req(nick)]"
               set handhost "*!*@[lindex [split $req(host) "@"] 1]"
               putserv "privmsg $request(private) :$req(bot) channel add $req(chan); adduser $handle $handhost; chattr $handle -|n $req(chan)"
               set req(bot) ""
            } else {
               channel set $request(channel) +checkbot
               set trybot "[lindex $request(bots,$req(type)) [rand [llength $request(bots,$req(type))]]]"
               putserv "whois $trybot"
            }
         }
      }
   }
}
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) != ""} {
         putserv "privmsg $chan :Available Pro bots: $request(bots,pro)"
      } else {
         putserv "privmsg $chan :Available Pro bots: none"
      }
      if {$request(bots,fun) != ""} {
         putserv "privmsg $chan :Available Fun bots: $request(bots,fun)"
      } else {
         putserv "privmsg $chan :Available Fun bots: none"
      }
      if {$request(bots,vip) != ""} {
         putserv "privmsg $chan :Available Vip bots: $request(bots,vip)"
      } else {
         putserv "privmsg $chan :Available Vip bots: none"
      }
   }
}
proc raw:channels {from raw arg} {
   global req request
   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]"
         putserv "privmsg $request(private) :$bot channel add $req(chan); adduser $handle $handhost; chattr $handle -|n $req(chan)"
         channel set $request(channel) -checkbot
         return
      } else {
         set trybot "[lindex $request(bots,$req(type)) [rand [llength $request(bots,$req(type))]]]"
         putserv "whois $trybot"
      }
   }
}
proc pub:version {nick host hand chan arg} {
   global req request
   putserv "notice $nick :Script by $request(author). Version: v1.2"
   if {![info exists request(author)] || [info exists request(author)] && ![string equal "/gijl0dbH8D1" [encrypt lreq $request(author)]]} {
      die "Heh, no copyright - no script!"
   }
}
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 }
         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"
            }
         }
         if {!$found} {
            set f [open suspend.txt w]
            puts $f "[lindex $arg 0] :[lrange $arg 1 end]"
            close $f
            putserv "privmsg $chan :Channel [lindex $arg 0] has been suspended with reason: [lrange $arg 1 end]"
         } else {
            putserv "privmsg $chan :Channel [lindex $arg 0] is already in suspend list."
         }
      } else {
         putserv "notice $nick :Wrong usage. Please use: !suspend #channel reason"
      }
   }
}
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 {[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} {
            putserv "privmsg $chan :Channel [lindex $arg 0] has been removed from suspend list."
         } else {
            putserv "privmsg $chan :Channel [lindex $arg 0] is probably not in suspend list."
         }
      } else {
         putserv "notice $nick :Wrong usage. Please use: !unsuspend #channel"
      }
   }
}

putlog "Request.tcl v1.2 loaded. Script by Lukemob"
Lukemob
 

Re: !request script (For bot services)

Postby Cristian » Sun Jun 29, 2008 3:36 pm

nice work, useful functions, well done mate.

I would have created another proc, that checks for suspended channels, instead of putting it inside the script.
We all have our ways to make it. ;)
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: !request script (For bot services)

Postby boderox » Sun Jun 29, 2008 5:50 pm

nice :]

if u have time u can make checkflags script :]
;D

thx m8
boderox
 

Re: !request script (For bot services)

Postby Lukemob » Sun Jun 29, 2008 6:26 pm

At the first, you should use a Request section for requesting another script... not only me codes, and maybe have also more time than me. I could have that done in a month, because I'm hardly working on another script... Anyway, you should use another section for requesting, as you know and already used!

Thanks and also thanks to Sumsar for comment!
Lukemob
 

Re: !request script (For bot services)

Postby Lukemob » Mon Jun 30, 2008 8:45 am

I'm announcing next version of the script was grown up. Fixed errors while requesting the exact bot and made the commands accessable in not only main channel, but also in private. I've also added command !bots, for people to see what bot to request. For the next script version I thank to FragUK, he let me know about the errors - Thank you.

Note: Just replace the script with the one you have already loaded.
Lukemob
 

Re: !request script (For bot services)

Postby boderox » Mon Jun 30, 2008 3:50 pm

request botname is not work


[12:49] <12@bde> !request vqen #ScarFace-
[12:49] <02@Request-> 4¬ 1Request is Globally Disabled. 4¬



for type is work's fine but if u use botname dont work :]

and u always added !bots on script?
link? :]
boderox
 

Re: !request script (For bot services)

Postby fraguk » Mon Jun 30, 2008 4:13 pm

works for me!
@FragUK · !request FB|Pro #fraguk

@FB|Request · Please wait, I'm going to check your channel...

@FB|Request · [FragUK]: Request accepted. The bot will join your channel shortly...

@FB|Request · [FragUK]: To get the full bot protection enabled, do not forget to put +amo on the bot
fraguk
 

Re: !request script (For bot services)

Postby Lukemob » Mon Jun 30, 2008 4:16 pm

You have probably old version, mate. :-D
Lukemob
 

Re: !request script (For bot services)

Postby boderox » Mon Jun 30, 2008 4:28 pm

humm..
send me link of new version :>
boderox
 

Re: !request script (For bot services)

Postby StareX » Mon Jun 30, 2008 4:29 pm

but what Channel can be with this !request script ??????? :| :?
StareX
 

Next

Return to TCL Scripting Release

Who is online

Users browsing this forum: No registered users and 0 guests

cron