CBPug
Posted by Young~Money
Tuesday, August 17, 2004
Description: C-Bots Pug Bot
Just remember the bots needs ops, and DONT FORGET to private message the bot and say .owner as soon as it is put up. First to do it gets ownership :)
Just remember the bots needs ops, and DONT FORGET to private message the bot and say .owner as soon as it is put up. First to do it gets ownership :)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;; CBPug Bot ;;;;;
;;;;; Version: 2.0 ;;;;;
;;;;; Author: youngMoney ;;;;;
;;;;; Notes: -Part of the C-Bots family ;;;;;
;;;;; -When first loading the bot, ;;;;;
;;;;; query the bot and say .owner ;;;;;
;;;;; to give yourself ownership ;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ON *:START:{
hmake pusers 10
hmake pservers 10
hmake pstaff
set %slots 10
set %doing 1
if (!%pug.num) {
set %pug.num 1
}
hload pstaff pstaff.hsh
hload pservers pservers.hsh
}
on *:text:.view:#:{
var %done 1
var %need %slots
var %pusers [^K]10×[^K]3 Pug Userlist: [^K]10 $chr(91)
var %x 1
while (%x <= $hget(pusers,0).item) {
var %pusers %pusers $hget(pusers, $+ %x $+ ).data
inc %done
inc %x
}
while (%done <= %need) {
var %pusers %pusers [^K]12·
inc %done
}
msg $chan %pusers [^K]10 $chr(93) [^K]7 $calc(%slots - $hget(pusers,0).item) Remaining slots [^K]10×
}
ON *:TEXT:.list:#:{
if ($hfind(pusers,*,0,w) == 0) {
msg $chan [^K]10×[^K]3 There are no people in line for a pug. [^K]10×
}
else {
set %x 1
unset %pusers
while (%x <= $hget(pusers,0).item) {
if (%pusers) {
var %pusers %pusers $hget(pusers, $+ %x $+ ).data
}
else {
var %pusers $hget(pusers, $+ %x $+ ).data
}
inc %x
}
msg $chan [^K]10×[^K]3 Pug List: [^K]10 $chr(91) %pusers $chr(93) [^K]7 $calc(%slots - $hget(pusers,0).item) Remaining slots [^K]10×
}
}
on *:text:.help:#:{
if (%doing == 1) {
set %doing 2
sleep 500
msg $chan [^K]10×[^K]3 [^B].slots [#][^B] use to set the number of slots for the pug. Must be between 2-16. [^K]10×
sleep 500
msg $chan [^K]10×[^K]3 [^B].join[^B] use to join the pug list. [^K]10×
sleep 500
msg $chan [^K]10×[^K]3 [^B].quit[^B] use to quit the pug list. [^K]10×
sleep 500
msg $chan [^K]10×[^K]3 [^B].startpug[^B] use to manually start the pug. [^K]10×
sleep 500
msg $chan [^K]10×[^K]3 [^B].view[^B] use to view the pug list. [^K]10×
sleep 500
msg $chan [^K]10×[^K]3 [^B].servers[^B] use to view the server list. [^K]10×
sleep 500
msg $chan [^K]10×[^K]3 [^B].numbers[^B] use to view the amount of pugs served. [^K]10×
sleep 500
msg $chan [^K]10×[^K]3 [^B].about[^B] use to view info the the pug bot. [^K]10×
if ($paccess > 100) {
cnotice $nick $chan [^K]10×[^K]3 [^B].ahelp[^B] admin control help. [^K]10×
}
timer 1 10 set %doing 1
}
else {
halt
}
}
on *:text:.ahelp:#:{
if (%doing == 1) {
if ($paccess > 100) {
set %doing 2
sleep 500
cnotice $nick $chan [^K]10×[^K]3 [^U]Admin Controls[^U] [^K]10×
sleep 500
cnotice $nick $chan [^K]10×[^K]3 [^B].addserver [IP][^B] use to add a server to the list. (100+ Access) [^K]10×
sleep 500
cnotice $nick $chan [^K]10×[^K]3 [^B].delserver [IP][^B] use to delete a server from the list. (100+ Access) [^K]10×
sleep 500
cnotice $nick $chan [^K]10×[^K]3 [^B].clearpug[^B] use to clear the pug list. (100+ Access) [^K]10×
sleep 500
cnotice $nick $chan [^K]10×[^K]3 [^B].addadmin [Access][^B] use to add an admin. (200+ Access) [^K]10×
sleep 500
cnotice $nick $chan [^K]10×[^K]3 [^B].deladmin[^B] use to delete an admin. (200+ Access) [^K]10×
timer 1 10 set %doing 1
}
}
else {
halt
}
}
on *:text:.numbers:#:{
msg $chan [^K]10×[^K]3 I have served[^K]7 %pug.num [^K]3pugs. [^K]10×
}
on *:text:.about:#:{
msg $chan [^K]10×[^K]3 I am using[^K]7 CBPug Bot v2.0[^K]3, a bot in the C-Bots family line. [^K]10×
msg $chan [^K]10×[^K]3 C-Bots were/are created by [^K]7youngMoney [^K]10×
}
ON *:TEXT:.owner:?:{
if ($hfind(pstaff,500,1,w).data) {
msg $nick [^K]10×[^K]3 The owner is already set to the hostmask $hfind(pstaff,500,1,w).data [^K]10×
}
else {
hadd pstaff $address($nick,2) 500
hsave pstaff pstaff.hsh
msg $nick [^K]10×[^K]3 You have been added as the owner. [^K]10×
}
}
ON *:TEXT:.addadmin*:#:{
if ($paccess >= 200) {
if (!$3) {
hadd pstaff $address($2,2) 200
hsave pstaff pstaff.hsh
notice $nick [^K]10×[^K]3 $2 has been added with 200 access. [^K]10×
}
else {
if ($paccess > $3) {
hadd pstaff $address($2,2) $3
hsave pstaff pstaff.hsh
notice $nick [^K]10×[^K]3 $2 has been added with $3 access. [^K]10×
}
}
}
else {
notice $nick [^K]10×[^K]3 You do not have the access to use this command. [^K]10×
}
}
ON *:TEXT:.deladmin*:#:{
if ($paccess >= 200) && ($paccess > $hget(pstaff,$address($2,2))) {
hdel pstaff $address($2,2)
hsave pstaff pstaff.hsh
notice $nick [^K]10×[^K]3 $2 has had their access deleted. [^K]10×
}
else {
notice $nick [^K]10×[^K]3 You do not have the access to use this command. [^K]10×
}
}
ON *:TEXT:.slots*:#:{
if (!$2) {
msg $chan [^K]10×[^K]3 Number of slots for pug is set to[^K]7 %slots [^K]10×
}
else {
if ($2 isnum 2-16) {
set %slots $2
msg $chan [^K]10×[^K]3 The number of slots for pug is now set to[^K]7 %slots [^K]10×
}
else {
notice $nick [^K]10×[^K]3 That is an invalid number of slots. [^K]10×
}
}
}
ON *:TEXT:.clearpug:#:{
if ($paccess >= 100) {
hfree pusers
hmake pusers
msg $chan [^K]10×[^K]3 The pug information has been cleared. [^K]10×
}
}
ON *:TEXT:.join:#:{
if ($hfind(pusers,*,0,w) <= %slots ) {
hadd -u600 pusers $address($nick,2) $nick
msg $chan [^K]10×[^K]3 Player[^K]7 $nick [^K]3added.[^K]7 $$calc(%slots - $hget(pusers,0).item) [^K]3slots remaining. [^K]10×
}
if ($hfind(pusers,*,0,w) == %slots ) {
startpug
}
}
ON *:TEXT:.quit:#:{
hdel pusers $address($nick,2)
msg $chan [^K]10×[^K]3 Player[^K]7 $nick [^K]3has been removed.[^K]7 $calc(%slots - $hget(pusers,0).item) [^K]3slots remaining. [^K]10×
}
ON *:NICK:{
if ($hget(pusers,$address($newnick,2))) {
hadd -u600 pusers $address($newnick,2) $newnick
}
}
ON *:EXIT:{
if ($hfind(pusers,$nick,1).data) {
hdel pusers $hfind(pusers,$nick,1,w).data
msg $chan [^K]10×[^K]3 Player[^K]7 $nick [^K]3removed (Exit).[^K]7 $calc(10- $hget(pusers,0).item) [^K]3slots remaining. [^K]10×
}
}
on *:PART:#:{
if ($hfind(pusers,$nick,1).data) {
hdel pusers $hfind(pusers,$nick,1,w).data
msg $chan [^K]10×[^K]3 Player[^K]7 $nick [^K]3removed (Exit).[^K]7 $calc(10- $hget(pusers,0).item) [^K]3slots remaining. [^K]10×
}
}
ON *:TEXT:.servers:#:{
if ($hfind(pservers,*,0,w) == 0) {
msg $chan [^K]10×[^K]3 There are no servers set for the pug. To add yours, type .addserver [^B]ip:port [^K]10×
}
else {
set %x 1
while (%x <= $hget(pservers,0).item) {
var %pservers %pservers [^B]IP:[^B] $hget(pservers, $+ %x $+ ).item [^B]PW:[^B] $hget(pservers, $+ %x $+ ).data
inc %x
}
msg $chan [^K]10×[^K]3 Server List: [^K]10 %pservers [^K]10×
}
}
ON *:TEXT:.addserver*:#:{
if ($paccess >= 100) {
hadd pservers $2 $3
hsave -o pservers pservers.hsh
notice $nick [^K]10×[^K]3 Server has been added. [^K]10×
}
}
ON *:TEXT:.delserver*:#:{
if ($hfind(pservers,$2,1,W)) && ($paccess >= 100) {
hdel pservers $2
hsave -o pservers pservers.hsh
notice $nick [^K]10×[^K]3 Server has been deleted from the list. [^K]10×
}
}
ON *:TEXT:.startpug:#:{
startpug
}
on *:text:.a*:#:{
if (!$2) {
if ($hget(pstaff,$address($nick,2))) {
notice $nick You have $hget(pstaff,$address($nick,2)) access.
}
else {
notice $nick You lack access.
}
}
else {
if ($hget(pstaff,$address($2,2))) {
notice $nick $2 has $hget(pstaff,$address($2,2)) access
}
else {
notice $nick $2 lacks access.
}
}
}
ctcp *:version:*:/ctcpreply $nick VERSION CBPug v2.0 by youngMoney
alias startpug {
if ($hget(pusers,0).item == %slots) {
if ($hget(pservers,0).item > 0) {
var %x 1
var %y $calc($hget(pusers,0).item /2+1))
var %terrorists [^B]Terrorists:[^B]
var %counterterrorists [^B]Counter-Terrorists:[^B]
var %half $calc($hget(pusers,0).item $+ /2)
while (%x <= $calc($hget(pusers,0).item /2)) {
var %terrorists %terrorists $hget(pusers, $+ %x $+ ).data
cprivmsg $hget(pusers, $+ %x $+ ).data $chan [^K]10×[^K]3 Pug now starting. Check $chan for more information. [^K]10×
inc %x
}
while (%y <= $calc($hget(pusers,0).item)) {
var %counterterrorists %counterterrorists $hget(pusers, $+ %y $+ ).data
cprivmsg $hget(pusers, $+ %y $+ ).data $chan [^K]10×[^K]3 Pug now starting. Check $chan for more information. [^K]10×
inc %y
}
msg $chan [^K]10× [^K]15,14The Pug is now starting. Please choose a server from the .servers list.[^K] [^K]10×
msg $chan [^K]10× [^K]15,14The teams are:[^K] [^K]10×
msg $chan [^K]10×[^K]3 [^K]0,4 $+ %counterterrorists $+ [^K] [^K]10×
msg $chan [^K]10×[^K]3 [^K]0,12 $+ %terrorists $+ [^K] [^K]10×
msg $chan [^K]10× [^K]15,14This pug has been brought to you by the CBPug Bot. Enjoy your game, and please play respectfully.[^K] [^K]10×
hfree pusers
hmake pusers
inc %pug.num
}
else {
msg $chan [^K]10×[^K]3 There has been no server supplied for the pug. Please .addserver [^B]IP:Port[^B] and then type .startpug [^K]10×
}
}
else {
msg $chan [^K]10×[^K]3 There are not enough people for the pug. Please fill the remaining $calc(%slots - $hget(pusers,0).item) slots. [^K]10×
}
}
alias paccess {
return $hget(pstaff,$address($nick,2))
}
alias ipverify {
;; Checks for a valid ip/port
;; Usage: $ipverify(ip[:port])[.ip|port]
var %regex = /((?:\d{1,3}\.){3}\d{1,3})((?::|\s)\d{1,5})*$/
if ($regex(ip,$1,%regex)) {
var %x = 1
while (%x <= $gettok($regml(ip,1),0,46)) {
if ($gettok($regml(ip,1),%x,46) > 255) return Invalid
inc %x
}
if ($prop == ip) return Valid - $regml(ip,1)
if ($prop == port) {
if ($regml(ip,2)) {
if ($right($ifmatch,-1) <= 65535) return Valid
else return Invalid
}
}
else return Valid
}
else return Invalid
}
alias sleep {
var %a = $ticks $+ .wsf
write %a <job id="js"><script language="jscript">WScript.Sleep( $+ $$1 $+ );</script></job>
.comopen %a WScript.Shell
if !$comerr { .comclose %a $com(%a,Run,3,bstr,%a,uint,0,bool,true) }
.remove %a
}