This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Looking for someone to re-script my age kicker

Help for those learning Tcl or writing their own scripts.
Post Reply
b
b0rk
Voice
Posts: 4
Joined: Sat Apr 19, 2008 8:35 am

Looking for someone to re-script my age kicker

Post by b0rk »

Can anyone else me, i get these errors

Code: Select all

[13:17] Tcl error [realname]: can't read "::sgchost": no such variable
[13:17] Not a ghost.
This one..

Code: Select all

[13:12] Tcl error [realname]: can't read "::jchan": no such variable
from this..

Code: Select all

bind pubm -|- "#database *SIGNED ON*" ghstcheck
bind join - *  whoisjoin
bind raw * 311 realname 
bind raw * 302 userhst
set gclone 0
set gnick ""
proc whoisjoin {nick uhost hand chan} {
	global botnick
	if {$nick==$botnick} { return }
	set ::jchan $chan
	#putlog "joined room is $::jchan"
	putquick "MODE $chan +v $nick"
  	putquick "whois $nick"
}
proc userhst { from key arg } {
set ::sgchost [string trim [string range $arg [expr [string first @ $arg] +1] end]]
set ::sgidnt [string range $arg [expr [string first + $arg] +1] [expr [string first @ $arg] -1] ]

#putlog "sgchost is $::sgchost"
if {$::sgchost=="Guardian :"} {
	putlog "Not a ghost."
}
return [string trim $::sgchost ]
}
proc ghstcheck { nick host hand chan text} {
  set chr(32) " "
  set signtxt [clone_stripcodes  [string trim $text]]
  set sighst [lindex $signtxt 2]
  set sgnick [lindex $signtxt 1]
  set ::gidnt [string range $sighst [expr [string first ( $sighst] +1] [expr [string first @ $sighst] -1] ]

  set sghost [string range $sighst [expr [string first @ $sighst] +1] end]
  set sgrnme  [string range $signtxt [expr [string first [lindex $signtxt 3] $signtxt] ] [expr [string first ) $signtxt] -1]]
  if {$sgrnme=="SearchIRC Crawler"} { set versi \00311IrcSearchRobot\00304 }
  if {$sgrnme!="SearchIRC Crawler"} { set versi \00309MircUser }

  #set sgrnme [string range $sgrnm [expr [string first $chr(32) $sgrnm] +1] end]
  #putlog "srgnm is sgrnm , sgrnme is $sgrnme"  
  set sgage [lindex $sgrnme 0]
  set sggender [strlwr [lindex $sgrnme 1]]
   #putlog "gender is $sggender"
  if {($sggender=="female") || ($sggender=="f")} { set gender \00313Female\00304 }

  if {($sggender=="male") || ($sggender=="m")} { set gender \00312Male\00304 }

  set sgloca [string range $sgrnme [string first [lindex $sgrnme 2] $sgrnme] end]
  set nicklen [expr [string length $sgnick ] -4]
  set nicktrim [string range $sgnick 0 $nicklen]
  set ::gnick $sgnick
  set ::grname [string trim $sgrnme ]
  set ::ghost [string trim $sghost ]
  set ::ghostnick $nicktrim
putquick "userhost $nicktrim"
if ([isnum $sgage]) {
putquick "PRIVMSG #Controlroom : \00304 $::gnick joined the network, they are $sgage years old $gender from $sgloca  " 
  } else { 
		#putlog "\00313realname is $sgrnme"
		if {($sgrnme!="SearchIRC Crawler") && ($sgrnme!="netsplit de")} { putquick "PRIVMSG #Controlroom : \00304 $::gnick joined the network, $versi "
    		}
	}
#putlog "text is $signtxt"
 # putlog "nick is $sgnick , realname is $sgrnme , host is $sghost , age is $sgage gender is $sggender loca is $sgloca ident is $::gidnt"
 # putlog "\002\0039doing whois on $nicktrim"
  putquick "whois $nicktrim"

}
proc isnum {string} {if {([string compare $string ""]) && (![regexp {[^0-9]} $string])} then {return 1};return 0}

proc realname {from key arg} {
global botnick nick gclone
   set argst [clone_stripcodes [string trim $arg]]
   #putlog "arg is $arg"
#putlog "joined idnt is $::gidnt ghost idnt is $::sgidnt"
   set cchan $::jchan
   set rname [string range $argst [expr [string first : $argst] +1] end]
   set age [lindex $rname 0]
   set cnick [lindex $arg 1]
   set uahost [getchanhost $cnick $cchan]

   #putlog "nicklength is $nicklen nicktrim is $nicktrim ghost is $::ghost gclone is $::gclone"
   if {($::gnick!="")&&($::sgchost!="Guardian :")} {
	if {($::grname==$rname)&&($::gidnt==$::sgidnt)} {
	putlog "names and ident match"
		putquick "PRIVMSG #Controlroom : \00304 Killing the Ghost of $::ghostnick " 
		putquick "PRIVMSG  operserv :set superadmin on"
		putquick "kill $::ghostnick  Nick Collision"
		putquick "PRIVMSG operserv :svsnick $::gnick $::ghostnick " 
		putlog "\002\0049changing $::gnick to $::ghostnick "
		putquick "PRIVMSG  operserv :set superadmin off"
		putlog "\002\0039superadmin on-off, svsick $::gnick, killed $cnick"
		#utimer 3 unsetclone
		set ::grname ""
		set ::ghost ""
		set ::ghostnick ""
		set ::gnick ""
		set ::sgchost ""
		#putserv "ghost is $::ghost : ghostnick is $::ghostnick  "
		return
	}
      putlog "\002\0039not killing, grname is $::grname rname is $rname ghost is $::ghost uahost is $::sgchost  "
	#utimer 3 unsetclone
	set ::gnick ""
	set ::grname ""
	set ::ghost ""
	set ::ghostnick ""

	return
    }
  
   set banmask "*!*[string range $uahost [string first "@" $uahost] end]"
   set ua_reason "You are under age for $cchan"
   set uan_reason "You are under age for this network."
   #putlog "banmask is $banmask"
   #putlog "real name is $rname age is $age channel is $cchan : nick is $cnick mask is $banmask"
   if ([isnum $age]) {
	if {$age<15} {
	  if {[onchan $cnick $cchan]} {    
		putlog "\002\0039«\003\002banning $cnick from $cchan for being underage for the network ($age)\002\0039»\003\002\ "
		newchanban $cchan $cnick $nick $uan_reason 10 
		newchanban $cchan $banmask $nick $uan_reason 10
		putquick "MODE $cchan +bb $banmask $cnick"
		#putquick "MODE $cchan +b $cnick"
		putquick "KICK $cchan $cnick :You are underage for this network."
		return
	   }
	}
	if {$age<16&&($cchan!="#Aberdeen"&&$cchan!="#Belfast"&&$cchan!="#TheRegulars"&&
       $cchan!="#Birmingham"&&$cchan!="#Bolton"&&$cchan!="#Brighton"&&
       $cchan!="#Bristol"&&$cchan!="#Cambridge"&&$cchan!="#Canterbury"&&$cchan!="#Cardiff"&&
       $cchan!="#Carlisle"&&$cchan!="#Chan-Islands"&&$cchan!="#Chester"&&
       $cchan!="#Colchester"&&$cchan!="#Coventry"&&$cchan!="#Croydon"&&$cchan!="#Darlington"&&
       $cchan!="#Derby"&&$cchan!="#Doncaster"&&$cchan!="#Dorset"&&$cchan!="#Dublin"&&
       $cchan!="#Dundee"&&$cchan!="#Dumfries"&&$cchan!="#Durham"&&$cchan!="#Dundee"&&
       $cchan!="#Edinburgh"&&$cchan!="#Enfield"&&$cchan!="#Exeter"&&$cchan!="#Falkirk"&&
       $cchan!="#Flyde"&&$cchan!="#Forum"&&$cchan!="#Glasgow"&&$cchan!="#Gloucester"&&
       $cchan!="#Guildford"&&$cchan!="#Huddersfield"&&$cchan!="#Hull"&&$cchan!="#Inverness"&&
       $cchan!="#Ipswich"&&$cchan!="#Ireland"&&$cchan!="#Kilmarnock"&&$cchan!="#Kingston-u-t"&&
       $cchan!="#Leeds"&&$cchan!="#Lincoln"&&$cchan!="#Liverpool"&&$cchan!="#London"&&
       $cchan!="#Luton"&&$cchan!="#Maidstone"&&$cchan!="#Manchester"&&$cchan!="#Medway"&&
       $cchan!="#Middlesbrough"&&$cchan!="#MiltonKeynes"&&$cchan!="#Motherwell"&&$cchan!="#Music"&&
       $cchan!="#Newcastle"&&$cchan!="#Newport"&&$cchan!="#Northampton"&&$cchan!="#Norwich"&&
       $cchan!="#Nottingham"&&$cchan!="#Oxford"&&$cchan!="#Peterborough"&&$cchan!="#Plymouth"&&
       $cchan!="#Preston"&&$cchan!="#Reading"&&$cchan!="#Romford"&&$cchan!="#Scotland"&&
       $cchan!="#Sheffield"&&$cchan!="#Slough"&&$cchan!="#Southampton"&&$cchan!="#Stevenage"&&
       $cchan!="#Stokeontrent"&&$cchan!="#Sunderland"&&$cchan!="#Swansea"&&$cchan!="#Swindon"&&
       $cchan!="#Taunton"&&$cchan!="#Technology"&&$cchan!="#Torquay"&&$cchan!="#Truro"&&
       $cchan!="#Wales"&&$cchan!="#Wolverhampton"&&$cchan!="#Worcester"&&$cchan!="#Wrexham"&&
       $cchan!="#York"&&$cchan!="#Leicester")} {
         if {[onchan $cnick $cchan]} {   
		putlog "\002\0039«\003\002banning $cnick from $cchan for being underage ($age) room $cchan\002\0039»\003\002\ "
		#putserv "privmsg $cchan :$cnick  you are underage for this room [$cchan]"
		newchanban $cchan $cnick $nick $ua_reason 10  
		newchanban $cchan $banmask $nick $ua_reason 10
		putquick "MODE $cchan +bb $banmask $cnick"
		#putquick "MODE $cchan +b $cnick"
		putquick "KICK $cchan $cnick :You are underage for this room, Please join another room."
		return
	   }
	}
	if {$age<35&&$cchan == "#40something"} { 
	  if {[onchan $cnick $cchan]} {   
		putlog "\002\0039«\003\002banning $cnick from $cchan for being underage ($age) room $cchan\002\0039»\003\002\ "
		#putserv "privmsg $cchan :$cnick  you are underage for this room [$cchan]"
		newchanban $cchan $cnick $nick $ua_reason 10  
		newchanban $cchan $banmask $nick $ua_reason 10
		putquick "MODE $cchan +bb $banmask $cnick"
		#putquick "MODE $cchan +b $cnick"
		putquick "KICK $cchan $cnick :You are underage for this room, Please join another room."
		return
	   }
	}
	if {$age<18&&$cchan == "#Nightclub"} { 
	  if {[onchan $cnick $cchan]} {   
		putlog "\002\0039«\003\002banning $cnick from $cchan for being underage ($age) room $cchan\002\0039»\003\002\ "
		#putserv "privmsg $cchan :$cnick  you are underage for this room [$cchan]"
		newchanban $cchan $cnick $nick $ua_reason 10  
		newchanban $cchan $banmask $nick $ua_reason 10
		putquick "MODE $cchan +bb $banmask $cnick"
		#putquick "MODE $cchan +b $cnick"
		putquick "KICK $cchan $cnick :You are underage for this room, Please join another room."
		return
	   }
	}
	if {$age<18&&$cchan == "#Paranormal"} { 
	  if {[onchan $cnick $cchan]} {   
		putlog "\002\0039«\003\002banning $cnick from $cchan for being underage ($age) room $cchan\002\0039»\003\002\ "
		#putserv "privmsg $cchan :$cnick  you are underage for this room [$cchan]"
		newchanban $cchan $cnick $nick $ua_reason 10  
		newchanban $cchan $banmask $nick $ua_reason 10
		putquick "MODE $cchan +bb $banmask $cnick"
		#putquick "MODE $cchan +b $cnick"
		putquick "KICK $cchan $cnick :You are underage for this room, Please join another room."
		return
	   }
	}
	if {$age<18&&$cchan == "#20something"} { 
	  if {[onchan $cnick $cchan]} {   
		putlog "\002\0039«\003\002banning $cnick from $cchan for being underage ($age) room $cchan\002\0039»\003\002\ "
		#putserv "privmsg $cchan :$cnick  you are underage for this room [$cchan]"
		newchanban $cchan $cnick $nick $ua_reason 10  
		newchanban $cchan $banmask $nick $ua_reason 10
		putquick "MODE $cchan +bb $banmask $cnick"
		#putquick "MODE $cchan +b $cnick"
		putquick "KICK $cchan $cnick :You are underage for this room, Please join another room."
		return
	   }
	}
	if {$age<45&&$cchan == "#50something"} { 
	  if {[onchan $cnick $cchan]} {   
		putlog "\002\0039«\003\002banning $cnick from $cchan for being underage ($age) room $cchan\002\0039»\003\002\ "
		#putserv "privmsg $cchan :$cnick  you are underage for this room [$cchan]"
		newchanban $cchan $cnick $nick $ua_reason 10  
		newchanban $cchan $banmask $nick $ua_reason 10
		putquick "MODE $cchan +bb $banmask $cnick"
		#putquick "MODE $cchan +b $cnick"
		putquick "KICK $cchan $cnick :You are underage for this room, Please join another room."
		return
	   }
	}
	if {$age<25&&$cchan == "#30something"} { 
	  if {[onchan $cnick $cchan]} {   
		putlog "\002\0039«\003\002banning $cnick from $cchan for being underage ($age) room $cchan\002\0039»\003\002\ "
		#putserv "privmsg $cchan :$cnick  you are underage for this room [$cchan]"
		newchanban $cchan $cnick $nick $ua_reason 10  
		newchanban $cchan $banmask $nick $ua_reason 10
		putquick "MODE $cchan +bb $banmask $cnick"
		#putquick "MODE $cchan +b $cnick"
		putquick "KICK $cchan $cnick :You are underage for this room, please join another room."
		return
	   }
	  }
  }
}

proc unsetclone {} { set ::gclone 0 }

proc clone_stripcodes {text} {
	regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $text "" text
	set text "[string map -nocase [list \002 "" \017 "" \026 "" \037 ""] $text]"
	return $text
}
Thanks

Edit: Code wrapping. (Sir_Fz)
Last edited by b0rk on Sat Apr 19, 2008 2:37 pm, edited 1 time in total.
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

you need to provide result of using ".set errorInfo" (see this topic)
b
b0rk
Voice
Posts: 4
Joined: Sat Apr 19, 2008 8:35 am

Post by b0rk »

Thanks, i'm no good at scripting, can anyone do it for me?

cheers
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Post by YooHoo »

b0rk wrote:Thanks, i'm no good at scripting, can anyone do it for me?
you are not paying attention. Go to your bot's partyline, type .set errorInfo, then copy/paste what the bot says here.
b
b0rk
Voice
Posts: 4
Joined: Sat Apr 19, 2008 8:35 am

Post by b0rk »

Okay i did that and it keeps saying

`What? You need .help' even witht hem commands disabled.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The cause of the error in the script would most likely be due to doing a check on someone who was already present in the channel when your bot joined (::sgchost is set whenever a 302 reply is given to a USERHOST command, sent by eggdrop by default when someone joins the channel; ::jchan is set by the proc "whoisjoin" - which is triggered by someone joining the channel.)

Roughly put, whenever any script does a WHOIS on someone your bot did not actually see join any channel, you'll end up with this error. Getting this working properly would take some rewriting of the code.
NML_375
b
b0rk
Voice
Posts: 4
Joined: Sat Apr 19, 2008 8:35 am

Post by b0rk »

Okay can someone help re-write it? thanks
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Please edit your post and replace your current subject with a relevant one.
I
Ibcus
Voice
Posts: 1
Joined: Thu Aug 14, 2008 8:31 pm

Post by Ibcus »

I wrote that script, and it's not just an age kicker.
May not be the best code in the world, but it works fine for me, regardless of people being in the room when it rejoins
Post Reply