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.

namespace

Help for those learning Tcl or writing their own scripts.
Post Reply
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

namespace

Post by ap »

Hi i am using namespace but i'm missing something. I am trying to call auto:voice procedure from the main procedure "voice" but it doesn't work

Code: Select all

namespace eval test {
 
 bind join - * [namespace current]::voice
 proc voice {nick host hand chan} { 
   if {![isbotnick $nick] && [string equal -nocase "#test" $chan]} { 
      utimer 15 [list auto:voice $nick $host $hand $chan] 
   } 
 } 
 proc auto:voice {nick host hand chan} { 
    if {![botisop $chan] || [matchattr $hand b]} {return}
    if {![isop $nick $chan] && ![isvoice $nick $chan]} { 
         pushmode $chan +v $nick 
    } 
  } 
}
i get timer error plus invalid command name "auto:voice"

thanks
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

The auto:voice proc is within the proc.

change:

Code: Select all

utimer 15 [list auto:voice $nick $host $hand $chan]
]
to

Code: Select all

utimer 15 [list [namespace current]::auto:voice $nick $host $hand $chan]
That should fix your problem...
r0t3n @ #r0t3n @ Quakenet
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

Post by ap »

thank you, Tosser^^

one more question please. i have noticed sometime when bot returns from netsplit etc. then utimer doesn't start unless i try .restart

any advise please?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Tcl-commands.doc:
REJN (stackable)
bind rejn <flags> <mask> <proc>
procname <nick> <user@host> <handle> <channel>

Description: someone who was split has rejoined. mask can contain
wildcards, and is matched against '#channel nick!user@host'.
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

Post by ap »

thank you, Sir_Fz. But i'm confused about REJN bind, how this will fit with the following codes? i mean then when JOIN bind will start working? i'll appreciate for help, thanks

may be bind rejn - * [namespace current]::voice need to add to the following codes?

Code: Select all

namespace eval test {
 
 bind join - * [namespace current]::voice
 proc voice {nick host hand chan} {
   if {![isbotnick $nick] && [string equal -nocase "#test" $chan]} {
      utimer 15 [list [namespace current]::auto:voice $nick $host $hand $chan]
   }
 }
 proc auto:voice {nick host hand chan} {
    if {![botisop $chan] || [matchattr $hand b]} {return}
    if {![isop $nick $chan] && ![isvoice $nick $chan]} {
         pushmode $chan +v $nick
    }
  }
} 
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

REJN is triggered when someone rejoins from a netsplit, so yeah adding that bind should solve your problem.
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

The rejn bind will work with the current voice proc.

Add this line:

Code: Select all

bind rejn - {*} [namespace current]::voice
under this line:

Code: Select all

bind join - * [namespace current]::voice 
r0t3n @ #r0t3n @ Quakenet
a
ap
Halfop
Posts: 44
Joined: Fri Jun 09, 2006 12:20 am

Post by ap »

Thank you so much Tosser^^ and Sir_Fz
Post Reply