| View previous topic :: View next topic |
| Author |
Message |
Reynaldo Halfop
Joined: 11 May 2005 Posts: 54
|
Posted: Sat Aug 27, 2005 10:46 pm Post subject: how to set $nick into variables |
|
|
| Code: | set hellobib {
{hi too =)}
{yups what's up}
{hmm..}
{yoi..}
{hi..}
{hi there}
{alo!}
{oi}
{aw aw}
{hoayem}
{welcome $nick}
}
bind pubm - "*" pub_haii
proc pub_haii {nick uhost hand chan args} {
global hellobib botnick
if {[regexp -nocase "hai" $args] || [regexp -nocase "hello" $args] > 0} {
set helloline [lindex $hellobib [rand [llength $hellobib]]]
putserv "PRIVMSG $chan :$helloline"
} |
how to take the $nick into $hellobib, when somebody spoken in channel.
the bot always saying: welcome $nick, not welcome "somebody nick"
 |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sun Aug 28, 2005 12:12 am Post subject: |
|
|
| Code: |
set hellobib {
{hi too =)}
{yups what's up}
{hmm..}
{yoi..}
{hi..}
{hi there}
{alo!}
{oi}
{aw aw}
{hoayem}
{welcome }
}
bind pubm - "*" pub_haii
proc pub_haii {nick uhost hand chan args} {
global hellobib botnick
if {[regexp -nocase "hai" $args] || [regexp -nocase "hello" $args]} {
set helloline [lindex $hellobib [rand [llength $hellobib]]]
if {$helloline == "welcome "} {append helloline $nick}
putserv "PRIVMSG $chan :$helloline"
}
|
|
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Sun Aug 28, 2005 7:33 pm Post subject: |
|
|
I beleave he was looking for:
putserv "PRIVMSG $chan :[subst -nobackslashes -nocommands $helloline]"
that would enable him to use phrases like
"welcome $nick in our channel $chan. enjoy your stay!"
without modify the whole script but just the list. _________________ 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 |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Aug 29, 2005 3:13 pm Post subject: |
|
|
*Off topic*
Subst works with -nob (instead of -nobackslashes) and -noc (instead of -nocommands) duno exactly from what version.
-nobackslashes or -nob means you won't be able to use any '\' won't be replaced, that means no bold, underline, italic, etc.
-nocommands or -noc means you won't be able to use commands, example: length of $nick is [llength $nick]
And about that regexp, if {[regexp -nocase {(hai|hello)} $args]} { # your stuff } should do better than two regexp if you want to use one, if I where you I'd go with a 'string match -nocase'  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Mon Aug 29, 2005 3:33 pm Post subject: |
|
|
dont know about the option shortcuts, maybe you can always shorten them to a unique expression. at least these are not mentioned in the command documentaion, so I rather beleave its something global. | Quote: | tcl: evaluate (.tcl): string equal -n a A
Tcl: 1
tcl: evaluate (.tcl): string mat -n *a* Age
Tcl: 1 |
if you actually concern about perfomance you really should cache the regexp by using it like:
| Code: | set hellore {(?i)(hai|hello)}
...
global hellobib hellore botnick
if {[regexp $hellore $args]} {
... |
_________________ 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 |
|
 |
Reynaldo Halfop
Joined: 11 May 2005 Posts: 54
|
Posted: Mon Aug 29, 2005 10:50 pm Post subject: |
|
|
| Code: | | if {$helloline == "welcome "} {append helloline $nick to $chan :)} |
output:welcome nickto#chan:)
 |
|
| Back to top |
|
 |
|