| View previous topic :: View next topic |
| Author |
Message |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Tue Jun 06, 2006 1:42 pm Post subject: adding numeric values. |
|
|
Question 1:
| Code: | proc relay:text {nick uhost handle chan text} {
global relay
if {[isop $nick $chan] == "1"} {
if {[string range "$nick" 0 0] != "^"} {return 0}
# if {[string match "*m*" [getchanmode $chan]] == "0"} { return 0 }
foreach badpub $relay(badpubs) { if {[string match "$badpub" [string tolower $text]] == "1"} { return 0 } }
regsub -all {FOUR} $text "10,09FOUR" text
regsub -all {SIX} $text "11,12SIX" text
regsub -all {OUT} $text "04,01OUT" text
if {[string range "$nick" 0 0] == "^"} { set nick "[string range "$nick" 1 end]" }
if {[llength [split $nick "_"]] == "2" && [lindex [split $nick "_"] 0] != "" && [lindex [split $nick "_"] 1] != ""} { set nick "[lindex [split $nick "_"] 0] VS [lindex [split $nick "_"] 1]" }
relay:send "PRIVMSG $relay(channel_out) :$nick: $text"
} |
| Quote: | regsub -all {FOUR} $text "10,09FOUR" text
regsub -all {SIX} $text "11,12SIX" text
regsub -all {OUT} $text "04,01OUT" text |
When the bot recieves the word FOUR SIX AND OUT, it changes the color pattern of it and shows in the channel. The way "FOUR, SIX & OUT" are added, I want something like:
| Quote: | regsub -all {0} $text "NO RUN" text
regsub -all {1} $text "ONE RUN" text
regsub -all {2} $text "TWO RUNS" text |
I tried that but giving me error.. What could be the best way adding numeric values?
Question 2:
If you get a Nickname like :
NICK_NICK_ and I want to make it NICK VS NICK: how will you do that? can you help me out ?
Somethign like this:?
| Code: | | if {[llength [split $nick "_"]] == "2" && [lindex [split $nick "_"] 0] != "" && [lindex [split $nick "_"] 1] != ""} { set nick "[lindex [split $nick "_"] 0] VS [lindex [split $nick "_"] 1]" } |
Thanks. |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Tue Jun 06, 2006 6:50 pm Post subject: |
|
|
advice: don't use regsub on simple string replaces without regular expressions. String map does fine in both cases. Though I am not sure why there should be an error, because of that line. Get the complete errorInfo (refer Help us to help you).
About the NICK_NICK_ thing... I advice you to actually try what such statements do: | Code: | % set list [split NICK_NICK_ _]
NICK NICK {}
% llength $list
3 |
_________________ 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 |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Wed Jun 07, 2006 5:20 am Post subject: |
|
|
| Did'nt understand I am sorry ;/ |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Wed Jun 07, 2006 6:34 am Post subject: |
|
|
With a "didnt understand" I am unable to help you. You must be more specific about the part you did not understand. If you did not understand at all, I suggest visiting some English lessons... though you wouldn't be able to understand then that suggestion, either .
I make a wild guess and give the link to the string map manual. _________________ 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 |
|
 |
|