| View previous topic :: View next topic |
| Author |
Message |
Hamish Voice
Joined: 27 Mar 2006 Posts: 25
|
Posted: Thu Mar 30, 2006 3:27 am Post subject: >> Simple MIRC -> TCL Script Conversion << |
|
|
I need a script that will allow the user to type !price item
The script should get the item from this text file Pricelist and return the line that word is contained on.
Eg. user types !price Abyssal whip and the bot will search the text file and return line one of the text file "Abyssal whip: 2.9-3.2Mil" as a notice to the user... So it's like:
<@Hamish> !price Abyssal whip
-ClanBot- Abyssal whip: 2.9-3.2Mil
Also, if it helps at all, here is the MIRC version:
| Code: | on *:TEXT:!price*:#:{
.notice $nick *** [7 $upper($$2-) ]: $read(prices.txt, s, $$2- $+ :)
}
} |
_________________ Thanks, Hamish. |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Thu Mar 30, 2006 9:39 pm Post subject: |
|
|
something like that should do the trick:
| Code: | bind pub - !price prices
proc prices {nick uhost hand chan text} {
set hit 0
set fd [open prices.txt r]
while {![eof $fd]} {
if {[string match -nocase "$text: *" [set price [gets $fd]]]} {
set hit 1
break
}
}
close $fd
if {$hit} {
puthelp "NOTICE $nick :$price"
return 1
} else {
puthelp "NOTICE $nick :No match found"
return 0
}
} |
Read TCL manual for possible wildcard searchs. _________________ De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens... |
|
| Back to top |
|
 |
Hamish Voice
Joined: 27 Mar 2006 Posts: 25
|
Posted: Fri Mar 31, 2006 11:40 am Post subject: |
|
|
De Kus, it works perfectly, thanks alot man!  _________________ Thanks, Hamish. |
|
| Back to top |
|
 |
|