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.

auto invite

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
P
PrE
Voice
Posts: 10
Joined: Sat Jan 14, 2012 8:19 pm

auto invite

Post by PrE »

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
J
Johannes13
Halfop
Posts: 46
Joined: Sun Oct 10, 2010 11:38 am

Post by Johannes13 »

Code: Select all

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 :P

Edit: fixed some mistakes
Last edited by Johannes13 on Mon Feb 13, 2012 11:31 am, edited 1 time in total.
P
PrE
Voice
Posts: 10
Joined: Sat Jan 14, 2012 8:19 pm

Post by PrE »

the script does not seem to work.... :(
J
Johannes13
Halfop
Posts: 46
Joined: Sun Oct 10, 2010 11:38 am

Post by Johannes13 »

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.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

What is

Code: Select all

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: Select all

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.
J
Johannes13
Halfop
Posts: 46
Joined: Sun Oct 10, 2010 11:38 am

Post by Johannes13 »

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: Select all

package provide Tcl
info patchlevel
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

[...]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.
J
Johannes13
Halfop
Posts: 46
Joined: Sun Oct 10, 2010 11:38 am

Post by Johannes13 »

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.
P
PrE
Voice
Posts: 10
Joined: Sat Jan 14, 2012 8:19 pm

Post by PrE »

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.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Ahh.. I've checked again your code and you are you are right, my bad. :) I was thinking about something else. :roll:

@PrE : Sure. Repalce join:chkinvite with this:

Code: Select all

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 :P
Once the game is over, the king and the pawn go back in the same box.
P
PrE
Voice
Posts: 10
Joined: Sat Jan 14, 2012 8:19 pm

Post by PrE »

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.
J
Johannes13
Halfop
Posts: 46
Joined: Sun Oct 10, 2010 11:38 am

Post by Johannes13 »

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: Select all

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"
      }
   }
}
Post Reply