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.

What's wrong?

Old posts that have not been replied to for several years.
Locked
j
jpheur

Post by jpheur »

Why this script won't do anything, even say error message:

Code: Select all

############### Bad words ###############
## Do not punish these channels:
set do_not_punish_these_chans {  }

#######################################

bind pub - "*[censored]*" punish
bind pub - "*[censored]*" punish
bind pub - "sorry*" apologize

########################################

proc punish {nick host hand chan} {
	global do_not_punish_these_chans
	foreach badchan $do_not_punish_these_chans
	if { [onchan $nick "#$badchan"] } { return 0 }
	puthelp "PRIVMSG $chan :$nick! Say sorry!!"
	set criminal { $nick }
	set crimechan { $chan }
	timer 0.5 warning2
	set asked_sorry { "ei" }
}

proc warning2 {} {
	global criminal crimechan
	if { [asked_sorry == "yes"] } { return 0 }
	puthelp "PRIVMSG $crimechan :It would be nice to say sorry!"
	timer 0.2 warning3
}

proc warning3 {} {
	global criminal crimechan
	if { [asked_sorry == "yes"] } { return 0 }
	puthelp "PRIVMSG $crimechan :Damn you $criminal."
	putserv "KICK $crimechan $criminal Shame!"
	set anteeksiannettu { "yes" }
}

proc apologize {nick host hand chan} {
	puthelp "PRIVMSG $chan: That's ok!"
	set anteeksiannettu { "yes" }
}

########################################

putlog "Do not use bad words!!!"

########################################
Thanks

<font size=-1>[ This Message was edited by: jpheur on 2001-10-11 14:46 ]</font>
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

I see a hell of a lot of errors in that. Firstly the binds are wrong for wildcarded matches (should be pubm). Procs are declared with incorrect number of args. Foreach loop in proc punish declaired with no body. unpunished chans section in same script needs competly redesigning. asked_sorry not declared as global variable in any proc. timers can't use fractional numbers (use utimer for seconds). warning's 2 and 3 should be called from timer with the nick and chan as arguments, and appropriatly declared in the proc. if { [asked_sorry == "yes"] } would return an error, as it would try and execute either 1 or 0 as a command due to square brackets. $asked_sorry and $anteeksiannettu should be same thing. also they really should be declared as arrays, with $nick as the array index. i might write this all for you properly tomorrow if i have the time

<font size=-1>[ This Message was edited by: Petersen on 2001-10-11 17:32 ]</font>
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Code: Select all

############### Bad words ###############

## Do not punish this channels - keep them lowercase
set not_punish {
  #channel1
  #channel2
  #channelx
  #mychan
}

# Punishable words
set punish_words {
[censored]
****
word
"multiword format"
"what a looser"
}

## THE DREADED DO NOT TOUCH BIT

set punish_nicks

proc punish:1 {nick uh hand chan arg} {
  global punish_nicks not_punish
  if {[lsearch -exact $not_punish [string tolower $chan]] >= 0} { return }
  if {[set idx [lsearch -exact $punish_nicks [string tolower $nick]]] >= 0} {
    set punish_nicks [lreplace $punish_nicks $idx $idx]
    putkick $chan $nick "You are suposed to say sorry, not swear again"
    return
  }
  lappend punish_nicks [string tolower $nick]
  puthelp "PRIVMSG $chan :${nick}! Say sorry for swearing (warning one)!!"
  utimer 30 [list punish:2 $nick $chan]
}

proc punish:2 {nick chan} {
  global punish_nicks
  if {[set idx [lsearch -exact $punish_nicks [string tolower $nick]]] >= 0} {
    if {![onchan $nick $chan]} {
      set punish_nicks [lreplace $punish_nicks $idx $idx]
      return
    }
    puthelp "PRIVMSG $chan :${nick}! You have allready been warned, all you have to say is sorry!"
    utimer 10 [list punish:3 $nick $chan]
  }
}

proc punish:3 {nick chan} {
  global punish_nicks
  if {[set idx [lsearch -exact $punish_nicks [string tolower $nick]]] >= 0} {
    set punish_nicks [lreplace $punish_nicks $idx $idx]
    if {![onchan $nick $chan]} { return }
    putkick $chan $nick "You only had to say sorry"
  }
}

proc punish:sorry {nick uh hand chan arg} {
  global punish_nicks not_punish
  if {[lsearch -exact $not_punish [string tolower $chan]] >= 0} { return }
  if {[set idx [lsearch -exact $punish_nicks [string tolower $nick]]] >= 0} {
    set punish_nicks [lreplace $punish_nicks $idx $idx]
    puthelp "PRIVMSG $chan :${nick}! See, that wasn't too hard"
  }
}
bind pub - "sorry" punish:sorry

foreach a $punish_words {
  bind pubm - "*${a}*" punish:1
}
unset a

putlog "BYE BYE BADWORDS - ppslim"
Locked