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 

Help with script

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


Joined: 18 May 2014
Posts: 33

PostPosted: Mon Aug 17, 2020 8:39 am    Post subject: Help with script Reply with quote

Code:
bind pub - !money pub:money
 
proc pub:money {nick host hand chan arg} {
  global botnick
  set searchstring $arg
  set fname "money.txt"
  set fp [open $fname "r"]
  set data [read -nonewline $fp]
  close $fp
  set lines [split $data "\n"]
  set searchresult ""
  foreach line $lines {
     if {[string match * $nick* [join $line]]} {
        lappend searchresult $line
     }
     if {[$nick == "[lindex [split [join $searchresult] "|"] 0]"} {
        putserv "NOTICE $nick :Je bent al een keer hier geweest."
        return 0
     }
     putserv "NOTICE $nick :You have €[lindex [split [join $searchresult] "|"] 1]"} {
     return 0
  }
}


And i'm getting this error: [14:35:22] Tcl error [pub:money]: wrong # args: should be "foreach varList list ?varList list ...? command"
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Aug 17, 2020 9:19 am    Post subject: Reply with quote

In fact, you have a trouble with the following line:
Code:
putserv "NOTICE $nick :You have €[lindex [split [join $searchresult] "|"] 1]"} {


The right script might be:
Code:
bind pub - !money pub:money

proc pub:money {nick host hand chan arg} {
   global botnick
   set searchstring $arg
   set fname "money.txt"
   set fp [open $fname "r"]
   set data [read -nonewline $fp]
   close $fp
   set lines [split $data "\n"]
   set searchresult ""
   foreach line $lines {
      if {[string match * $nick* [join $line]]} {
         lappend searchresult $line
      }
      if {[$nick == "[lindex [split [join $searchresult] "|"] 0]"} {
         putserv "NOTICE $nick :Je bent al een keer hier geweest."
         return 0
      }
      putserv "NOTICE $nick :You have €[lindex [split [join $searchresult] '|'] 1]"
      return 0
   }
}

Think to indent your code and you'll see this kind of errors
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
l.kleijn
Voice


Joined: 18 May 2014
Posts: 33

PostPosted: Mon Aug 17, 2020 11:38 am    Post subject: Reply with quote

Now it's working thanks
Back to top
View user's profile Send private message
l.kleijn
Voice


Joined: 18 May 2014
Posts: 33

PostPosted: Mon Aug 17, 2020 11:39 am    Post subject: Reply with quote

Now i have something else

I have a file called money.txt and there is a line called Fujin|50 and i want to remove that line with a tcl script. How do i do this ?
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Mon Aug 17, 2020 3:24 pm    Post subject: Reply with quote

Maybe check this forum thread for some procs to work with text files...
http://forum.egghelp.org/viewtopic.php?t=19168
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
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