This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

how to set $nick into variables

Old posts that have not been replied to for several years.
Locked
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

how to set $nick into variables

Post by Reynaldo »

Code: Select all

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"
:(
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

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"
   
}
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

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...
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

*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' :P
Once the game is over, the king and the pawn go back in the same box.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

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.
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: Select all

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...
R
Reynaldo
Halfop
Posts: 54
Joined: Wed May 11, 2005 2:51 am

Post by Reynaldo »

Code: Select all

if {$helloline == "welcome "} {append helloline $nick to $chan :)}
output:welcome nickto#chan:)

:cry:
Locked