| View previous topic :: View next topic |
| Author |
Message |
PrE Voice
Joined: 14 Jan 2012 Posts: 10
|
Posted: Sat Feb 11, 2012 9:28 pm Post subject: auto invite |
|
|
Anyone willing to code me a autoinvite script with a datebase?
like
.+adduserdb
it will add the use to db (list of people to be invited on join)
so when the user joins one of the channels the bot is in it check if the user is on invite list and if it is will invite the user to another chan |
|
| Back to top |
|
 |
Johannes13 Halfop
Joined: 10 Oct 2010 Posts: 46
|
Posted: Sun Feb 12, 2012 11:03 am Post subject: |
|
|
| Code: |
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 |
|
| Back to top |
|
 |
PrE Voice
Joined: 14 Jan 2012 Posts: 10
|
Posted: Mon Feb 13, 2012 11:15 am Post subject: |
|
|
the script does not seem to work....  |
|
| Back to top |
|
 |
Johannes13 Halfop
Joined: 10 Oct 2010 Posts: 46
|
Posted: Mon Feb 13, 2012 11:28 am Post subject: |
|
|
Ok, it has the public triggers +autoinvite and -autoinvite.
Only ops (users with the o flag for either the channel or global) can use that commands.
And it requires at least Tcl 8.5.
Try it, if it does not work, please give me the error you receive on the partyline. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Feb 13, 2012 1:50 pm Post subject: |
|
|
What is
| Code: |
if {$a ni [channel get $c autoinvite]} {
|
meant to do? "ni" means "not in" or what?
To check if a specific channel flag is active or not use the builtin channel get function like this:
| Code: |
if {[channel get $c autoinvite]} {
|
also, you should make autoinvite a flag (+autoinvite when active and -autoinvite when is disabled), not a string.
PS: My TCL version is 8.4 (just type tclsh in your shell then puts $tcl_version to see what version you have). _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Johannes13 Halfop
Joined: 10 Oct 2010 Posts: 46
|
Posted: Mon Feb 13, 2012 2:59 pm Post subject: |
|
|
caesar: read the script and you _MIGHT_ get an idea why autoinvite is a string, not a flag.
And reinstall Tcl. 8.5 is out for years, and 8.6b2 is also stable enough to run eggdrop with it.
And what ni does. I suggest reading the manual for expr.
Please. I did not wrote that script for you, but you can modify it if you want to use it. But then LEARN TCL.
One last thing: to get what exact version of Tcl you have, execute tclsh and enter one of that commands:
| Code: | package provide Tcl
info patchlevel |
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Feb 14, 2012 5:26 am Post subject: |
|
|
| Quote: |
[...]you should make autoinvite a flag (+autoinvite when active and -autoinvite when is disabled), not a string. [...]
|
You clearly missed out that part.
My TCL version and knowledge is just fine. I've suggested that change merely to allow other members to easily understand the code.
Anyway, please take care of that attitude, there's no need to be an asshole and start insulting people. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Johannes13 Halfop
Joined: 10 Oct 2010 Posts: 46
|
Posted: Tue Feb 14, 2012 11:06 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
PrE Voice
Joined: 14 Jan 2012 Posts: 10
|
Posted: Tue Feb 14, 2012 8:29 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Feb 15, 2012 2:39 am Post subject: |
|
|
Ahh.. I've checked again your code and you are you are right, my bad. I was thinking about something else.
@PrE : Sure. Repalce join:chkinvite with this:
| Code: |
proc join:chkinvite {n u h c} {
if {[isbotnick $n]} return
foreach ic [channels] {
if {[onchan $n $ic]} continue
foreach mask [channel get $c autoinvite] {
if {![string match -nocase $n!$u $mask]} continue
putserv "INVITE $n $ic"
break
}
}
}
|
PS: I've upgraded to 8.5  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
PrE Voice
Joined: 14 Jan 2012 Posts: 10
|
Posted: Wed Feb 15, 2012 2:47 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Johannes13 Halfop
Joined: 10 Oct 2010 Posts: 46
|
Posted: Wed Feb 15, 2012 3:44 pm Post subject: |
|
|
Ok, rewrite, now it uses eggdrops internal invite list to do that things.
That means you can add/remove an invite with +invite/-invite
| Code: | 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"
}
}
}
|
|
|
| Back to top |
|
 |
|