| View previous topic :: View next topic |
| Author |
Message |
Thib Voice
Joined: 11 Jan 2010 Posts: 9
|
Posted: Mon Jan 11, 2010 11:58 am Post subject: proc under proc problems - dubble logs |
|
|
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 :
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
Thib |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Jan 12, 2010 5:41 pm Post subject: |
|
|
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 |
|
 |
Thib Voice
Joined: 11 Jan 2010 Posts: 9
|
Posted: Wed Jan 13, 2010 5:50 am Post subject: |
|
|
It works, thanks
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Wed Jan 13, 2010 1:31 pm Post subject: |
|
|
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 |
|
 |
Thib Voice
Joined: 11 Jan 2010 Posts: 9
|
Posted: Fri Jan 15, 2010 5:23 am Post subject: |
|
|
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 ?  |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Jan 15, 2010 10:35 am Post subject: |
|
|
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 |
|
 |
Thib Voice
Joined: 11 Jan 2010 Posts: 9
|
Posted: Mon Jan 25, 2010 5:40 am Post subject: |
|
|
thanks  |
|
| Back to top |
|
 |
|