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.

Member Management List Help

Old posts that have not been replied to for several years.
Locked
K
Kraka
Voice
Posts: 19
Joined: Thu Apr 21, 2005 9:25 pm

Member Management List Help

Post by Kraka »

I have this script and I was wondering what code I would have to put in to make it check the list to make sure the nick that is being added isn't already on the list and if it is to announce it. The command is like !addmem <nick> <posistion>
so the list is like:
Nick1 OP
Nick2 Voice
I want it to just check for the nick and not the posistion. If anyone can help that would be great. Here is the code to the part that I already have:

Code: Select all

##########################################################
##########################################################
##   Info : This tcl is made for shell provider         ##
##   You can Add Staff, Del Staff, View Staff,          ##
##   View URL and View Uptime.                          ##
##                                                      ##
##   Programmer : AcADIeN on Efnet (#hands)             ##
##   Email : admin@tohands.org                          ##
##   Website : http://www.tohands.org                   ##
##########################################################
#Bugs from older version:                               ##
#   Uptime reply didn't do the right job                ##
##########################################################

# channel where it's working
set chan "#channel"

# backupfile is the place where the data will be save

set backupfile "/home/user/eggdrop/provider.txt"

# FLAG
# who can do the addcommand (give me a flag)

set adminflag "X"

# this is the command
# if you set the msg in dcc... the command will have a "." in front
# if you set it in PRIVATE MSG or CHANNEL... the command will have a "!" in front
# Like add if you set the addmsg in DCC... you have to use ".add" but if you set
# in PRIVATE or CHANNEL... you have to use "!add"
#
# understand?? if not well use another script

set addcommand "addmem"
set delcommand "delmem"
set staffcommand "members"

# addmsg,delmsg,uptimemsg,staffmsg and urlmsg is where the addcommand will work

# 0 = in DCC
# 1 = in PRIVATE MSG
# 2 = in CHANNEL

set addmsg "2"
set delmsg "2"
set staffmsg "2"        


# uptimereply,staffreply and urlreply is where the uptimecommand will reply
# Public option will do the same thing as PRIVATEMSG if the msg command (below) 
# is set to PRIVATE MSG
# 0 = in PRIVATE MSG
# 1 = in PRIVATE NOTICE
# 2 = Public 


set staffreply "0" 



################################################
#### DO NOT CHANGE ANYTHING AFTER THIS LINE ####
################################################
if {$addmsg == 0} {
  set addbind dcc
  set addcmd "$addcommand"
} elseif {$addmsg == 1} {
  set addbind msg
  set addcmd "!$addcommand"
} else {            
  set addbind pub
  set addcmd "!$addcommand"
}                       
bind $addbind $adminflag $addcmd add$addbind

if {$delmsg == 0} {
  set delbind dcc
  set delcmd "$delcommand"
} elseif {$delmsg == 1} {
  set delbind msg
  set delcmd "!$delcommand"
} else {            
  set delbind pub
  set delcmd "!$delcommand"
}                       
bind $delbind $adminflag $delcmd del$delbind

if {$staffmsg == 0} {
  set staffbind dcc
  set staffcmd "$staffcommand"
} elseif {$staffmsg == 1} {
  set staffbind msg
  set staffcmd "!$staffcommand"
} else {            
  set staffbind pub
  set staffcmd "!$staffcommand"
}                       
bind $staffbind - $staffcmd staff$staffbind

proc adddcc {hand idx arg} {
  global backupfile addcmd nick time date
set time1 [ctime [unixtime]]
  if {$arg != ""} {
    set fsw [open $backupfile a+]
    puts $fsw "$arg added by $nick on $time1"
    close $fsw
    putlog "$arg has been added"
  } else {
    putlog "You have to put something after $addcmd"
  }
  return 0
} 

proc addmsg {nick uhost hand arg} {         
  global backupfile addcmd time date
set time1 [ctime [unixtime]]
  if {$arg != ""} {
    set fsw [open $backupfile a+]
    puts $fsw "$arg added by $nick on $time1"
    close $fsw
    putserv "PRIVMSG $nick :$arg has been added"
  } else {
    putserv "PRIVMSG $nick :You have to put something after $addcmd"
  }
  return 0
}

proc addpub {nick uhost handle channel arg} {
  global backupfile addcmd chan time date
set time1 [ctime [unixtime]]
  if {$chan == $channel} {
    if {$arg != ""} {
      set fsw [open $backupfile a+]
      puts $fsw "$arg added by $nick on $time1"
      close $fsw
      putserv "PRIVMSG $channel :$arg has been added"
    } else {
      putserv "PRIVMSG $channel :You have to put something after $addcmd"
    }
  }
  return 0
}

proc staffdcc {hand idx arg} {
  global backupfile
  set fs [open $backupfile r]
  putlog "Members are :"
  while {![eof $fs]} {
    gets $fs line
    putlog "$line"
  }
  close $fs
  return 0
}
                                      
proc staffmsg {nick uhost hand arg} {
  global backupfile staffreply
  set fs [open $backupfile r]
  if {$staffreply == 0 || $staffreply == 2} {
    putserv "PRIVMSG $nick :Members are :"
  } else {
    putserv "NOTICE $nick :Members are:"
  }
  while {![eof $fs]} {
    gets $fs line
    if {$staffreply == 0 || $staffreply == 2} {
      putserv "PRIVMSG $nick :$line"
    } else {
      putserv "NOTICE $nick :$line"
    }
  }
  close $fs
  return 0
}

proc staffpub {nick uhost handle channel arg} {
  global backupfile staffreply chan
  if {$chan == $channel} {
    set fs [open $backupfile r]
    if {$staffreply == 0} {
      putserv "PRIVMSG $nick :Members are :"
    } elseif {$staffreply == 1} {
      putserv "NOTICE $nick :Members are:"
    } else {
      putserv "PRIVMSG $channel :Members are:"
    }
    while {![eof $fs]} {
      gets $fs line
      if {$staffreply == 0} {
        putserv "PRIVMSG $nick :$line"
      } elseif {$staffreply == 1} {
        putserv "NOTICE $nick :$line"
      } else {
        putserv "PRIVMSG $channel :$line"
      }
    }
    close $fs
  }
  return 0
}

proc deldcc {hands idx arg} {
  global backupfile delcmd
  if {$arg != ""} {
    set infile [open $backupfile r]
    set outfile [open $backupfile.tmp w]
    set find 0 
    while {![eof $infile]} {
      gets $infile line
      if {![string match [string tolower $arg]* [string tolower $line]]} {
        puts $outfile $line      
      } else {
        set find 1 
      }
    }
    close $infile
    close $outfile   
    if {$find == 1} {            
      file rename -force $backupfile.tmp $backupfile
      putlog "$arg is deleted"
    } else {               
      putlog "$arg not found"               
    }
  } else {
    putlog "You have to put something after $delcmd"
  }
  return 0
}

proc delmsg {nick uhost hand arg} {
  global backupfile delcmd
  if {$arg != ""} {
    set infile [open $backupfile r]
    set outfile [open $backupfile.tmp w]
    set find 0 
    while {![eof $infile]} {
      gets $infile line
      if {![string match [string tolower $arg]* [string tolower $line]]} {
      puts $outfile $line      
      } else {
      set find 1 
      }
    }
    close $infile
    close $outfile   
    if {$find == 1} {            
      file rename -force $backupfile.tmp $backupfile
      putserv "PRIVMSG $nick :$arg is deleted"
    } else {               
      putserv "PRIVMSG $nick :$arg not found"               
    }
  } else {
    putserv "PRIVMSG $nick :You have to put something after $delcmd"
  }
  return 0
}

proc delpub {nick uhost handle channel arg} {
  global backupfile delcmd chan
  if {$chan == $channel} {
    if {$arg != ""} {
      set infile [open $backupfile r]
      set outfile [open $backupfile.tmp w]
      set find 0 
      while {![eof $infile]} {
        gets $infile line
        if {![string match [string tolower $arg]* [string tolower $line]]} {
          puts $outfile $line      
        } else {
          set find 1 
        }
      }
      close $infile
      close $outfile   
      if {$find == 1} {            
        file rename -force $backupfile.tmp $backupfile
        putserv "PRIVMSG $channel :$arg is deleted"
      } else {               
        putserv "PRIVMSG $channel :$arg not found"               
      }
    } else {
      putserv "PRIVMSG $channel :You have to put something after $delcmd"
    }
  }
  return 0
}
 
putlog "provider.tcl v0.7.1 by AcADIeN (http://www.tohands.org)"
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

*sigh*

another shining example of how not to handle data & files

anyway:

Code: Select all

proc adddcc {hand idx arg} {
  global backupfile addcmd nick time date
set time1 [ctime [unixtime]]
  if {$arg != ""} {
    set fsw [open $backupfile a+]
    seek $fsw start
    set argword [lindex [split $arg] 0]
    while {![eof $fsw]} {
      set fileword [lindex [split [gets $fsw]] 0]
      if {[string eq -noc $fileword $argword]} {
        putdcc $idx "$argword is already there"
        close $fsw
        return 0
      }      
    }
    puts $fsw "$arg added by $nick on $time1"
    close $fsw
    putlog "$arg has been added"
  } else {
    putlog "You have to put something after $addcmd"
  }
  return 0
} 
I hope you can figure out the other 2 add procs yourself
Locked