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.

Help about writing userfile

Help for those learning Tcl or writing their own scripts.
Post Reply
i
ijookeren
Voice
Posts: 4
Joined: Thu Sep 02, 2021 8:04 pm

Help about writing userfile

Post by ijookeren »

hi, i confuse about setuser

i write a simple script

Code: Select all

bind msg n pass msg_pass

proc msg_pass {nick uhost hand rest} {
	global botnick
	if {![matchattr $nick n]} {
		putquick "NOTICE $nick :Not Owner"
		return 0
	}
	set rest [lindex $rest 0]
	if {$rest == ""} {
		putquick "PRIVMSG $nick :Type /msg $botnick pass <password>"
		return 0
	}
	set pw $rest
	setuser $nick PASS $rest
        chattr $nick +G
	putquick "PRIVMSG $nick :pass $nick set to $pw , you can identify for protection!"
}
but it cannot save into mybot.user files.

and 1 again..
first time i connect an eggdrop..
after msg hello word
eggdrop ask me to set a password.
where i can find the password or change the password..

when i using [passwdok $nick $pass] its return 0
and when i enter first time password its said invalid/wrong password...

trying with this script

Code: Select all

#         Script : Auth v1.03 by David Proper (Dr. Nibble [DrN])
#                  Copyright 2002 Radical Computer Systems
#
#       Original
#       Platform : Linux 2.0.33
#                  Eggdrop v1.2.0+bel1
#       Current
#      Platforms : Linux 2.2.16    TCL v8.3
#                  Eggdrop v1.6.2
#                  Eggdrop v1.6.6
#            And : SunOS 5.8       TCL v8.3
#                  Eggdrop v1.5.4
#
#    Description : Auth allows you to quickly and easily add authentication
#                  to channel commands. 
#
# To require a command to need authorization, place this before the actual
# procedure, but after any level/access checking:
# if {(![authed $hand])} {return 0}
#
#       Features : 
#                 o Easy method to require password authentication 
#                 o Expires authentication when they part all bot chans
#                 o Expires authentications when they sign-off
#                 o Expires authentication when idle over 60 mins unless DCCed
#                 o Expires all authentications when connects to a server.
#                 o Requires user to be on at least one bot channel to auth.
#
#        History : 05/20/2001 - First Release
#                  12/30/2001 - v1.01
#                              o Will check to make sure user is on a
#                                channel the bot is on before allowing
#                                them to authenticate.
#                  01/02/2002 - v1.02
#                              o Fixed empty string error.
#                  12/09/2002 - v1.03
#                              o Fixed [die] nick vulerablity
#
#
#   Future Plans : Hell if I know.
#
#      Donations : https://www.paypal.com/xclick/business=rainbows%40stx.rr.com
# (If you don't have PayPal and want to donate, EMail me for an address.
#  Will take money or hardware/computer donations)
#  Significant (or even non-significant donations) can be published on a
#  web site if you so choose.
#
# Author Contact :     Email - DProper@chaotix.net
#                   Homepage - http://www.chaotix.net/~dproper
#                        IRC - Primary Nick: DrN
#                     UseNet - alt.irc.bots.eggdrop
# Support Channels: #RCS @UnderNet.Org
#                   #RCS @DALnet
#                   #RCS @EFnet
#                   #RCS @GalaxyNet
#                   #RCS @Choatix Addiction
#            Other channels - Check contact page for current list
#
#                Current contact information can be located at:
#                 http://rcs.chaotix.net/contact.html
#
# New TCL releases are sent to the following sites as soon as they're released:
#
# FTP Site                   | Directory                     
# ---------------------------+-------------------------------
# ftp.chaotix.net            | /pub/RCS
# ftp.eggheads.org           | Various
# ftp.realmweb.org           | /drn
#
#   Radical Computer Systems - http://rcs.chaotix.net/
# To subscribe to the RCS mailing list:
#  http://www.chaotix.net/mailman/listinfo/rcs-list
#  
#
#  Feel free to Email me any suggestions/bug reports/etc.
# 
# You are free to use this TCL/script as long as:
#  1) You don't remove or change author credit
#  2) You don't release it in modified form. (Only the original)
# 
# If you have a "too cool" modification, send it to me and it'll be
# included in the official release. (With your credit)
#
# Commands Added:
#  Where     F CMD       F CMD         F CMD        F CMD
#  -------   - --------- - ----------- - ---------- - --------- - -------
#  Public:   - N/A
#     MSG:   - verify    - pubauth     - deauth
#     DCC:   - N/A
#
# Public Matching: N/A
#

#\
# |##### NOTE: Anything on the Chaotix.Net domain is currently offline
#/

set authver "v1.02.00"

# Set this to the user defined flag to use to indicate authorized.
set authflag "Z"

bind msg - verify msg_auth
bind msg - pubauth msg_auth
proc msg_auth {nick uhost hand rest} {
  global botnick authflag
 
  if {$rest == ""} {
    putserv "NOTICE $nick :Usage: /msg $botnick verify password"
    putserv "NOTICE $nick :  Authenticate for public commands."
    return 0
  }
 if {([matchattr $hand $authflag] == 1)} {
    putserv "NOTICE $nick :You are allready athenticated."
    return 0
                                 }

if {(![auth_chans $nick $hand])} {return 0}

 if {[passwdok $hand $rest] == 1} {
    putlog "$nick is now authenticated"
    putserv "NOTICE $nick :You are now athenticated."
    chattr $hand "+${authflag}"
                                  } else { putserv "NOTICE $nick :Access Denied." } 
                                     }


bind msg - deauth msg_deauth
proc msg_deauth {nick uhost hand rest} {
 global authflag
 chattr $hand "-${authflag}"
 putlog "$nick request deauth. Deauthenticated."
 putserv "NOTICE $nick :You're no longer authenticated."
}

proc authed {hand} {
 global botnick authflag
 set nick [hand2nick $hand]
 if {([matchattr $hand $authflag] == 1)} {return 1
                                 } else {
                                         putserv "NOTICE $nick :Please athenticate before using this command."
                                         putserv "NOTICE $nick :To authenticate: /msg $botnick verify yourpassword"
                                         putlog "$nick tried to use an authenticated command."
                                         return 0
                                        }
}

bind part $authflag * auth_part
proc auth_part {nick uhost hand chan {msg ""}} {
subst -nobackslashes -nocommands -novariables nick
subst -nobackslashes -nocommands -novariables msg

regsub -all {\[} $nick "\\\[" nick
regsub -all {\]} $nick "\\\]" nick

regsub -all {\[} $nick "\\\[" msg
regsub -all {\]} $nick "\\\]" msg

 utimer 5 "auth_check $nick $hand"
}

bind sign $authflag * auth_signoff
proc auth_signoff {nick uhost hand channel reason} {
 global authflag
 chattr $hand "-${authflag}"
 putlog "$nick signed off. Deauthenticated."

}

proc auth_check {nick hand} {
subst -nobackslashes -nocommands -novariables nick

 global authflag
 if {([matchattr $hand $authflag] == 0)} {return}
 set chans [channels]
 set chan_tot [llength $chans]
 set chan_num 0
 for {set loop 0} {$loop < $chan_tot} {incr loop} {
  if {[onchan $nick [lindex $chans $loop]]==1} {incr chan_num +1}
                                                  }

 if {($chan_num == 0)} {
    chattr $hand "-${authflag}"
    putlog "$nick parted all channels. Deauthenticated."
    putserv "NOTICE $nick :You're no longer on one of my channels. You have been deathenticated."
    return 0
                       }
}

proc auth_chans {nick hand} {
 global authflag
 set chans [channels]
 set chan_tot [llength $chans]
 set chan_num 0
 for {set loop 0} {$loop < $chan_tot} {incr loop} {
  if {[onchan $nick [lindex $chans $loop]]==1} {incr chan_num +1}
                                                  }

 if {($chan_num == 0)} {
    putlog "$nick Isn't on any of my channels. Athentication Rejected"
    putserv "NOTICE $nick :You're not on any of my channels. Athentication is rejected."
    return 0
                       }
return 1
}

proc auth_idle {} {
global _auth authflag

set idletime 1
 set chans [channels]
 set chan_tot [llength $chans]
 set chan_num 0
 for {set loop 0} {$loop < $chan_tot} {incr loop} {
   set nicks [chanlist [lindex $chans $loop] $authflag]
   set nickidle 1
   set nick_tot [llength $nicks]
    for {set loop2 0} {$loop2 < $nick_tot} {incr loop2} {
      set idletime [getchanidle [lindex $nicks $loop2] [lindex $chans $loop]]
      if {$idletime >= $nickidle} {set nickidle $idletime}
      if {($idletime > 60)} {
                           set nick [lindex $nicks $loop2]
                           set hand [nick2hand [lindex $nicks $loop2]]
     if {[hand2idx $hand] == -1} {
                           putlog "$nick Idle over 60 minutes. Deauthenticated."
                           chattr $hand "-${authflag}"
                           putserv "NOTICE $nick :Idle over 60 minutes. Deauthenticated."
                                 }
                          } 
                                                                }
                                                  }

 set _auth [timer 60 auth_idle]
}

set init-server { run_server_init }

proc run_server_init {} {
 global botnick
 putserv "MODE $botnick +i-ws"
 reset_auth
}

proc reset_auth {} {
 global authflag
 set users [userlist $authflag]
 set user_tot [llength $users]
 set user_num 0
 for {set loop 0} {$loop < $user_tot} {incr loop} {
   set hand [lindex $users $loop]
   if {[hand2idx $hand] == -1} {
      putlog "Reseting authorizations. $hand Deauthenticated."
      chattr $hand "-${authflag}"
                               }
                                                  }  

}


if {![info exists _auth]} {
                           putlog "Starting auth timmer"
                           set _auth [timer 60 auth_idle]
                            }


return "Auth.tcl $authver by Dr. Nibble (DrN) -: Loaded :-"

User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I think you've to use $hand rather than $nick for setuser and chattr.

Code: Select all

setuser $hand PASS $rest
chattr $hand +G
i
ijookeren
Voice
Posts: 4
Joined: Thu Sep 02, 2021 8:04 pm

Post by ijookeren »

thx for reply..

i think there is problem with my userfile..
i try no tcl..
thereis no PASS on userfile..

there is some delay ?

EDIT:
after ctcp chat with bot
and .save command..

i have PASS in mybot.user

so every change i must .save to overwrite mybot.user files
thanks..
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

ijookeren wrote:
...
so every change i must .save to overwrite mybot.user files
...
Not exactly. You may, but you don't have to, because the bot will automatically save the user file periodically. I believe it is on the hour.

And the bot will save the user file when it is shut down, if it is shut down properly. That is, with the .die command. If it is slammed down with kill -9 from the shell command line, I think then it cannot.

It can't hurt to use the .save command though. Especially if you've just made an edit to a user's account in the bot, and you know that you are about to shut it down. I use the .save command when I log into a brand new bot for the first time, after examining my own account in the bot. Often, I edit my HOSTS line. Then I .save, then I .die the bot. This way, I can start it again right away, without the -m switch. If I don't do this, I am apt to forget it and leave the bot running with that -m switch. :)
Other than that, I rarely use the .save command.

By the way, the same applies to the .chan file.

I hope this helps.
Have fun with your new bot.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
Post Reply