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 

how to set $nick into variables

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Sat Aug 27, 2005 10:46 pm    Post subject: how to set $nick into variables Reply with quote

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"
Sad
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sun Aug 28, 2005 12:12 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Sun Aug 28, 2005 7:33 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Aug 29, 2005 3:13 pm    Post subject: Reply with quote

*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' Razz
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Mon Aug 29, 2005 3:33 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Reynaldo
Halfop


Joined: 11 May 2005
Posts: 54

PostPosted: Mon Aug 29, 2005 10:50 pm    Post subject: Reply with quote

Code:
if {$helloline == "welcome "} {append helloline $nick to $chan :)}

output:welcome nickto#chan:)

Crying or Very sad
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive 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