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 

Pub string match - simple command, silly problem.

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


Joined: 13 Apr 2009
Posts: 15

PostPosted: Thu Apr 30, 2009 9:20 am    Post subject: Pub string match - simple command, silly problem. Reply with quote

Hello,

Can anybody help me fix it ?

I don't know what is wrong with this...

I mean that good function "!xxx ccc" show 2 responses:

Code:
15:14:45 <A>  good
15:14:46 <A>  bad


The: "!xxx ccc", as only to show: "good".

Code:

bind pub -|- !xxx pub_do_ccc

proc pub_do_ccc {nick host handle channel text} {


if {[string match -nocase "ccc" [string trim $text]]} {
   putserv "PRIVMSG $channel : good"
}elseif {[string match -nocase "ccc1" [string trim $text]]} {
   putserv "PRIVMSG $channel : good1"
}elseif {[string match -nocase "ccc2" [string trim $text]]} {
   putserv "PRIVMSG $channel : good2"
}
   putserv "PRIVMSG $channel : bad"

}
Back to top
View user's profile Send private message
tsukeh
Voice


Joined: 20 Jan 2005
Posts: 31

PostPosted: Thu Apr 30, 2009 9:48 am    Post subject: Reply with quote

Code:

bind pub -|- !xxx pub_do_ccc

proc pub_do_ccc {nick host handle channel text} {
 set text [string trim $text]
 if {[string match -nocase "ccc" $text]} {
   putserv "PRIVMSG $channel : good"
 } elseif {[string match -nocase "ccc1" $text]} {
   putserv "PRIVMSG $channel : good1"
 } elseif {[string match -nocase "ccc2" $text]} {
   putserv "PRIVMSG $channel : good2"
 } else {
   putserv "PRIVMSG $channel : bad"
 }
}
Back to top
View user's profile Send private message
cleaner
Voice


Joined: 13 Apr 2009
Posts: 15

PostPosted: Thu Apr 30, 2009 10:05 am    Post subject: Reply with quote

Thanks Smile
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Thu Apr 30, 2009 5:36 pm    Post subject: Reply with quote

Code:
bind pub -|- !xxx pub_do_ccc

proc pub_do_ccc {nick host handle channel text} {
  switch -- [string tolower [string trim $text]] {
    "ccc" { putserv "PRIVMSG $channel :good" }
    "ccc1" { putserv "PRIVMSG $channel :good1" }
    "ccc2" { putserv "PRIVMSG $channel :good2" }
    default { putserv "PRIVMSG $channel :bad" }
  }
}

There are many ways to accomplish this, but the faster method is usually preferred. The command "switch" is probably faster than nesting if's and else's in this case.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
cleaner
Voice


Joined: 13 Apr 2009
Posts: 15

PostPosted: Fri May 01, 2009 11:15 am    Post subject: Reply with quote

Thanks, I think that I most rewrite some scripts hehe Smile.
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