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 

[Solved] Need some help again :\
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Red_Rooste5
Voice


Joined: 21 Oct 2006
Posts: 37

PostPosted: Mon Dec 11, 2006 11:07 am    Post subject: [Solved] Need some help again :\ Reply with quote

Well This is my newly updated invite script.
Code:
bind raw - INVITE invites:join

proc invites:join {from key arg} {
  set chan [string range [lindex [split $arg] 1] 1 end]
set chans [llength [split [channels]]]
set nick [lindex [split $from !] 0]
if {$chans == 30} {
putquick "NOTICE $nick :This bot is currently full, searching for other bots."
putquick "PRIVMSG #boombot :join $chan"
utimer 10 [list invites:joinmsg $chan $nick]
return
if {$chans < 30} {
   channel add $chan
return
  }
}

set requirement 5

proc invites:joinmsg {nick uhost hand chan} {
global requirement
set chans [llength [chanlist $chan]]
if {$chans < $requirement} {
putquick "PART $chan :You need atleast 5 users to have this bot in your channel$
channel remove $chan
if {[onchan \[De\]BoomBot $chan]} {
putlog "OMG \[De\]BoomBot is on $chan"
putquick "PART $chan You already have a BoomBot in your chan."
channel remove $chan
}
return
}
if {$chans >= 5} {
if {[string equal -nocase $::botnick $nick]} {
  putquick "PRIVMSG $chan :\00302BoomBot v1.9 by \00307Red_Rooste5"
return
}
}
}
}


That's on the first bot

Code:
bind pub * join join:de
proc join:de {nick uhost hand chan text} {
if {[string equal -nocase BoomBot $nick]} {
channel add $text
}
}

bind join * {*} joinmsg:de
proc joinmsg:de {nick uhost hand chan} {
if {llength [split [chanlist $chan]]] < 5} { putquick "PART $chan :You need atl$
channel remove $chan
}
}
{
if {[string equal -nocase \[De\]BoomBot $nick]} {
if {[llength [split [chanlist $chan]]] > 5} {
putquick "PRIVMSG $chan :\00302BoomBot v1.9 by \00307Red_Rooste5"
}
}
}

That's on the second one.

Well... The first problem on the first bot is that it won't join...
And the second bot won't even start with that script.

On the first script, it's meant to get the invite, but if the bot is on 30 channels, it'll message #boombot join $chan but if it's not on 30 channels it will join, though if the channel has 5 or less users, it will part. And on the second one, it's meant to look after "join #chan" and join the channel if "BoomBot" is the one saying the command.


Last edited by Red_Rooste5 on Sat Dec 16, 2006 3:41 am; edited 3 times in total
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Dec 11, 2006 11:23 am    Post subject: Reply with quote

Please indent your code properly.
Doing so would make it obvious you failed to "close" the first conditional body (sending the message 'bout full bot).
Hence, the second if-conditional will only be reached if chans is equal to 30. At the same time, for this second conditional to be true, chans must be less than 30 (which it can't be).

Solution: Indent properly and get your { and } in order

Second script is similar... Properly indented, it would look like this; where the error would be obvious:

Code:
bind pub * join join:de
proc join:de {nick uhost hand chan text} {
 if {[string equal -nocase BoomBot $nick]} {
  channel add $text
 }
}

bind join * {*} joinmsg:de
proc joinmsg:de {nick uhost hand chan} {
 if {llength [split [chanlist $chan]]] < 5} {
  putquick "PART $chan :You need atl$"
  channel remove $chan
 }
}


{
 if {[string equal -nocase \[De\]BoomBot $nick]} {
  if {[llength [split [chanlist $chan]]] > 5} {
   putquick "PRIVMSG $chan :\00302BoomBot v1.9 by \00307Red_Rooste5"
  }
 }
}


Edit: Just to make clear, the above script is not fixed, just had some proper indenting to actually make the error visible. Don't expect it to run.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Red_Rooste5
Voice


Joined: 21 Oct 2006
Posts: 37

PostPosted: Mon Dec 11, 2006 11:40 am    Post subject: Reply with quote

Anyways, what do you mean by "It can't be on less then 30 channels"?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Dec 11, 2006 1:06 pm    Post subject: Reply with quote

Simply, if you actually study your conditionals (if-then-else constructs), you'd see that the only time this is actually executed:
Code:
if {$chans < 30} {...
is when the conditional:
Code:
if {$chans == 30} {...
is fulfilled...

So, whenever this part of the code:
Code:
if {$chans < 30} {...
is executed, chans will be 30 and nothing else.. 30 is not less than 30, hence it will always be false, and your bot will never join the channel...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Red_Rooste5
Voice


Joined: 21 Oct 2006
Posts: 37

PostPosted: Mon Dec 11, 2006 4:12 pm    Post subject: Reply with quote

Sooo... What I gotta do here is that I need to change the if's to =< ?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Dec 11, 2006 4:48 pm    Post subject: Reply with quote

NO!
What you need is this:

Quote:
Solution: Indent properly and get your { and } in order


Changing the comparison operator in the second if-statement wont change the fact that it will only be run when the first if-statement is true (chans == 30).

Edit: Also, since there's a return-command within the first conditional, prior to the second if-statement, the second if-statement won't be evaluated even if chans == 30.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Red_Rooste5
Voice


Joined: 21 Oct 2006
Posts: 37

PostPosted: Tue Dec 12, 2006 10:14 am    Post subject: Reply with quote

Erm... I really don't get your point. What should I do with the script itself?
Do I need to remove the return on the first statement or what?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Dec 12, 2006 10:21 am    Post subject: Reply with quote

No, you need to get your braces ({ and }) in order.
If you don't understand this, I suggest you study the tcl manual, especially this part.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Red_Rooste5
Voice


Joined: 21 Oct 2006
Posts: 37

PostPosted: Tue Dec 12, 2006 10:37 am    Post subject: Reply with quote

Well.. I got that working now, but it now gives me this:
Code:

[15:35] can't read "chans": no such variable
    while executing
"if {$chans >= 5} {
if {[string equal -nocase $::botnick $nick]} {
  putquick "PRIVMSG $chan :\00302BoomBot v1.9 by \00307Red_Rooste5"
return
}
}"
    (file "scripts/invite1.tcl" line 36)
    invoked from within
"source scripts/invite1.tcl"
    (file "eggdrop.conf" line 1353)
[15:35] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)


Script:
Code:
bind raw - INVITE invites:join

proc invites:join {from key arg} {
  set chan [string range [lindex [split $arg] 1] 1 end]
set chans [llength [split [channels]]]
set nick [lindex [split $from !] 0]
if {$chans == 30} {
putquick "NOTICE $nick :This bot is currently full, searching for other bots."
putquick "PRIVMSG #boombot :join $chan"
utimer 10 [list invites:joinmsg $chan $nick]
return
}
if {$chans < 30} {
   channel add $chan
return
  }
}

set requirement 5

proc invites:joinmsg {nick uhost hand chan} {
global requirement
set chans [llength [chanlist $chan]]
if {$chans < $requirement} {
putquick "PART $chan :You need atleast 5 users to have this bot in your channel$
channel remove $chan
}
elseif {[onchan \[De\]BoomBot $chan]} {
putlog "OMG \[De\]BoomBot is on $chan"
putquick "PART $chan You already have a BoomBot in your chan."
channel remove $chan
}
return
}
global chans
if {$chans >= 5} {
if {[string equal -nocase $::botnick $nick]} {
  putquick "PRIVMSG $chan :\00302BoomBot v1.9 by \00307Red_Rooste5"
return
}
}
}
}
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Dec 12, 2006 10:49 am    Post subject: Reply with quote

And once again, if you actually bothered to indent your code, you'd be able to see the problem yourself... Which still is the fact that you've lost track of your braces... Adding to that, you add a "global chans" while already in globalspace, and also do further matchins on variables not defined in globalspace (that is, you've already "ended" the second proc when you reach the point where you write "global chans").

Obviously, this is an error due to the fact that you've lost track on your { }. Properly indenting your code helps you with that. Any further code-parts you post that are not indented, will be ignored on my behalf...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Red_Rooste5
Voice


Joined: 21 Oct 2006
Posts: 37

PostPosted: Tue Dec 12, 2006 11:14 am    Post subject: Reply with quote

Code:

bind raw - INVITE invites:join
 proc invites:join {from key arg} {
 set chan [string range [lindex [split $arg] 1] 1 end]
 set chans [llength [split [channels]]]
 set nick [lindex [split $from !] 0]
 if {$chans == 30} {
  putquick "NOTICE $nick :This bot is currently full, searching for other bots."
  putquick "PRIVMSG #boombot :join $chan"
  utimer 10 [list invites:joinmsg $chan $nick]
  return
 }
 if {$chans < 30} {
  channel add $chan
  putquick "PRIVMSG $chan :\00302BoomBot version 1.9 by \00307Red_Rooste5"
  return
  }
}

set requirement 5

proc invites:joinmsg {nick uhost hand chan} {
 global requirement
 set chans [llength [chanlist $chan]]
  if {$chans < $requirement} {
   putquick "PART $chan :You need atleast 5 users to have this bot in your chan$
   channel remove $chan
  }
 elseif {[onchan \[De\]BoomBot $chan]} {
  putlog "OMG \[De\]BoomBot is on $chan"
  putquick "PART $chan You already have a BoomBot in your chan."
  channel remove $chan
  return
 }
}
if {$chans >= 5} {
 if {[string equal -nocase $::botnick $nick]} {
  putquick "PRIVMSG $chan :\00302BoomBot v1.9 by \00307Red_Rooste5"
  return
 }
}

There. I atleast tried to indent dunno if I made it right or not :\
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Dec 12, 2006 11:33 am    Post subject: Reply with quote

Indention is roughly correct (or correct enough).
Should be quite obvious now that
Code:
if {$chans >= 5} {
 if {[string equal -nocase $::botnick $nick]} {
  putquick "PRIVMSG $chan :\00302BoomBot v1.9 by \00307Red_Rooste5"
  return
 }
}
is not part of the body of invites:joinmsg, but instead is executed in globalspace when your script is loaded (and at that point, there's no chans-variable defined, and both nick and botnick have special meaning here. Also, using return in globalspace might not be such a good idea. I'm guessing that code-snipped rather should be part of invites:joinmsg, and hence the solution is trivial.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Red_Rooste5
Voice


Joined: 21 Oct 2006
Posts: 37

PostPosted: Tue Dec 12, 2006 11:53 am    Post subject: Reply with quote

Well, I did update the script after intending it.
Code:
bind raw - INVITE invites:join
 proc invites:join {from key arg} {
 set chan [string range [lindex [split $arg] 1] 1 end]
 set chans [llength [split [channels]]]
 set nick [lindex [split $from !] 0]
 if {$chans == 30} {
  putquick "NOTICE $nick :This bot is currently full, searching for other bots."
  putquick "PRIVMSG #boombot :join $chan"
  utimer 10 [list invites:joinmsg $chan $nick]
  return
 }
 if {$chans < 30} {
  channel add $chan
  putquick "PRIVMSG $chan :\00302BoomBot version 1.9 by \00307Red_Rooste5"
  return
  }
}

set requirement 5

proc invites:joinmsg {nick uhost hand chan} {
 global requirement
 set nickonchan [llength [chanlist $chan]]
  if {$nickonchan > $requirement} {
   putquick "PART $chan :You need atleast 5 users to have this bot in your chan$
   channel remove $chan
  }
 elseif {[onchan \[De\]BoomBot $chan]} {
  putlog "OMG \[De\]BoomBot is on $chan"
  putquick "PART $chan You already have a BoomBot in your chan."
  channel remove $chan
  return
 }
elseif {$nickonchan =< $requirement} {
 if {[string equal -nocase $::botnick $nick]} {
  putquick "PRIVMSG $chan :\00302BoomBot v1.9 by \00307Red_Rooste5"
  return
 }
}
}


So it starts now, but doesnt part or anything. And nothing is on the pl either.
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Dec 12, 2006 11:58 am    Post subject: Reply with quote

You should not have any newline in front of else or elseif
Incorrect:
Code:
}
elseif {....} {


Correct:
Code:
} elseif {.....} {


Also, I see a logical error:
Code:
if {$nickonchan > $requirement} {

This would be true if there are more than 5 members in the channel, not less
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Red_Rooste5
Voice


Joined: 21 Oct 2006
Posts: 37

PostPosted: Tue Dec 12, 2006 12:00 pm    Post subject: Reply with quote

EDIT: Nvm Razz
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
Goto page 1, 2, 3  Next
Page 1 of 3

 
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