setudef str autoinvite
bind pub o|o +autoinvite pub:addinvite
bind pub o|o -autoinvite pub:delinvite
bind join - * join:chkinvite
proc pub:addinvite {n u h c a} {
if {$a ni [channel get $c autoinvite]} {
set tmp [channel get $c autoinvite]
lappend tmp $a
channel set $c autoinvite $tmp
putnotc $n "$a has been added to the autoinvite database"
} {
putnotc $n "$a is already in the autoinvite database"
}
}
proc pub:delinvite {n u h c a} {
set tmp [channel get $c autoinvite]
set pos [lsearch -exact $tmp $a]
if {$pos == -1} {
putnotc $n "$a is not in the autoinvite database"
} {
channel set $c autoinvite [lreplace $tmp $pos $pos]
putnotc $n "$a was removed from the autoinvite database"
}
}
proc join:chkinvite {n u h c} {
foreach ic [channels] {
if {[onchan $n $ic]} {continue}
if {$n in [channel get $ic autoinvite]} {
putserv "INVITE $n $ic"
}
}
}
May or may not work, might or might not be what you want
Edit: fixed some mistakes
Last edited by Johannes13 on Mon Feb 13, 2012 11:31 am, edited 1 time in total.
Ok, as you can see from my script, I treat the value of autoinvite as a list.
I use it to store what nicks should be invited to that channel.
Such a thing is much simpler than writing my own database with all the IO stuff.
An other solution is to use user defined flags (A-Z). Also effective, but it requires that every user that should be invited have a handle.
And ni stands for "not in", right.
Sorry for my offense, but your tip was to use a flag, and my script uses an other method, so it was useless and I've read more or less: "I don't understand what is going on, but do xyz, this is always good."
PS.: Tcl 8.5 has some very cool new features that I often use. Some of them are: dicts, extended expr syntax (eq, ne, in, ni), namespace ensebles.
I write my scripts always for 8.5 because 8.4 is imho not up-to-date. You can keep your old Tcl version, but then some (if not all) scripts from me won't work for you.
the script works now awesome, btw is it possible to add host mask check rather then nick? because i don't want random ppl changing nicks to get in the channel...thanks though.
wow thanks, I know am asking to much but not giving anything thing other then thanks but is it possible to set mode +I on the same host when the user is added/removed
so like
User added to autoinvite database
MODE +I *!*user@host.com
User removed from autoinvite database
MODE -I *!*user@host.com
i need this just so if the bot is down or not in the channel the user can still get in the channel.
bind pub o|o +autoinvite pub:addinvite
bind pub o|o -autoinvite pub:delinvite
bind join - * join:chkinvite
proc pub:addinvite {n u h c a} {
if {![isinvite $a $c]} {
newchaninvite $c $a $h "" 0 sticky
putnotc $n "$a has been added to the autoinvite database"
} {
putnotc $n "$a is already in the autoinvite database"
}
}
proc pub:delinvite {n u h c a} {
if {![isinvite $a $c]} {
putnotc $n "$a is not in the autoinvite database"
} {
killchaninvite $c $a
putnotc $n "$a was removed from the autoinvite database"
}
}
proc join:chkinvite {n u h c} {
foreach ic [channels] {
if {[onchan $n $ic]} {continue}
if {[matchinvite $n!$u $ic]} {
putserv "INVITE $n $ic"
}
}
}