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-add users (with host and basic flags) + expiration

Old posts that have not been replied to for several years.
Locked
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

auto-add users (with host and basic flags) + expiration

Post by CosmicD »

Hello,

How can I automaticly add users when they join a channel where my bot is on. (with their host and some basic flags that expire when they do not actively join channels that the bot is on for ,

I found a small add script, but still I have the problem of the expiration. I really looked hard but all "expire" related tcl's seem to be about ban expires, and not user expires..

I'd like to find a script that tells the bot that it has to delete the user if it doesnt join for x days (to keep the userlist from groing out of control)

the add script I have now is

Code: Select all

bind join - * autoadd_join
#
proc autoadd_join {nick host hand chan} {
    if {$hand == "*"} {
        if {[validuser $nick] == 1} {
            putlog "Adding host to $nick.."
            setuser $nick HOSTS [maskhost $host]
            return 1
        } {
            putlog "Adding new user $nick.."
            adduser $nick [maskhost $host]
            return 2
        }
    }
    return 0
}
Can someone add this expire thingy to it if they know how to do that ?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Well adding a user with a flag on join is indeed a very simple task just 4-5 lines of code. However for the expiration part, that is indeed not very simple.

For this not join thing, you would have to make arrays and store nicks with userhost. However what if the same person joins with a different host? How will the bot recognize it then? if a persons other host is added. Since almost all isps have dynamic ip's.

You would probobaly have to make a timer execute every X secs say checking for joins for every nick with the host then check the user file, then delete that entry. But even as far as I know, this is not very simple as it seems. Because you would also have to store the last seen time as well of that nick, and if it exceeds your defined time then only expire the entry.

Take a look at some seen scripts, that can be a bit helpful. Like bass's seen script, because this will definately involve file manipulation.

Bans have a time limit to expire, (if not set '0' which is permanent). However users do not expire, they can only be deleted manually.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

Post by CosmicD »

wow,

or I could just use the cleanusers.tcl by slennox :) hehe :P

thx :)
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Well if there already was a script, why did you request for it. Just simply put a continuous timer to make it execute a loop after every interval of time you want (5secs, 10secs etc) so it is continuous and remove the public/dcc trigger binds. :)
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

CosmicD wrote:or I could just use the cleanusers.tcl by slennox
Use cleanusers.tcl, it's absolutely brilliant for cleaning up user files.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

security warning

Post by user »

CosmicD wrote:

Code: Select all

        if {[validuser $nick] == 1} {
            putlog "Adding host to $nick.."
            setuser $nick HOSTS [maskhost $host]
            return 1
        }
This will allow anyone able to get a nick matching one of your handles to add their own host to that user record in your bot. This might lead to total/partial compromise of your system (depending on your flags/settings/other scripts)
I think it would be better to force the users to register with your bot before being able to play. (set learn-users 1; set default-flags ""; + *msg:hello bind should do) And just refuse people who are ![validuser] (telling them how to register)
Have you ever read "The Manual"?
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Hey one suggestion I have is to prefix newly added users with something like... game_ so that when you "clean" the userfile, you don't delete your real users by mistake. I also put a +G flag on them to help even more. Furthermore, it's very simple to add this cleaning thing you're talking about automatically. Something like:

Code: Select all

bind join - * autoadd_join 
# 
proc autoadd_join {nick host hand chan} { 
    if {![validuser $hand]} {
        set hand game_$nick
        if {[validuser $hand]} { 
            putlog "Adding host to $hand.." 
            setuser $hand HOSTS [maskhost $host]
        } { 
            putlog "Adding new user $hand.." 
            adduser $hand [maskhost $host] 
            chattr $hand +G
        } 
    }

    if {[matchattr $hand +G]} {
      setuser $hand XTRA gamejoin [clock seconds]
    }
    return 0 
}

# I think this executes once per day or something.. I forget the syntax
bind time - "00 00 *" game_cleanup

proc game_cleanup {args} {
  # change cutoff to whatever you want... tcl is pretty good at
  # understanding relative time
  set cutoff [clock scan "2 weeks ago"]
  foreach hand [userlist +G] {
    set gamejoin [getuser $hand XTRA gamejoin]
    # only delete users matching game_*
    if {$gamejoin < $cutoff && [string match -nocase "game_*" $hand]} {
      deluser $hand
    }
  }
}

Be sure to set your HANDLEN to be long enough, although it's not critical (user name will be truncated).

I didn't test this! But I wrote something similar to prune unused hosts from users.
C
CosmicD
Op
Posts: 102
Joined: Sat Dec 11, 2004 3:46 pm

Post by CosmicD »

well thx all.. the reason i just put it like that that i just found out too late about the cleanusers... but thx :)
Locked