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.
Old posts that have not been replied to for several years.
eiSi
Halfop
Posts: 70 Joined: Thu Mar 07, 2002 8:00 pm
Post
by eiSi » Mon Jun 09, 2003 12:52 pm
hi there!
I want to code a little script.
For example someone says: Hello there! Join #thischannel now!!!
I want the bot to kick the user (that's no problem), join #thischannel and says a specific line.
My problem: How to get #thischannel saved in a var?
Thanks for any help!
Greetz,
eiSi
mortician
Voice
Posts: 37 Joined: Sun Sep 22, 2002 6:35 pm
Location: Tsjakamaka
Contact:
Post
by mortician » Mon Jun 09, 2003 1:56 pm
by using a regexp probably ...
e.g. if what he says is stored in the var $rest it would be something like this:
Code: Select all
regexp -line -- {#(.*) } $rest -> chan
$chan will be the channame without the # ...
It is a mistake to think you can solve any major problems just with potatoes.
eiSi
Halfop
Posts: 70 Joined: Thu Mar 07, 2002 8:00 pm
Post
by eiSi » Mon Jun 09, 2003 2:09 pm
thx!
than 2 other questions (sorry...):
what about string manipulation? how to add the # to the front?
that regexp doesn't work, i tried it that way:
proc blocked:words {nick uhost handle chan text} {
set chan [regexp -line -- {#(.*) } $text]
puthelp "PRIVMSG #bot-hub : $chan"
}
but it says: "0".
whats that? can you help me again please? thanks!!
mortician
Voice
Posts: 37 Joined: Sun Sep 22, 2002 6:35 pm
Location: Tsjakamaka
Contact:
Post
by mortician » Mon Jun 09, 2003 2:16 pm
Use the regexp just like it was in my post. (more information about regexp:
http://www.tcl.tk/man/tcl8.4/TclCmd/regexp.htm
And for the String manipulation, just put a # in front of $chan would do the job (e.g. set chan "#$chan")
Code: Select all
proc blocked:words {nick uhost handle chan text} {
regexp -line -- {#(.*) } $text -> chan
set chan "#$chan"
puthelp "PRIVMSG #bot-hub : $chan"
}
It is a mistake to think you can solve any major problems just with potatoes.
eiSi
Halfop
Posts: 70 Joined: Thu Mar 07, 2002 8:00 pm
Post
by eiSi » Mon Jun 09, 2003 2:22 pm
thx, but it won't work:
that's my proc:
proc blocked:words {nick uhost handle chan text} {
set revchan ""
regexp -line -- {#(.*) } $text -> revchan
set revchan "#$revchan"
puthelp "PRIVMSG #bot-hub : $revchan"
}
but it says: "#"
thanks again!!!
and sorry for me posting again
mortician
Voice
Posts: 37 Joined: Sun Sep 22, 2002 6:35 pm
Location: Tsjakamaka
Contact:
Post
by mortician » Mon Jun 09, 2003 2:30 pm
hmz well, did your the chan in your message end with a space? if you would say something like "join #chan" it will not work, if you say "join #chan now" it will work ... there is a space after the (.*) in the regexp to make sure he only takes the first word after the # ... perhaps a better way to do this is, is to take everything and split it into a list:
Code: Select all
proc blocked:words {nick uhost handle chan text} {
set revchan ""
regexp -line -- {#(.*)} $text -> revchan
set revchan "#[lindex [split $revchan] 0]"
puthelp "PRIVMSG #bot-hub : $revchan"
}
allthough you can probably do all this in one regexp, this works for me
Last edited by
mortician on Tue Jun 10, 2003 2:51 am, edited 1 time in total.
It is a mistake to think you can solve any major problems just with potatoes.
eiSi
Halfop
Posts: 70 Joined: Thu Mar 07, 2002 8:00 pm
Post
by eiSi » Mon Jun 09, 2003 2:58 pm
thanks!
but for me it's the same error.
if I type: #asd
it says: #
if I type: #asd now
it says: #asd
hm, I don't know the error, but I'll have a closer look at it tomorrow.
thanks for your help!
stdragon
Owner
Posts: 959 Joined: Sun Sep 23, 2001 8:00 pm
Contact:
Post
by stdragon » Mon Jun 09, 2003 3:23 pm
Code: Select all
proc blocked:words {nick uhost handle chan text} {
set revchan ""
regexp {(#\S+)} $text match revchan
puthelp "PRIVMSG #bot-hub :$revchan"
}
Just a note, though: I've seen many times that people will spam for a particular channel in order to get people angry at that channel. For instance, if #sheep bans baduser, then baduser might set up a spambot to join every channels and say "join #sheep now!!" because it annoys everybody, and some people take revenge on #sheep, when they didn't really even do it.
So the moral is, you should be careful with this, because you might be doing more harm than good.
eiSi
Halfop
Posts: 70 Joined: Thu Mar 07, 2002 8:00 pm
Post
by eiSi » Tue Jun 10, 2003 6:29 am
yep, thanks for the info.
I don't want to use that.. a friend of mine wants to.. I told him your remark...
thanks anyway! now it works fine!