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.

!learn Scripts

Support & discussion of released scripts, and announcements of new releases.
A
AudiAddict
Voice
Posts: 11
Joined: Tue Aug 28, 2007 8:55 am

!learn Scripts

Post by AudiAddict »

Can anybody tell me what I'm doing wrong?

I've tried using several !learn scripts with the latest eggdrop source, but I cannot get any of them to work.

I've tried dictionary.tcl, hal-learn.tcl, fluxlearn5

Basicly, I can hal-learn to work as far as the bot says : ?? word not defined.

But when trying to use !learn add test test --> nothing happends. No error in the eggdrop telnet (live view).

The actual file learn.dat is there, I even tried giving it 755 acces rights.

Anybody willing to help? Or provide me with a working tcl file that works with the latest eggdrop source?
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Reading the instructions that come with any script does come in handy.

For instance, !learn TCL:

Code: Select all

# PLEASE CHANGE THE LINE BELOW. If you don't, the file and the directory will be
# created
set learn_db "data/learn.dat"
It is possible you will be required to create this 'data' directory instead of relying on the script to do it.

As for a dictionary script, Rosc2112 has written an updated one and it can be found on the Tcl Archive (along with many new and updated scripts).

To find out exactly why a script doesn't work simply do the following:

Edit your .conf file and change:

Code: Select all

unbind dcc n set *dcc:set
to

Code: Select all

#unbind dcc n set *dcc:set
Restart your bot.

In the party line type this:

Code: Select all

.set errorInfo
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
A
AudiAddict
Voice
Posts: 11
Joined: Tue Aug 28, 2007 8:55 am

Post by AudiAddict »

Alchera wrote:Reading the instructions that come with any script does come in handy.

For instance, !learn TCL:

Code: Select all

# PLEASE CHANGE THE LINE BELOW. If you don't, the file and the directory will be
# created
set learn_db "data/learn.dat"
It is possible you will be required to create this 'data' directory instead of relying on the script to do it.

As for a dictionary script, Rosc2112 has written an updated one and it can be found on the Tcl Archive (along with many new and updated scripts).

To find out exactly why a script doesn't work simply do the following:

Edit your .conf file and change:

Code: Select all

unbind dcc n set *dcc:set
to

Code: Select all

#unbind dcc n set *dcc:set
Restart your bot.

In the party line type this:

Code: Select all

.set errorInfo
Thanks for the feedback.

I've tried creating the learn/database files manualy, dirs aswel. I don't think the file is the issue, it's just not writing the data into it.

As explained in the first post aswel, I checked the chmod rights etc. Even set it to have everyone write into it.

.set errorInfo gives me What? You need ".help"
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

AudiAddict wrote:...
.set errorInfo gives me What? You need ".help"
Could you check the "must-be-owner" and "owner" settings within your configfile?
eggdrop.conf wrote:# Un-comment the next line and set the list of owners of the bot.
# You NEED to change this setting.
#set owner "MrLame, MrsLame"
...
# If you enable this setting, only permanent owners (owner setting) will be able to use .tcl and .set. Moreover, if you want only let permanent owners use .dump, then
# set this to 2.
set must-be-owner 1
NML_375
A
AudiAddict
Voice
Posts: 11
Joined: Tue Aug 28, 2007 8:55 am

Post by AudiAddict »

Sorry for the late reply, have been really busy.

I checked the owner settings. They are correct.

So in short :

I'm currently using tklearn-0.5.tcl from your archives. It appeares to be a recent version from 2007.

I uploaded the file to my eggdrop/scripts folder.

I added the loader in my eggdrop.conf

Restarted eggdrop, the script get's loaded.

The eggdrop bot responds to lookups with --? word

When trying !add ! add !add word info ! add word info the eggdrop simply does not do anything.

When checking my eggdrop dir, it does make a folder called learn.db (as stated in the config file).

The file is made by eggdrop, so it seems eggdrop has the correct "write" permission.

To be safe I've tried to give the folder a chmod of -R 777. That didn't make any difference.

For some reason it's not writing data to the folder. All other learn scripts have the same problem it seems. They respond to ? commands but not when writing data.

Anybody know what I'm doing wrong? I did check the owner settings, they are set to my Name.

I'm using telnet and it doesn't display any errors while logged in.

Hopefully somebody has some feedback or a version which works for them on the latest eggdrop + unreal version.
s
smash
Halfop
Posts: 45
Joined: Mon Jul 31, 2006 12:33 pm

Post by smash »

I have been useing the script for some time now, and works ok for me.

!learn add egg http://egghelp.org

FB|News Defenition added

FragUK + egg

FB|News egg http://egghelp.org

eggdrop v1.6.18

Tcl version: 8.4.13
quakenet #fraguk www.fraguk.com
hosting 113 scripts @ this time!
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Put some debugging lines into the script where it's supposed to be writing to the file, something like:

putcmdlog "Writing data to file $variable-used-to-write-data"

where $variable is the name of the var in the script (since I don't have the script this is just an example)

If you want, post the proc used for writing to the script, so we can help you more.
s
smash
Halfop
Posts: 45
Joined: Mon Jul 31, 2006 12:33 pm

Post by smash »

Code: Select all

# Simple !learn TCL that supports several defenition lines
# Created by Hal9000 @ irc.PTnet.org
#
# !learn add word defenition
# !learn del word <number|all>
# and also !learn <ins|put|rep> <number> <defenition>
#
# You can see a defenition using + <word>
# You can search inside the whole file (including defenitions) using ** word
# Large defenitions (more than six lines) will be sent into the user so the
# chan wont be flooded. You can force sending to channel the same way you can
# force sending to nicks.
# ?? defenition > nick
#
# What does this script has different from other so common ?? scripts?
# The characters are treated properly. Chars like ';' or '[' are properly handled
# and there have been no problems untill now.
# Also we have a multi line support... and a "repeat explain" protection.
#
# Inspired on fluxlearn TCL.
#
# Some additional features, sugestions and bufixes from
#   Status@brasnet.org aka Juvenal@PTnet.org
#
# If you find any bug, pleas bug me at hal9000@gupe.net

# PLEASE CHANGE THE LINE BELOW. If you don't, the file and the directory will be
# created
set learn_db "data/learn.dat"


### - ### No need to edit below this line... ### - ###
# or at least i hope so ;)

putlog "!learn TCL by Hal9000 @ irc.ptnet.org loaded."

bind pub m !learn learn_learn
bind pub - "+" learn_explain
bind pub - "$" learn_search

set learn_whodid ""

proc learn_learn { nick uhost hand chan args } {
 set args [lindex $args 0]
 set args [split $args " "]
 switch [lindex $args 0] {
  "add" {
   if {[lindex $args 2] == ""} {
    puthelp "NOTICE $nick :Try !learn add word defenition!" 
   } else {
      learn_addEntry $nick [lindex $args 1] [lrange $args 2 end]
      puthelp "NOTICE $nick :Defenition added"
      learn_flood "[lindex $args 1]" $chan
     }
  }
  "del" {
   if {[lindex $args 2]!=""} {
    learn_delEntry [lindex $args 1] [lindex $args 2]
    puthelp "NOTICE $nick :Defenition removed"
    learn_flood "[lindex $args 1]" $chan
   } else {
      learn_delEntry [lindex $args 1]
      puthelp "NOTICE $nick :Defenition removed"
     }
  }
  "ins" {
   if {[lindex $args 3]!=""} {
    learn_insEntry [lindex $args 1] [lindex $args 2] [lrange $args 3 end]
    puthelp "NOTICE $nick :Defenition inserted"
    learn_flood "[lindex $args 1]" $chan
   } else {puthelp "NOTICE $nick :Syntax: !learn ins word num text" }
  }
  "put" {
   if {[lindex $args 3]!=""} {
    learn_putEntry [lindex $args 1] [lindex $args 2] [lrange $args 3 end] $nick
    puthelp "NOTICE $nick :Defenition inserted"
    learn_flood "[lindex $args 1]" $chan
   } else {puthelp "NOTICE $nick :Syntax: !learn put word num text" }
  }
  "rep" {
   if {[lindex $args 3]!=""} {
    learn_repEntry [lindex $args 1] [lindex $args 2] [lrange $args 3 end]
    puthelp "NOTICE $nick :Defenition replaced"
    learn_flood "[lindex $args 1]" $chan
   } else {puthelp "NOTICE $nick :Syntax: !learn rep word num text" }
  }  
  default { puthelp "NOTICE $nick :Syntax: \002!learn <add|del|info|ins|rep>" }
 }
}

proc learn_explain { nick uhost hand chan args } {
	global learn_db learn_whodid;if {![info exists learn_whodid]} {set learn_whodid ""}
	set real_chan $chan
	set args [split [lindex $args 0] " "]
	if {$args == ""} { puthelp "PRIVMSG $chan :\002+\[\002x\002]: Usage: ?? <word> \[> nick]" ; return }
	set explain [string tolower [lindex $args 0]]; set chan [string tolower $chan]
	if {([lindex $args 1] == ">" || [lindex $args 1] == ">>") && [lindex $args 2] != ""} { set chan [lindex $args 2] 
#         if {[lsearch -exact $learn_whodid [list $explain [string tolower $chan]]] != -1} {
#                puthelp "PRIVMSG $real_chan :\002Hey ${nick}, i've already told $chan about \"$explain\"... no need to repeat (i think)"
#                return 0
#         }
	}
	set fp [open $learn_db r];set allEntrys ""
	while {![eof $fp]} {gets $fp curEntry;set curEntry [split $curEntry " "];if {[string equal -nocase [lindex $curEntry 1] $explain]} {lappend allEntrys [join $curEntry " "]}}
	close $fp
	set count 0
	if {[llength $allEntrys]==1} {
	 if {[lsearch -exact $learn_whodid [list $explain [string tolower $chan]]] != -1} {
		puthelp "PRIVMSG $real_chan :\002Hey ${nick}, i've already told $chan about \"$explain\"... no need to repeat (i think)"
		return 0
	 } else { puthelp "PRIVMSG $chan :\002\037${explain}\037: \002[join [lrange [split [lindex $allEntrys 0] " "] 2 end]]";incr count }
	} else {
	 if {[llength $allEntrys]>6&&[string index $chan 0]=="#"&&!(([lindex $args 1] == ">" || [lindex $args 1] == ">>") && [lindex $args 2] != "")} {set chan $nick; 
          puthelp "PRIVMSG $real_chan :\002\037${explain}?\002\037 What a huge defenition... i'll tell you in private instead..."
	 }
         if {[lsearch -exact $learn_whodid [list $explain [string tolower $chan]]] != -1} {
                puthelp "PRIVMSG $real_chan :\002Hey ${nick}, i've already told you about \"$explain\"... no need to repeat (i think)"
                return 0
	 }
	 foreach curEntry $allEntrys {
		incr count
		puthelp "PRIVMSG $chan :\002\037${explain}\[\037\002${count}\002\037]:\037 \002[join [lrange [split $curEntry " "] 2 end]]"
	} }
	if {$count == 0} { puthelp "PRIVMSG $chan :\002${explain}\[\002x\002\]: \002No defenition found for word." }
	if {([lindex $args 1] == ">" || [lindex $args 1] == ">>") && [lindex $args 2] != ""} {
		puthelp "NOTICE $nick :Ok, done."
	}
	lappend learn_whodid [list $explain [string tolower $chan]]
	set explain [learn_filterstr $explain]	;# Don't allow code to be executed
	set chan [learn_filterstr $chan]	;# ensure []s are properly handled...
	utimer 60 "learn_flood \"$explain\" \"$chan\""
}

proc learn_flood {word target} {
	# removes from "already told so" list
	global learn_whodid
	set word [string tolower $word]; set target [string tolower $target]
	set lin [lsearch -exact $learn_whodid [list $word $target]] 
	if {$lin == -1} {
		return
	} else {
		set learn_whodid [lreplace $learn_whodid $lin $lin]
	}
}

proc learn_addEntry { nick word defenition } {
 global learn_db;set word [string tolower $word]
 if {![file exists $learn_db]} {file mkdir [lindex [split $learn_db /] 0];set fp [open $learn_db w+]
  puts $fp "Hal9000 + Just do a \002+ \037word\037\002 or \002+ \037word\037 > \037nick\037\002"
  puts $fp "Hal9000 !learn hal-learn script | mantained by the #Eggdrop team at irc.PTnet.org"
 } else {set fp [open $learn_db a]};puts $fp "$nick $word [join $defenition]";close $fp
}

proc learn_delEntry { word {remnum "all"}} {
 global learn_db
 set word [string tolower $word]
 set fp [open $learn_db r]
 set allEntrys ""
 set count 1
 if {$remnum == "all"} {
  while {![eof $fp]} {gets $fp curEntry;if {![string equal -nocase [lindex [split $curEntry] 1] $word]} {lappend allEntrys $curEntry}}
 } else {
  while {![eof $fp]} {
   gets $fp curEntry
   if {![string equal -nocase [lindex [split $curEntry] 1] $word] || ($count != $remnum && $remnum != -2)} {
    if {[info exists curEntry]&&$curEntry!=""} {lappend allEntrys $curEntry}
    if {[string equal -nocase [lindex [split $curEntry] 1] $word]} {incr count}
   } else {incr count}
  }
 }
 close $fp;set fp [open $learn_db w];foreach curEntry $allEntrys {puts $fp $curEntry};close $fp
}

proc learn_insEntry {word num text} {
 global learn_db
 set word [string tolower $word]
 set fp [open $learn_db r]
 set allEntrys ""
 set count 1
 while {![eof $fp]} {
  gets $fp curEntry
  if {![string equal -nocase [lindex [split $curEntry] 1] $word] || ($count != $num && $num != -2)} {
   if {[info exists curEntry]&&$curEntry!=""} {lappend allEntrys $curEntry}
   if {[string equal -nocase [lindex [split $curEntry] 1] $word]} {incr count}
  } else {incr count;lappend allEntrys "$curEntry [join $text]"}
 }
 close $fp;set fp [open $learn_db w];foreach curEntry $allEntrys {puts $fp $curEntry};close $fp
}

proc learn_putEntry {word num text {whodid "."}} {
 global learn_db
 set word [string tolower $word]
 set fp [open $learn_db r]
 set allEntrys ""
 set count 1
 if {$num==1} {lappend allEntrys "$whodid $word [join $text]"}
 while {![eof $fp]} {
  gets $fp curEntry
  if {[string equal -nocase [lindex [split $curEntry] 1] $word]} {incr count}
  if {[info exists curEntry]&&$curEntry!=""} {lappend allEntrys $curEntry}
  if {$count==$num&&$num!=1} {lappend allEntrys "$whodid $word [join $text]"}
 }
 close $fp;set fp [open $learn_db w];foreach curEntry $allEntrys {puts $fp $curEntry};close $fp
}
  

proc learn_repEntry {word num text} {
 global learn_db
 set word [string tolower $word]
 set fp [open $learn_db r]
 set allEntrys ""
 set count 1
 while {![eof $fp]} {
  gets $fp curEntry
  if {![string equal -nocase [lindex [split $curEntry] 1] $word] || ($count != $num && $num != -2)} {
   if {[info exists curEntry]&&$curEntry!=""} {lappend allEntrys $curEntry}
   if {[string equal -nocase [lindex [split $curEntry] 1] $word]} {incr count}
  } else {incr count;lappend allEntrys "[lrange [split $curEntry] 0 1] [join $text]"}
 }
 close $fp;set fp [open $learn_db w];foreach curEntry $allEntrys {puts $fp $curEntry};close $fp
}

proc learn_sortFile {a c d e f} {
 global learn_db
 set t_count [clock clicks -milliseconds]
 set fp [open $learn_db r]
 set allEntrys ""
 while {![eof $fp]} {
  set curEntry [gets $fp]
  if {[info exists curEntry]&&$curEntry!=""} {lappend allEntrys [split $curEntry " "]}
 }
 close $fp; set allEntrys [lsort -index 1 $allEntrys]
 set fp [open $learn_db w];foreach curEntry $allEntrys {puts $fp [join $curEntry " "]};close $fp
 putlog " -> Done with sorting of data on the database ($learn_db)->[expr double([clock clicks -milliseconds]-$t_count)/1000]s"
}
bind time - "12 * * * *" learn_sortFile

proc learn_filterstr { data } {
 regsub -all -- \\\\ $data \\\\\\\\ data
 regsub -all -- \\\[ $data \\\\\[ data	
 regsub -all -- \\\] $data \\\\\] data
 regsub -all -- \\\} $data \\\\\} data
 regsub -all -- \\\{ $data \\\\\{ data
 regsub -all -- \\\" $data \\\\\" data
 return $data
}

proc learn_search { nick uhost hand chan args } {
 global learn_db
 set args [string tolower [lindex $args 0]]
 if {$args==""} {puthelp "PRIVMSG $chan :Not enough arguments.";return}
 set init_t [clock clicks -milliseconds]
 set fp [open $learn_db r];set matches "";set allEntrys ""
 while {![eof $fp]} {
  gets $fp curEntry;if {[info exists curEntry]&&$curEntry!=""} {
   set curEntry [split [string tolower $curEntry] " "]; set thisEntry [join [lrange $curEntry 1 end] " "]
   if {[string match -nocase "*${args}*" $thisEntry]} {
#    putserv "PRIVMSG #meta :worked $curEntry"
    if {[lsearch $allEntrys [lindex curEntry 1]]==-1} {lappend allEntrys [lindex $curEntry 1];set allEntrys [lsort -unique $allEntrys]}
 } } } ;set init_t [expr double(([clock clicks -milliseconds] - $init_t))/1000]
 if {$allEntrys==""} {puthelp "PRIVMSG $chan :Sorry, no matches for $args on the defenition database. (\002\037${init_t}\037s)"
 } else {
  if {[llength $allEntrys]>10} {puthelp "PRIVMSG $chan :\002Too much matches.\002 Please try a more complex search."
  } else {puthelp "PRIVMSG $chan :\002Found \037[llength $allEntrys]\037 matches.\002 Sorted: \037[join [lsort -dictionary $allEntrys] "\037, \037"]\037. (\002\037${init_t}\037s)"
  }
 }
}

quakenet #fraguk www.fraguk.com
hosting 113 scripts @ this time!
A
AudiAddict
Voice
Posts: 11
Joined: Tue Aug 28, 2007 8:55 am

Post by AudiAddict »

The script from Smash above does the same thing.

egg[x]: No defenition found for word.

It seems that it's not writing the data to it's file anywhere.

I've set the data file to /scripts/learn.dat , /etc/eggdrop/scripts/learn.dat all no go.

I did the following :

- Manualy created learn.dat --> set file dir --> no error with finding the file --> but still no defenition found problem (not writing data)

- Set file dir, but did not create learn.dat --> error, learn.dat not found when trying to !learn

- Chown/chmod 777 or as the current running eggdrop user --> no go

- Manualy create learn.dat and give it max acces (CHMOD 777) --> still no writing of data possible

- Made Eggdrop Op --> and reoped myself with the telnet eggdrop client --> no go

- Chmodded the whole eggdrop dir + sub dirs as 777 (crazy, I know) --> no go

- Chown whole dir + sub dirs as the current eggdrop running user --> no go.

I think it's a combination of linux rights (chmod) and setting the correct database file/dir.

I've tried everything, hopefully somebody can help me. Because I'm having the exact same problem with other learn scripts. The bot responds in the channel, but doesn't learn data!

Is it maybe a eggdrop setting which needs to be adjusted?

Code: Select all

 set errorInfo
This works, but doesn't give me any errors while trying to learn. Doesn't give me any errors at all actually.
Last edited by AudiAddict on Sun Oct 28, 2007 6:28 am, edited 1 time in total.
s
smash
Halfop
Posts: 45
Joined: Mon Jul 31, 2006 12:33 pm

Post by smash »

your missing out the folder data . in the parth .

should be
eggdrop/data/learn.dat

take a look in eggdrop for a folder named data, if there's not 1 there, make 1, then put a file named learn.dat in that folder, then restart the bot. :wink:
quakenet #fraguk www.fraguk.com
hosting 113 scripts @ this time!
A
AudiAddict
Voice
Posts: 11
Joined: Tue Aug 28, 2007 8:55 am

Post by AudiAddict »

smash wrote:your missing out the folder data . in the parth .

should be
eggdrop/data/learn.dat

take a look in eggdrop for a folder named data, if there's not 1 there, make 1, then put a file named learn.dat in that folder, then restart the bot. :wink:
Hey smash, I don't have a data folder, I figured I didn't need one since I changed the setting to /scripts/learn.dat and not /data/learn.dat.

Like I said the bot can find the learn.dat file, it's just not able to write data into it.

Maybe u could try sending your learn.dat file and I could see if that would work? email : jsbosch@xs4all.nl (first letter is a j )
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Keep in mind that /scripts/learn.dat and scripts/learn.dat points to two completely different locations on your filesystem.

This script in particular expects, and depends, on you providing a relative path with one single directory (data/learn.dat or scripts/learn.dat or similar).
NML_375
A
AudiAddict
Voice
Posts: 11
Joined: Tue Aug 28, 2007 8:55 am

Post by AudiAddict »

nml375 wrote:Keep in mind that /scripts/learn.dat and scripts/learn.dat points to two completely different locations on your filesystem.

This script in particular expects, and depends, on you providing a relative path with one single directory (data/learn.dat or scripts/learn.dat or similar).
If I understand you're answer correctly, I have not set my data file correctly?

Code: Select all

 set learn_db "/etc/eggdrop/data/learn.dat" 
is what I'm using, this seems to work since it's not giving me learn.dat file not found.

Selecting another folder/path gives me an error that the file cannot be found.

So it would seem that this is ok?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The reason it does'nt bark at you, is, as you stated in an earlier post, because you've already created that file by hand (hence the file exists).

There is still the issue wether your eggdrop is actually able to open it or not.
Last edited by nml375 on Sun Oct 28, 2007 10:10 am, edited 1 time in total.
NML_375
A
AudiAddict
Voice
Posts: 11
Joined: Tue Aug 28, 2007 8:55 am

Post by AudiAddict »

True, so why isn't it writing data to that file?
Post Reply