egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

!map

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Kuukkeli
Voice


Joined: 23 Apr 2006
Posts: 4

PostPosted: Fri Sep 01, 2006 11:01 am    Post subject: !map Reply with quote

Hi, this script finds map @ kartta.dat file.
Code:
bind pub - !kartta pub_kartta

proc pub_kartta { nick uhost hand chan args } {
global kartta_db
set kartta_db "data/kartta.dat"
   set args [split [lindex $args 0] " "]
    if {$args == ""} { puthelp "PRIVMSG $chan :$nick !kartta <hakusana> ohjeet: hakusanan tulee olla kolme merkkiä pitkä tai pitempi, eikä siinä saa käyttää$
return
}
    if {$args == "kz"} { puthelp "PRIVMSG $chan :$nick !kartta <hakusana> ohjeet: hakusanan tulee olla kolme merkkiä pitkä tai pitempi, eikä siinä saa käytt$
return
}
    set explain [string tolower [lindex $args 0]]
 set chan [string tolower $chan]
 set init_t [clock clicks -milliseconds]
 set fp [open $kartta_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 0 end] " "]
   if { [string match -nocase "*${args}*" $thisEntry] } {
    if { [lsearch $allEntrys [lindex curEntry 1]]==-1 } {lappend allEntrys [lrange $thisEntry 0 end]
 set allEntrys [lsort -unique $allEntrys]
}
 } } }
set init_t [expr double(([clock clicks -milliseconds] - $init_t))/1000]
 if {$allEntrys==""} { puthelp "PRIVMSG $chan :Karttaa ei löytynyt."
 } else {
  if {[llength $allEntrys]>5} {puthelp "PRIVMSG $chan :Liian monta karttaa löytyi, kokeille muulla hakusanalla."
  } else {
set jee1 "[lrange $allEntrys 0 1]"
puthelp "PRIVMSG $chan :Löytyi [llength $allEntrys] kartta(a). $allEntrys"
  }

}

}

It works, but answer is [@Romuloota] Löytyi 1 kartta(a). {lol - http://asd.com/lol.asd}. How i delete these {}. Sry my bad english, i hope you understand.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Sep 01, 2006 12:08 pm    Post subject: Reply with quote

Simply, use lists and strings properly. Specially, when printing the contents of allEntrys, convert it to a string ({} are used to set the boundaries for each list-item).
Something like:
Code:
join $allEntrys ", "
should do the trick...

Also, don't use "args" as a parameter name when building procs, as this one is interpreted in a special fashion (allows dynamic number of arguments to be supplied to a process, each argument will be a list-item in "args"). Pub-binds will call the associated function with a fixed number of arguments, so there's no need for it here.. And frankly, your mangling of args in the code really does'nt make much sense either.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Kuukkeli
Voice


Joined: 23 Apr 2006
Posts: 4

PostPosted: Fri Sep 01, 2006 12:45 pm    Post subject: Reply with quote

Now it say Tcl error [pub_kartta]: invalid command name "lol - http://asd.com/lol.asd". :S
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Sep 01, 2006 12:48 pm    Post subject: Reply with quote

Then you've most likely got a pair of [] to many
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber