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 

Member Management List Help

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
Kraka
Voice


Joined: 21 Apr 2005
Posts: 19

PostPosted: Sat Jul 30, 2005 8:17 pm    Post subject: Member Management List Help Reply with quote

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:

##########################################################
##########################################################
##   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)"
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sat Jul 30, 2005 9:20 pm    Post subject: Reply with quote

*sigh*

another shining example of how not to handle data & files

anyway:
Code:

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive 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