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.

login/logout script

Old posts that have not been replied to for several years.
Locked
C
Carnage69
Halfop
Posts: 64
Joined: Sat Jun 07, 2003 8:25 pm

login/logout script

Post by Carnage69 »

hello i am making a login logout script the login command i think works havent tested it yet the .ops command works just the logout command i need it to remove the nick from the file and it is not working can someone please help me thanks!

Code: Select all

bind pub - .login proc_login 
proc proc_login {nick uhost handle channel arg} { 
  set file ops
  if {![file exists $file]} {close [open $file w]} 
  set io [open $file a+] 
  puts $io $nick 
  close $io 
  putserv "NOTICE $nick :You Are Now LOGED IN" 
} 

bind pub - .logout proc_logout 
proc proc_logout {nick uhost handle channel arg} { 
  set file ops
  if {![file exists $file]} {close [open $file w]} 
  set io [open $file r+] 
  puts $io $nick 
  close $io 
  putserv "NOTICE $nick :You Are Now LOGED OUT" 
} 


bind pub - .ops proc_ops
proc proc_ops {nick uhost handle channel arg} { 
  set file ops 
  if {![file exists $file]} {close [open $file w]} 
  set io [open $file r] 
  set list "" 
  while {![eof $io]} { 
    gets $io line 
    if {[string trim $line] == ""} {continue} 
    lappend list $line 
  } 
  close $io 
  set message "\0002Available Ops\002 :" 
  putserv "PRIVMSG $channel :$message" 
  foreach line $list { 
    putquick "PRIVMSG $channel :$line" 
  } 
}
User avatar
Xpert
Halfop
Posts: 88
Joined: Mon Mar 08, 2004 7:03 am

Post by Xpert »

Code: Select all

Try this:
bind pub - .logout proc_logout 
proc proc_logout {nick uhost handle channel arg} { 
  set file ops 
  if {![file exists $file]} {close [open $file w]} 
  set in [open $file "r"]
  set out [open ${file}.tmp "w+"] 
  while {![eof $in]} { 
    set line [gets $in] 
    if {![string equal -nocase "$line" "$nick"} { 
      puts $out $line 
    } 
  } 
  close $in 
  close $out 
  exec "rm $file" 
  exec "cp ${file}.tmp $file" 
  exec "rm ${file}.tmp"
  putserv "NOTICE $nick :You Are Now LOGED OUT" 
}
Should work, not tested :)
Xpert.
d
dollar
Op
Posts: 178
Joined: Tue Oct 28, 2003 3:47 pm
Location: Netherlands

Post by dollar »

Xpert wrote:

Code: Select all

Try this:
bind pub - .logout proc_logout 
proc proc_logout {nick uhost handle channel arg} { 
  set file ops 
  if {![file exists $file]} {close [open $file w]} 
  set in [open $file "r"]
  set out [open ${file}.tmp "w+"] 
  while {![eof $in]} { 
    set line [gets $in] 
    if {![string equal -nocase "$line" "$nick"} { 
      puts $out $line 
    } 
  } 
  close $in 
  close $out 
  exec "rm $file" 
  exec "cp ${file}.tmp $file" 
  exec "rm ${file}.tmp"
  putserv "NOTICE $nick :You Are Now LOGED OUT" 
}
Should work, not tested :)
Why not use TCL's "file" functions?
dollar (or something similar) at:
#eggdrop / #tcl - undernet
#egghelp / #tcl / #eggtcl - efnet
#eggdrop.support / #tcl - quakenet
#eggdrop - ircnet
C
Carnage69
Halfop
Posts: 64
Joined: Sat Jun 07, 2003 8:25 pm

doesent work

Post by Carnage69 »

i get this error
[12:26] Tcl error [proc_logout]: missing close-bracket
and i cant find were it is missing
User avatar
Xpert
Halfop
Posts: 88
Joined: Mon Mar 08, 2004 7:03 am

Post by Xpert »

Oh, my mistake.
Change this:

Code: Select all

if {![string equal -nocase "$line" "$nick"} {
to:

Code: Select all

if {![string equal -nocase "$line" "$nick"]} {
:)
Xpert.
C
Carnage69
Halfop
Posts: 64
Joined: Sat Jun 07, 2003 8:25 pm

dont work

Post by Carnage69 »

now i get this
[14:41] Tcl error [proc_logout]: couldn't execute "rm ops": no such file or directory
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Re: dont work

Post by GodOfSuicide »

Carnage69 wrote:now i get this
[14:41] Tcl error [proc_logout]: couldn't execute "rm ops": no such file or directory
dont use exec's, tcl's "file" command provides such a feature
file delete ?-force? ?- -? pathname ?pathname ... ?
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

...also, use 'file rename' instead of 'exec cp'+'exec rm'. But why use a file to store those nicks? Storing them in an array would make things alot easier.
Have you ever read "The Manual"?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

not sur if this is what u looking for but from what i can see i gues u are
XplaiN but think of me as stupid
Locked