egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

auto invite

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
PrE
Voice


Joined: 14 Jan 2012
Posts: 10

PostPosted: Sat Feb 11, 2012 9:28 pm    Post subject: auto invite Reply with quote

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
View user's profile Send private message
Johannes13
Halfop


Joined: 10 Oct 2010
Posts: 46

PostPosted: Sun Feb 12, 2012 11:03 am    Post subject: Reply with quote

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 Razz

Edit: fixed some mistakes


Last edited by Johannes13 on Mon Feb 13, 2012 11:31 am; edited 1 time in total
Back to top
View user's profile Send private message
PrE
Voice


Joined: 14 Jan 2012
Posts: 10

PostPosted: Mon Feb 13, 2012 11:15 am    Post subject: Reply with quote

the script does not seem to work.... Sad
Back to top
View user's profile Send private message
Johannes13
Halfop


Joined: 10 Oct 2010
Posts: 46

PostPosted: Mon Feb 13, 2012 11:28 am    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Feb 13, 2012 1:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
Johannes13
Halfop


Joined: 10 Oct 2010
Posts: 46

PostPosted: Mon Feb 13, 2012 2:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Feb 14, 2012 5:26 am    Post subject: Reply with quote

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
View user's profile Send private message
Johannes13
Halfop


Joined: 10 Oct 2010
Posts: 46

PostPosted: Tue Feb 14, 2012 11:06 am    Post subject: Reply with quote

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
View user's profile Send private message
PrE
Voice


Joined: 14 Jan 2012
Posts: 10

PostPosted: Tue Feb 14, 2012 8:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Wed Feb 15, 2012 2:39 am    Post subject: Reply with quote

Ahh.. I've checked again your code and you are you are right, my bad. Smile I was thinking about something else. Rolling Eyes

@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 Razz
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
PrE
Voice


Joined: 14 Jan 2012
Posts: 10

PostPosted: Wed Feb 15, 2012 2:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
Johannes13
Halfop


Joined: 10 Oct 2010
Posts: 46

PostPosted: Wed Feb 15, 2012 3:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber