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 

proc under proc problems - dubble logs

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Thib
Voice


Joined: 11 Jan 2010
Posts: 9

PostPosted: Mon Jan 11, 2010 11:58 am    Post subject: proc under proc problems - dubble logs Reply with quote

Hellow,

I'm creating my own script, i have 2 questions.

When an user comes, he's noticed by the bot called Eva. When he "/notice botnick confirm", he's noticed by Eva, and kicked after 5 secs.

here is my code :

Code:

set salon "#channel"
bind notc - * notc:confirm
proc notc:confirm { nick uhost handle text {dest "Eva"} } {
        global salon
        if {$text == "confirm"} {
                putserv "NOTICE $nick :Vous avez maintenant confirmé"
                pushmode $salon +v $nick
                putlog "$nick - $uhost à confirmé"
                utimer 5 { proc_kick }
        }

        proc proc_kick {} {
                global salon
                putkick $salon $nick "test"
        }
}


first question, when i hit /notice botnick confirm, i can seen two times the confirmation in partyline :

Quote:

(16:44:24) (Eva) [16:43] aaa - a@hide-D4B501FE.unknown.uunet.be à confirmé
(16:44:25) (Eva) [16:43] aaa - a@hide-D4B501FE.unknown.uunet.be à confirmé
(16:44:25) (Eva) [16:43] -aaa (a@hide-D4B501FE.unknown.uunet.be)- confirm


Why ? Same problem for the timer, two timers are started .. ?
Why is all cloned ?

--

Second question, is concerning the proc_kick.
I want it to start after 5 secs, it works. But the user isnt kicked !
What do i have to insert here :
Quote:
proc proc_kick {} {
to catch the nick again ?

Thank you for your answers Smile

Thib
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jan 12, 2010 5:41 pm    Post subject: Reply with quote

First off,
I'd recommend that you don't create the proc_kick proc from within the notc:confirm proc. I take it you are accustomed with Java classes (especially events)? Unfortunately, tcl does not work that way - the proc_kick proc will be created at a global level, not within any notc:confirm proc/"object".

Secondly, this is partly due to the first part;
Variable scope. $nick is not available within proc_kick, as it is not defined as a variable within proc_kick's namespace. What you'll need to do, is add a parameter for your proc_kick:
Code:
proc proc_kick {nickname} {
  global salon
  putkick $salon $nickname "test"
}

Next, you'll have to provide the nickname as an argument when calling the proc. In a trivial case, you'd simply do proc_kick $nick, but since you use utimer things get alittle more complicated. To avoid double evaluations and possible exploits, you'll need to do it like this:
Code:
  utimer 5 [list proc_kick $nick]

Much simplified, we use the list command to build a proper command line that can be executed safely when the timer expires.

Third, as for the multiple triggers, most likely you've loaded the script twice, generating 2 bindings (using .rehash will not wipe the current tcl environment, and any already existing bindings will remain).

All in all, I'd write the script something like this:
Code:
#Fancy tweak to see if the binding has already been created, just in case of a .rehash
if {[lsearch -glob -- [binds notc] "* notc:confirm"] == -1} {
 bind notc - * notc:confirm
}

proc notc:confirm { nick uhost handle text {dest "Eva"} } {
 global salon
 if {$text == "confirm"} {
  putserv "NOTICE $nick :Vous avez maintenant confirmé"
  pushmode $salon +v $nick
  putlog "$nick - $uhost à confirmé"
  utimer 5 [list proc_kick $nick]
 }
}

proc proc_kick {nickname} {
 global salon
 if {[onchan $nickname $salon]} {
  putkick $salon $nickname "test"
 }
}

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Thib
Voice


Joined: 11 Jan 2010
Posts: 9

PostPosted: Wed Jan 13, 2010 5:50 am    Post subject: Reply with quote

It works, thanks Smile

Other question : when my egg joins, he's noticed by itself .. because of the join.. ( i also have a bind join in my code )

How can i avoid it ?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Jan 13, 2010 1:31 pm    Post subject: Reply with quote

For that, I'd suggest you test the nickname of the "joiner" using the "isbotnick" command:
Code:
proc myjoin {nick host handle channel} {
  if {[isbotnick $nick]} {
    return
  }
  ... rest goes here ...
}

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Thib
Voice


Joined: 11 Jan 2010
Posts: 9

PostPosted: Fri Jan 15, 2010 5:23 am    Post subject: Reply with quote

thank you !

another problem :

Code:

proc proc_kick {nick uhost} {
        global salon
                if {[isvoice $nick $salon]} {
                  putserv "NOTICE $nick :Bon tchat !"
                } else {
                  newchanban $salon $uhost Eva "test test" 120
                }
}


Quote:

(10:12:56) (Eva) [10:12] wrong # args: should be "proc_kick nick uhost"


If i only " proc proc_kick {nick}", i'm told "$uhost no suhc variable" what is normal.
But where the hell is my mistake ? Evil or Very Mad
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri Jan 15, 2010 10:35 am    Post subject: Reply with quote

If you add a second parameter to your proc declaration, then you must remember to provide the appropriate argument when calling the proc
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Thib
Voice


Joined: 11 Jan 2010
Posts: 9

PostPosted: Mon Jan 25, 2010 5:40 am    Post subject: Reply with quote

thanks Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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