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.

Weird bot problem

Help for those learning Tcl or writing their own scripts.
Post Reply
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

Weird bot problem

Post by T-Xorcist »

Hi guys/girls,

I have the following script:

Code: Select all

proc msg:join {nick host hand text} {
  set chan [lindex $text 0]
  if {[botonchan $chan]} {
    putquick "NOTICE $nick :I am allready on \002$chan\002"
    return 1
  }else{ 
    putquick "PRIVMSG #bots :I have been invited into \002$chan\002 by \002$nick\002"
    putquick "NOTICE $nick :You invited me to join \002$chan\002. Joining..."
    channel add $chan
  }
}
The weird thing is, that it worked 1 time, after that it didn't work anymore.
What am I doing wrong? Because when I start the bot, it doesn't give any errors.
The problem accured when I added the ... if {[botonchan $chan]} { line ...

Thanks in advance!
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You got an error after adding that line but didn't bother to show it here. Replace

Code: Select all

}else{
with

Code: Select all

} else {
or just

Code: Select all

} {
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

Post by T-Xorcist »

Tried it. After I restart the bot, it lissens to me 1 time (parting the channel). After that, it seems it crashes :S

I really do not get the problem :cry:

UPDATE: It doesn't even connect to the IRC server right now... This is a very weird problem I guess... This happened why I tried the } { thing ;)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Is that even a problem from the script? What do you mean crashes? any errors?

Also, I recommend you to split text when setting chan.

Code: Select all

set chan [lindex [split $text] 0]
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

Post by T-Xorcist »

Well, it doesn't work as it supposed to.

When I type /msg botnick join #channel it doesn't respond at all.
But if I use a channel where it is allready in, it gives me response that he is allready in that channel.

So, if the bot is in the channel, it responds with: I am allready in #channel.
But if he is not, he doesn't give me response and doesn't join the channel.

Exactly the same problem with the parting area. It parts the channel if he is on that channel. But if he is NOT on the channel, it doesn't give me a response. After the else, it is going wrong. I guess he doesn't like the } else { part :(

For better understanding, here is the whole script:

Code: Select all

bind msg - join msg:join
bind msg m part msg:part


proc msg:join {nick host hand text} {
  set chan [lindex [split $text] 0]
  if {[botonchan $chan]} {
    putquick "NOTICE $nick :I am allready on \002$chan\002"
  } else { 
    putquick "NOTICE $nick :You invited me to join \002$chan\002. Joining..."
    channel add $chan
  }
}

proc msg:part {nick host hand text} {
  set chan [lindex [split $text] 0]
  if {[botonchan $chan]} {
    putquick "PRIVMSG $chan :Leaving channel... (Removed by T-Xorcist)"
    channel remove $chan
  } else {
    putquick "NOTICE $nick :I am not on \002$chan\002"
  }
}
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

That's because it's not a validchan (doesn't exist in bot's chanfile).

Code: Select all

bind msg - join msg:join
bind msg - part msg:part

proc msg:join {nick uhost hand arg} {
 set c [lindex [split $arg] 0]
 if {[validchan $c]} {
  puthelp "notice $nick :$c is already in my chanfile."
 } {
  channel add $c
  puthelp "notice $nick :$c has been succesfully added to my chanfile."
 }
}

proc msg:part {nick uhost hand arg} {
 set c [lindex [split $arg] 0]
 if {[validchan $c]} {
  channel remove $c
  puthelp "notice $nick :$c has been succesfully removed from my chanfile."
 } {
  puthelp "notice $nick :$c does not exist in my chanfile."
 }
}
T
T-Xorcist
Halfop
Posts: 47
Joined: Mon Nov 14, 2005 6:36 pm
Location: Netherlands
Contact:

Post by T-Xorcist »

Great! It works now. Very much appreciated! :P
Post Reply