| View previous topic :: View next topic |
| Author |
Message |
Repdientu Voice
Joined: 30 Apr 2009 Posts: 33 Location: Viet Nam
|
Posted: Sat Oct 05, 2019 2:11 am Post subject: help join/part script |
|
|
Hello
i write script to join(part) script but it not work (bot part but not join #)
here is my script
| Code: |
set p_chan "#Lobby"
set p_time 5
proc joinpart_start {} {
global p_time
if {[string match *p_joinpart* [timers]]} {return 0}
timer [expr [rand $p_time] + 1] p_joinpart
}
proc p_joinpart {} {
global botnick p_chan p_time
if {[onchan $botnick $p_chan]} {
channel remove $p_chan
}
if {![onchan $botnick $p_chan]} {
channel add $p_chan
}
timer [expr [rand $p_time] + 1] p_joinpart
}
set p_chan [string tolower $p_chan]
joinpart_start
|
|
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Oct 05, 2019 12:57 pm Post subject: |
|
|
Hello,
The first thing that comes to mind, is that "onchan" only works for channels added to your eggdrop's channel-list. As such, your script would then crash once your eggdrop has left the channel.
The options I see, is either to use the "inactive" channel modifier to temporarily disable the channel (rather than delete it); or if you still prefer to delete it, you'd have to use "validchan" to check whether the channel is valid, rather than using "onchan" (or "botonchan" for that matter). _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Repdientu Voice
Joined: 30 Apr 2009 Posts: 33 Location: Viet Nam
|
Posted: Sat Oct 05, 2019 11:56 pm Post subject: |
|
|
i change script to:
| Code: |
set p_chan "#Lobby"
set p_time 5
proc joinpart_start {} {
global p_time
if {[string match *p_joinpart* [timers]]} {return 0}
timer [expr [rand $p_time] + 1] p_joinpart
}
proc p_joinpart {} {
global botnick p_chan p_time
if {![validchan $p_chan]} {
channel add $p_chan
}
else {
channel remove $p_chan
}
timer [expr [rand $p_time] + 1] p_joinpart
}
set p_chan [string tolower $p_chan]
joinpart_start
|
but it not work. can you help me ? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Oct 06, 2019 5:37 am Post subject: |
|
|
The only obvious error I can see in this code, is that you've placed "else {" on a separate line.
Unlike languages like C, Java, etc; tcl is strictly newline-terminated outside blocks. As your code stands now, tcl tries to interpret "else" as a new command, as opposed to an argument to "if":
| Code: | // this is ok
if {some expression} then {
code here
} else {
other code here
}
//or simplified
if {some expression} {
code here
} {
other code here
}
//or condensed
if {some expression} {code here} {other code here}
// these however will not work
if {some expression}
{
code here
}
...
// then-body is not part of the if-command due to the newline _before_ {
if {some expression} {
code here
} else
{
code here
}
// else-body is not part of the if-command due to the newline _before_ {
if {some expression} {
code here
}
else {
code here
}
// else-keyword and -body is not part of the if-command due to the newline _before_ else |
Hope these examples illustrate the issue _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|