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.

egg-fu 2.0.2 problem

Support & discussion of released scripts, and announcements of new releases.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Yeah.. I got the same private message with questions about this thread. It's not needed to do this if you've already mentioned it in a thread btw (especially to two entirely different members, sheesh!). Mostly because by the time I see and have had time to reply to your error/question, someone else has already done so, which is basically a waste of my time.

Now.. about this script, quite honestly, it's like nml375 has said. The script is badly written using a single parameter of args (full of restrictions) in the proc header, then uses clumsy lindex/lrange methods (incorrectly applying them to strings...) to tear out the variables. Instead of all this they could've easily passed variables directly using them as parameters. Because of the clumsiness of this approach it makes debugging by eye harder. When just learning tcl, some people just stubble odd code bits together for no apparent reason at all (when functions exist to easily do them internally), then act all arrogant in the top comments of their script like it's some work of god. It's sometimes funny to see, sometimes it's not. In this case it's sorta both. To me funny, to you the sad, unfortunately. The good part is, you can use any other script as an example of proper tcl style, and possibly learn how to fix things yourself if your inclined enough. It's enough to ask once, even twice is okay, at some point you appear as if begging. When a person begs, it's usually because they refuse to do the required work to earn something for themselves. Homeless people most times fit this description, sometimes those using internet forums do too, it's a grab bag. But for future refernece (at least on this forum) try not to appear so 'homeless' (...if you know what I mean, heh) :wink:
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

egg-fu is no longer supported and the original author unreachable!

I'd suggest using bMotion instead.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
P
PoHuIsT
Voice
Posts: 23
Joined: Mon Oct 22, 2007 7:49 am

Post by PoHuIsT »

Alchera wrote:egg-fu is no longer supported and the original author unreachable!

I'd suggest using bMotion instead.
YA i now but bnotion iz wery slow and not so good as egg-fuu
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

It cant be that good if it doesn't work =p
P
PoHuIsT
Voice
Posts: 23
Joined: Mon Oct 22, 2007 7:49 am

Post by PoHuIsT »

rosc2112 wrote:It cant be that good if it doesn't work =p
ic working almost but with 1 eror

Code: Select all

[09:26] expected integer but got "09" (looks like invalid octal number)
    while executing
"expr [lindex [split $arg :] 0] + [unoctal [lindex [split $arg :] 1]] * 60"
    (procedure "mconv" line 1)
    invoked from within
"mconv [getdate time]"
    (procedure "myage" line 7)
    invoked from within
"myage"
    invoked from within
"putlog "\002egg\002-\002fu\002 \002$eggver\002 loaded! (age: [myage], sex: $sex
)""
    (file "scripts/egg-fu_2.0.11.tcl" line 762)
    invoked from within
"source scripts/egg-fu_2.0.11.tcl"
P
PoHuIsT
Voice
Posts: 23
Joined: Mon Oct 22, 2007 7:49 am

Post by PoHuIsT »

here iz my script code maybe i do samthing wrong ?:)

Code: Select all

#eggdrop1.6 +/-
#                              ___                             
#   .-----..-----..-----. __ .'  _|.--.--.
#   |  -__||  _  ||  _  ||__||  ._||  |  |
#   |_____||___  ||___  |    |__|  |_____|
#          |_____||_____|
#                              version 2.0.11
#				
#
#                              Copyright (C) 2002-2003, Kevin Lanni
#                              ch3mi0n@users.sourceforge.net
#                              irc.easynews.com#ch3mpo (EFnet)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
# Version Information (Major Additions and Bug Fixes!) can be found in the
# Version.txt included in the package.
#
# Feature explanations, instructions, and HELP can be found in
# How-to.txt included in the package.
#
#  ** THIS PROGRAM IS NOT INTENDED FOR USE IN WINDROP AND YOU WILL **
#  ** NOT RECIEVE SUPPORT IF YOU ATTEMPT TO RUN EGG-FU IN WINDROP  **
#  ** BECAUSE I CAN TELL YOU RIGHT NOW IT DOES NOT WORK!           **
#  **   AND THIS GOES FOR ALL WINDOWS IMPLEMENTATIONS OF EGGDROP   **
#
##########################################################################

# If you use the following code in any form partial or modifed, at least #
# give the programmer who did this much hard work his deserved credit!   #

##########################################################################
#
# Greets:
# Tigrrr, psykoz, dilvie, yo momma, mickrip, poke, #trax@efnet
# DemonSeed, lobywang, scrap, d0oGs, paco, tls,
# one_, sunrpc, ^PLAID^, Tenebrous, Byte, #arizona@unet
# and various other freaks and geeks, you all know who you are 
#
# Special thanks to all my beta testers (this means you)
# Especially psykoz for being such a huge pain in my ass and consistantly nudging me to work on egg-fu :D
#
# Email your suggestions/questions/comments/bitches to:
# ch3mi0n@users.sourceforge.net - NO WINDOWS SUPPORT!
#
##########################################################################


set eggfu(path,cfg) "scripts/";	#set this to the location of your config files (advanced users)


####################################################
### Don't need to touch anything below this line ###
#$##################################################

### functions
proc low {i} {return [string tolower $i]}
proc bit {} {global eggfu;if {$eggfu(it)=="-no-"} {return ""} {return $eggfu(it)}}
proc botsnick {} {global botnick;return $botnick}
proc trim {i} {return [string trim $i]}

proc wordcount {} {
	
}

proc readrand {source} {
	set sf [open $source r]
	while {![eof $sf]} {
		set stdin [trim [gets $sf]]
		if {![regexp #.* $stdin] && $stdin != ""} {lappend readlist $stdin}
	}
	return $readlist
}

proc loadrand {} {
	global eggfu randarray
	foreach i $eggfu(randset) {set randarray($i) [trim [readrand $eggfu(path)/$i.txt]]}
}

proc grabrand {type} {
	global randarray
	return [lindex $randarray($type) [rand [llength $randarray($type)]]]
}	

proc saverand {} {
	global eggfu
	foreach i $eggfu(randset) {
		set file [open $i.txt w]
		foreach n $i {puts $file $n}
	}
}

proc loadcfg {path} {
	global eggfu grammar
	foreach cfg {eggfu grammar} {
		set cf [open $path$cfg.cfg r]
		while {![eof $cf]} {
			set stdin [string trim [gets $cf]]
			if {![regexp #.* $stdin] && $stdin != ""} {
				set ${cfg}([trim [lindex [split $stdin :] 0]]) [trim [lindex [split $stdin :] 1]]
			}
		}
	}
}

proc savecfg {} {
	global eggfu grammar
	foreach cfg {eggfu grammar} {
		set cf [open $cfg.cfg w]
		set a [array startsearch $cfg]
		for {set i 0} {$i<[array size $cfg} {incr i} {
			set element [array nextitem $cfg $a]
			#Unfinished broken code
		}
	}
}

proc fixgrammar {text} {
	global eggfu grammar
#Unfinished unbroken code
	set text "@ $text @"
	regsub -all -nocase " better then " $text " better than " text
	return [string trim [lrange $text 1 [expr [llength $text] - 2]]]
}

proc isfrozen {arg} {
	set i 0
	set text [getword $arg]
	set apos [lsearch -exact $text "=>"]
	set text [lrange $text [expr $apos + 1] e]
	if {[lindex $text 0] == "!"} {set i 1}
	if {[lindex $text 0] == "~"} {set i 1}
	return $i
}

proc isinop {arg} {
	set i 0
	foreach a {<reply> <action> <ctcp> <notice>} {
		if {$arg==$a} {set i 1}
	}
	return $i
}

proc alterit {nick host hand chan text} {
	regsub -all "[botsnick], " $text "" text
	regsub -all " s/" $text " " text
	regsub -all "/" $text " / " text
	set fseperator [lsearch -exact $text "=~"]
	set seperator [lsearch -exact $text "/"]
	set alterstring [lrange $text 0 [expr $fseperator -1]]
	set alterwhat [lrange $text 2 [expr $seperator -1]]
	set alterwith [lrange $text [expr $seperator +1] e]
	regsub -all " /" $alterwith "" alterwith
	set question [lrange [getword $alterstring] 1 e]
	set searchforwhat [lsearch -exact $question $alterwhat]

	if {[isfrozen $alterstring]} {
		putnotc $nick "'$alterstring' has been frozen."
	} elseif {$question == ""} {
		putnotc $nick "No variable set!"
	} elseif {$searchforwhat == "-1"} {
		putnotc $nick "'$alterwhat' not in '$alterstring'!"
	} {
		regsub -all $alterwhat $question $alterwith result
		delword $alterstring
		addword $alterstring $result
		putlog "!egg-fu! Alter: '$question' is now: $result"
		putnotc $nick "'$alterstring' is altered."
	}
}

proc freezeit {nick host hand chan text} {
	regsub -all "[botsnick], " $text "" text
	set wpos [lsearch -exact $text "freeze"]
	set what [lrange $text [expr $wpos + 1] e]
	set text [getword $what]
	set apos [lsearch -exact $text "=>"]
	set text [lrange $text [expr $apos + 1] e]

	if {[isfrozen $what]} {
		putnotc $nick "'$what' has already been frozen."
	} elseif {$what != ""} {
		putlog "!egg-fu! Freezing '$what'"
		delword $what
		addword $what "! $text"
		putnotc $nick "'$what' is now frozen."
	} {putnotc $nick "Freeze what?"}
}

proc thawit {nick host hand chan text} {
	set wpos [lsearch -exact $text "thaw"]
	set what [lrange $text [expr $wpos + 1] e]
	set text [getword $what]
	set apos [lsearch -exact $text "=>"]
	set text [lrange $text [expr $apos + 1] e]

	if {![isfrozen $what]} {
		putnotc $nick "'$what' isn't frozen."
	} elseif {$what != ""} {
		putlog "!egg-fu! Thawing '$what'"
		delword $what
		addword $what [lrange $text 1 e]
		putnotc $nick "'$what' is now unfrozen."
	} {putnotc $nick "Thaw what?"}
}

proc lockit {nick host hand chan text} {
	regsub -all "[botsnick], " $text "" text
	set wpos [lsearch -exact $text "lock"]
	set what [lrange $text [expr $wpos + 1] e]

	if {[isfrozen $what]} {
		putnotc $nick "'$what' has been frozen."
	} elseif {$what != ""} {
		putlog "!egg-fu! Locking '$what'"
		delword $what
		addword $what "~"
		putnotc $nick "'$what' is now locked."
	} {putnotc $nick "Lock what?"}
}

proc unlockit {nick host hand chan text} {
	regsub -all "[botsnick], " $text "" text
	set wpos [lsearch -exact $text "unlock"]
	set what [lrange $text [expr $wpos + 1] e]
	set text [lindex [getword $what] e]

	if {$text == "~" && $what != ""} {
		delword $what
		putlog "!egg-fu! Unlocked '$what'"
		putnotc $nick "'$what' is now unlocked."
	} {putnotc $nick "Unlock what?"}
}

proc forgetit {nick host hand chan text} {
	set wpos [lsearch -exact $text "forget"]
	set what [lrange $text [expr $wpos + 1] e]
	set text [lrange [getword $what] 1 e]

	if {[isfrozen $what]} {
		putnotc $nick "'$what' has been frozen."
	} elseif {$text == ""} {
		putnotc $nick "'$what' not found."
	} elseif {$what != "" && [llength $what] < 3} {
		delword $what
		putnotc $nick "'$what' forgotten."
	} {putnotc $nick "Forget what?"}
}

proc karma_info {nick host hand chan text} {
	set karma_action [lindex $text 0]
	regsub -all "\\\?" $text "" text
	set karma [lindex $text 1]
	if {$karma == "me"} {
		set karma $nick
	} elseif {$karma == ""} {
		putnotc $nick "You have not entered a karma option (karma for/set/reset)"
	} elseif {$karma_action == "for"} {
		set answer [lrange [getword "<karma> $karma"] 1 e]
		if {$answer == "" || $answer == "0"} {
			putchan $chan "$karma has neutral karma"
		} {
			putchan $chan "$karma has karma of $answer"
		}
	} elseif {$karma_action == "set"} {
		set karma_setas [lindex $text 2]
		if {$karma == $nick} {
			putnotc $nick "Please don't karma yourself."
		} elseif {$karma_setas != ""} {
			putlog "!egg-fu! Karma: $karma been changed to $karma_setas"
			delword "<karma> $karma"
			addword "<karma> $karma" $karma_setas
			putchan $chan "$karma has now been set to $karma_setas"
		} {
			putnotc $nick "You have not entered a set value! (karma set <karma> <new value>)"
		}
	} elseif {$karma_action == "reset"} {
		if {$karma == $nick} {
			putnotc $nick "Please don't karma yourself."
		} else {
			delword "<karma> $karma"
			addword "<karma> $karma" ""
			putchan $chan "$karma has been reset"
		}
	}
}

proc karma_action {nick host hand chan text} {
	regsub -all "\\\+\\\+" $text " \+\+" text
	regsub -all "\\\-\\\-" $text " \-\-" text
	set karma [lindex $text 0]
	set question [lrange [getword "<karma> $karma"] 1 e]
	if {$karma == "me"} {set karma $nick}
		
	if {$question == ""} {
		addword "<karma> $karma" 1
		putlog "!egg-fu! Karma: $karma set to 1"
	} elseif {[low $karma] == [low $nick]} {
		putnotc $nick "You cannot give yourself karma."
	} else {
		if {[lsearch -exact $text "\+\+"] == -1} {
			incr question -1
		} {incr question 1}
		delword "<karma> $karma"
		addword "<karma> $karma" $question
		putlog "!egg-fu! Karma: $karma set to $question"
	}
}

proc addword {keyword answer} {
	global eggfu
	if {$eggfu(mdirect)} {
		set fword [lindex $keyword 0]
		if {[string match *:* $fword]} { 
			if {[llength $keyword]>1} {
				set keyword [lrange $keyword 1 e]
			} {regsub -all ":" $keyword "" keyword}
		}
	}

# fix the 'mysterious disappearances' bug
	set feeler [lrange [getword $keyword] 1 e]
	if {$keyword != $feeler && ![isfrozen $keyword]} {
		set put "$keyword => $answer"
		regsub -all "\\{" $put "" put
		regsub -all "\\}" $put "" put
		set fh [open $eggfu(brain) a]
		puts $fh $put
		close $fh
		putlog "!egg-fu! Learn: $keyword => $answer"
	}
}

proc getword {keyword} {
	global eggfu
	set foundone 0
	set returnit {}
	set fh [open $eggfu(brain) r]
	while {![eof $fh]} {
		set stdin [string trim [gets $fh]]
		if {[eof $fh]} {break}
		set breaker [lsearch -exact $stdin "=>"]
		set getkey [low [lrange $stdin 0 [expr $breaker - 1]]]
		set getresult [low [lrange $stdin [expr $breaker + 1] e]]
		if {[string match -nocase "* $getkey *" "@ $keyword @"] || [string match -nocase "* $keyword *" "@ $getkey @"]} {
			set returnit $stdin;set foundone 1
			if {[rand 4]==1} {break}
		}
	}
	close $fh
	if {$foundone} {return [string trim $returnit]}
}

proc delword {keyword} {
	global eggfu
	set fh [open $eggfu(brain) r]
	set return {}
	set del 0
	while {![eof $fh]} {
		set stdin [string trim [gets $fh]]
		set breaker [lsearch -exact $stdin "=>"]
		set getkey [low [lrange $stdin 0 [expr $breaker - 1]]]
		if {[eof $fh]} {break}
		if {![string match -nocase "* $keyword *" " $getkey "]} {
			lappend return $stdin
		} {incr del 1}
	}
	close $fh
	set fh [open $eggfu(brain) w]
	foreach a $return {puts $fh $a}
	close $fh
	return $del
}

proc anynick {chan} { 
	set apb [botsnick]
	while {$apb == [botsnick]} {
		if {$apb != [botsnick]} {break}
		set apb [lindex [split [chanlist $chan]] [rand [llength [split [chanlist $chan]]]]]
	}
	return $apb
}

proc anyrandq {text} {
	regsub -all "\\| " $text "\t" text
	set randq [lindex [split $text \t] [rand [llength [split $text \t]]]]
	return $randq
}

proc randomize {q n c} {
	set israndom [lsearch -exact $q "|"]
	if {$israndom!=-1} {set q [anyrandq $q]}
# i plan on adding other $options in the future
	regsub -all \\\$date $q [ctime [unixtime]] q
	regsub -all \\\$month $q [grabrand months] q
	regsub -all \\\$day $q [grabrand days] q
	regsub -all \\\$animal $q [grabrand animals] q
	regsub -all \\\$nick $q [anynick $c] q
	regsub -all \\\$noun $q [grabrand nouns] q
	regsub -all \\\$adj $q [grabrand adjectives] q
	regsub -all \\\$adjective $q [grabrand adjectives] q
	regsub -all \\\$birthday $q [happybday] q
	regsub -all \\\$age $q [myage] q
	regsub -all \\\$sex $q [mysex] q
# regsub -all \\\{ $q "" q
# regsub -all \\\} $q "" q
	return [string trim $q]
}

proc mysex {} {
	global eggfu
	set bc [open $eggfu(path,bc) r]
	set sex [gets $bc]
	set sex [gets $bc]
	close $bc
	return $sex
}

proc myage {} {
	global eggfu
	set bc [open $eggfu(path,bc) r]
	set bdate [split [gets $bc] @]
	close $bc

	set ztime [unoctal [mconv [getdate time]]]
	set btime [unoctal [mconv [lindex $bdate 1]]]
	set bdate [lindex $bdate 0]
	set today [getdate date]
	set month [unoctal [lindex [split $today /] 0]]
	set bmonth [unoctal [lindex [split $bdate /] 0]]
	set zyear [getdate year]
	set byear [lindex [split $bdate /] 2]
#putlog "$ztime $btime $bdate $today $month $bmonth $zyear $byear"
	if {$today==$bdate} {
		return [lconv [expr $ztime - $btime]]
	} elseif {$month==$bmonth} {
		return "[expr [unoctal [lindex [split $today /] 1]] - [unoctal [lindex [split $bdate /] 1]]] days"
	} elseif {$zyear==$byear} {
		return "[expr $month - $bmonth] months"
	} else {
		return "[expr $zyear - $byear] years"
	}
}

proc lconv {mins} {
	set i 0;set n $mins;set hour 0
	while {$i<$n} {
		incr i
		if {$i>$n} {break}
		if {$mins>59} {incr mins -60;incr hour}
	}
	set mins [unoctal $mins]
	set hour [unoctal $hour]
#1440=24
	if {$mins!=0} {return "$hour hrs, $mins min"
	} {return "$hour hrs"}
}

proc mconv {args} {return [expr [lindex [split $args :] 1] + ([unoctal [lindex [split $args :] 0]] * 60)]}

proc getdate {arg} {
       set system [split [clock format [clock seconds] -format "%m/%d/%Y@%H:%M"] @]
       set date [split [lindex $system 0] /]
       set time [lindex $system 1]
       set month [lindex $date 0]
       set day [lindex $date 1]
       set year [lindex $date 2]
       set date [join $date /]

	if {$arg=="date"} {return $date}
	if {$arg=="time"} {return $time}
	if {$arg=="month"} {return $month}
	if {$arg=="day"} {return $day}
	if {$arg=="year"} {return $year}
}

proc unoctal {args} {
	set args [split $args {}]
	set n [llength $args]
	set i 0
	while {$i<$n} {
		if {[string match 0 [lindex $args 0]]} {regsub -all "0 " $args "" args}
		incr i;set n [llength $args]
		if {$i>$n} {break}
	}
	return [join $args {}]
}

proc happybday {} {
	global eggfu
	set bc [open $eggfu(path,bc) r]
	set bdate [lindex [gets $bc] 0];close $bc
	set bdiff [myage]

# !B is for born (birthdate), !D is for difference (age)
	set bday {
		{I was born on !B. I'm only !D old}
		{My birthday is !B}
		{My birthday is !B}
		{I'm only !D old!}
		{}
	}
	regsub -all "!B" $bday $bdate bday
	regsub -all "!D" $bday $bdiff bday
	return [lindex $bday [rand [llength $bday]]]
}

proc learnit {nick host hand chan text} {
	global botsnick eggfu

	regsub -all "\\\"" $text "'" text

# death to leet hax0rz!
# regsub -all "\\\\n|\\\\a|\\\\b|\\\\f|\\\\r|\\\\t|\\\\v" $text "" text
	regsub -all "\007|\015|\022|\026|\028|\030" $text "" text
	regsub -all "\\\\" $text "\\\\\\\\" text
# regsub -all "\\\[" $text "\\\\\\\[" text
# regsub -all "\\\]" $text "\\\\\\\]" text

# regsub -nocase "'s " $text " is " text
	regsub -nocase " let is " $text " lets " text
	regsub -nocase " isn't " $text " is not " text
	set text [fixgrammar $text]
 
	set start [low [lindex $text 0]]
	set ignorewords {[botsnick] who what ok}

	if {($eggfu(trig,lrn,0)) && [lindex $text 0]!="[bit]$eggfu(trig,lrn,1)"} {
		set do_nothing 1
	} elseif {![string match *$nick* $eggfu(ignores)]} {
# lets not forget about stripping! wooohoooo
		if {$eggfu(trig,lrn,0)} {
			regsub -all -nocase "[bit]$eggfu(trig,lrn,1) " $text "" text
		}

		set original {}
		set type [lsearch -exact [low $text] "is"]
		if {$type!="-1"} {set type "is"} {set type "are"}

		set whom [lsearch -exact $text "$type"]
		set getword [getword [lrange $text 0 [expr $whom -1]]]
		if {$getword!=""} {
			set breaker [lsearch -exact $getword "=>"]
			set keyword [lrange $getword 0 [expr $breaker - 1]]
			set original [lrange $getword [expr $breaker + 1] e]
		} else {
			set keyword [lrange $text 0 [expr $whom -1]]
		}

		set response [lrange $text [expr $whom + 1] e]

		if {![isinop [lindex $response 0]]} {
			set ll [lindex [split [lindex $response e] {}] e]
			while {$ll=="."} {
				set response [trim {[lrange $response 0 end-1] [join [lrange [split [lindex $response e] {}] 0 end-1] {}]}]
				set ll [lindex [split [lindex $response e] {}] e]
			}
		} {
			if {![matchattr $hand $eggfu(req,cn)]} {
				putnotc $nick "Sorry, you don't have access to do that."
				return 0
			}
		}

		set also [lindex $text [expr $whom + 1]]
# replace a few things
		regsub -all -nocase " my " $response " $nick's " response
		regsub -all -nocase " i am " $response " $nick is " response
		regsub -all -nocase "[botsnick] is " $response "I am " response
		regsub -all -nocase " [botsnick]'s " $response " my " response
		regsub -all -nocase "[botsnick], " $text "" text

		if {[string match *$start* $ignorewords]} {set text [lrange $text 1 e]}

		if {[string match -nocase no, $start] && ![isfrozen $keyword]} {delword $keyword}

		if {$original != "" && ![isfrozen $keyword]} {
			delword $keyword
			set response "$original | $response"
			set original {}
		}

		if {($original == "" && ![isfrozen $keyword]) && ([string length $keyword] >= 3 && [string length $keyword] <= 100)}  {
#   if {$start == "no,"} {putchan $chan "Ok $nick"}
			addword $keyword $response
		}
	}
}

proc askquestion {nick host hand chan text} {
	global botnick botsnick floodcount eggfu eggver

	set botsnick [low $botnick]
	set lownick [low $nick]
	set trigger [bit]$eggfu(trig,ask,1)
	set textlen [string length $text]
	set ignorecheck [lsearch -exact [low $eggfu(ignores)] [low $nick]]
	set chancheck [lsearch -exact [low $eggfu(chans)] [low $chan]]
	
	# check status of trigger
	if {($eggfu(trig,ask,0) && [lindex $text 0] == $trigger) || !$eggfu(trig,ask,0)} {
		set triggered 1
		regsub -all "$trigger " $text "" text
	} {set triggered 0}
	
	# perform passcheck, if anything fails we don't respond.
	if {$triggered && $ignorecheck == -1 && ($chancheck != -1 || $eggfu(chans) == "&all") && $textlen > 1} {
		regsub -all "\\\"" $text "'" text
		regsub -all "\\\!" $text "" text
		regsub -all "\\\?" $text "" text

		set ll [lindex [split [lindex $text e] {}] e]
		while {$ll=="."} {
			set text [trim {[lrange $text 0 end-1] [join [lrange [split [lindex $text e] {}] 0 end-1] {}]}]
			set ll [lindex [split [lindex $text e] {}] e]
		}

		set text [trim $text]

		set q(start) [lindex $text 0]
		set q(end) [lrange $text [expr [llength $text] - $eggfu(subrange)] e]
		set q(long) $text

#if {$getquestion == "me?"} {set q(end) $nick}
#regsub -all "me?" $q(end) "$nick" q(end)
		regsub -all "\007|\015|\022|\026|\028|\030" $q(start) "" q(start)

		set getword [getword $q(end)]
		set breaker [lsearch -exact $getword "=>"]
		set keyword [lrange $getword 0 [expr $breaker - 1]]
		if {[isfrozen $keyword]} {incr breaker}
		set q(ans) [lrange $getword [expr $breaker + 1] e]

		if {[isfrozen $q(ans)]} {set q(ans) [lrange $q(ans) 2 e]}
		if {$q(long)=="egg-fu"} {set q(ans) "<action> is running \002egg-fu $eggver\002, by ch3mical"} 
#if {$q(ans)=="" && $q(end)!=$q(long)} {set q(ans) $q(end)}

		# pass their nick and chan to the randomizer for in-opt functionality
		set q(ans) [randomize $q(ans) $nick $chan]
		regsub -all "\\\$question" $q(ans) "$text" q(ans)
		regsub -all "\\\$keyword" $q(ans) "$q(long)" q(ans)
		regsub -all "\\{" $keyword "" keyword
		regsub -all "\\}" $keyword "" keyword
		regsub -all "\\{" $q(ans) "" q(ans)
		regsub -all "\\}" $q(ans) "" q(ans)

		set sendto $chan
		if {$q(start) == "tell"} {
			set whom [lsearch -exact $text "tell"] 
			set target [lindex $text [expr $whom + 1]]
			if {$target!=""} { 
				set sendto $target
				regsub -all "\\\$who" $q(ans) $target q(ans)
		   }
		} {regsub -all "\\\$who" $q(ans) $nick q(ans)}

		if {$q(ans)!="" && $q(ans)!="~"} {
			set getstart [lindex $q(ans) 0] 
			set getrest [lrange $q(ans) 1 e]

			if {$getstart == "<reply>"} {
				putserv "PRIVMSG $sendto :$getrest"
				if {$sendto!=$nick && $sendto!=$chan} {putnotc $nick "Told $sendto \"$getrest\""}
		    } elseif {$getstart == "<ctcp>"} {putserv "PRIVMSG $nick :\001$getrest\001"
			} elseif {$getstart == "<notice>"} {putnotc $sendto "$getrest" 
			} elseif {$getstart == "<action>"} {putserv "PRIVMSG $sendto :\001ACTION $getrest\001"
			} {
				regsub -all "!Q" [grabrand responses] $keyword randmy
				regsub -all "!A" $randmy $q(ans) randmy
				regsub -all "!U" $randmy $nick randmy
				putserv "PRIVMSG $sendto :$randmy"
			}
		} elseif {[string match -nocase [botsnick]* $q(start)] && $q(end) != ""} {
			if {[lindex $q(end) 0]==$q(start)} {set q(end) [lrange $q(end) 1 e]}
			regsub -all "\\?" $q(end) "" q(end)
			regsub -all "!Q" [grabrand unsure] $q(end) randmn
			regsub -all "!A" $randmn $q(ans) randmn
			regsub -all "!U" $randmn $nick randmn
			putserv "PRIVMSG $sendto :$randmn"
		}
	}
	return 0
}

### start-up code
loadcfg $eggfu(path,cfg)
loadrand

bind pubm $eggfu(req,ak) * askquestion
bind pubm $eggfu(req,ln) "* is *" learnit
bind pubm $eggfu(req,ln) "* isn't *" learnit
#bind pubm $eggfu(req,ln) "* it's *" learnit
#bind pubm $eggfu(req,ln) "* are *" learnit

bind pubm - "* =~ *" alterit
bind pubm - "*--" karma_action
bind pubm - "*++" karma_action

bind pub o|o thaw thawit
bind pub m|m lock lockit
bind pub o|o freeze freezeit
bind pub m|m unlock unlockit
bind pub o|o forget forgetit
bind pub -|- karma karma_info

bind dcc o|o freeze dcc_freezeit
bind dcc o|o thaw dcc_thawit
bind dcc m|m lock dcc_lockit
bind dcc m|m unlock dcc_unlockit
bind dcc o|o forget dcc_forgetit
bind dcc -|- karma dcc_karma

set eggver "2.0.10"
set floodcount 0

# set this variable to a relative or absolute path if you plan on storing your birth certificate somewhere
# other than the default location, advanced users only
if {![file exists $eggfu(path,bc)]} {
#if the brain can't be found, we'll create a minimal one
	if {![file exists $eggfu(brain)]} {
		putlog "Hatching your new egg..."
		set wf [open $eggfu(brain) w]
		puts $wf "born => <reply> \$birthday"
		puts $wf "birthday => <reply> \$birthday"
		puts $wf "how old are you => <reply> I'm \$age old | <action> is \$age old"
		puts $wf "boy or girl => <reply> I'm a \$sex! | <action> is a \$sex"
		puts $wf "asl => <reply> \$age/\$sex/earth!"
		puts $wf "how => ~"
		puts $wf "who => ~"
		puts $wf "why => ~"
		puts $wf "what => ~"
		puts $wf "when => ~"
		puts $wf "where => ~"
		puts $wf "wtf => ~"
		close $wf
	}
# flip a coin for the sex
	set coin [rand 10]
	if {$coin>=5} {set sex boy} {set sex girl}
	putlog "\002IT'S A [string toupper $sex]!!\002"
	putlog "\002Congratulations!\002 You are now the proud owner of an \002egg-fu\002 bot!"
	set bdate [split [concat [exec date +%m/%d/%Y@%H:%M]] @]
	putlog "I was born on \002$bdate\002"
	set bc [open $eggfu(path,bc) w]
	puts $bc $bdate
	puts $bc $sex
	close $bc
}
set bc [open $eggfu(path,bc) r]
set sex [gets $bc];set sex [gets $bc];close $bc
putlog "\002egg\002-\002fu\002 \002$eggver\002 loaded! (age: [myage], sex: $sex)"
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Think you'd understand by now, that as soon as we patch one hole, we discover another one, and another, and another...

There are issues with strings<->lists all over the place, aswell as all other kinds of issues.

So, simply put, there's alot more than 1 single error..
The author is apparently not maintaining the script anymore, you've been recommended a replacement, I'm dropping this thread as of now...
NML_375
c
ch3mi0n
Voice
Posts: 1
Joined: Wed Nov 21, 2007 6:19 am

Post by ch3mi0n »

egg-fu is not unsupported, and I (the programmer of egg-fu) am not unreachable.

If you are having problems with egg-fu, use the help methods provided on the egg-fu project page found on sourceforge.net

egg-fu works perfectly fine as described in the help file included with the software, provided you follow the instructions and also are not trying to run it on WINDROP as warned against many times (also in the help file included with the software).

Now, if anyone has any support questions for me, refer to the above as I probably won't respond to you here.

Oh yeah, and... RTFM.
Post Reply