# shroudBNC - an object-oriented framework for IRC
# Copyright (C) 2005-2007,2010 Gunnar Beutner
#
# Modified for use with nickserv.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

proc nickserv:migrate_users {authphrase} {
	foreach user [bncuserlist] {
		set nuser [getbncuser $user tag nickserv.nick]
		set npass [getbncuser $user tag nickserv.password]
		set nphrase "*[getbncuser $user tag nickserv.warning]*"

    if {$nphrase == "**"} {
			set nphrase $authphrase
		}

		if {$npass == ""} {
			continue
		}

		setbncuser $user tag authuser $nuser
		setbncuser $user tag authpass $npass
		setbncuser $user tag authphrase $nphrase 
	
    setbncuser $user tag nickserv.nick ""
		setbncuser $user tag nickserv.password ""
		setbncuser $user tag nickserv.reply ""
		setbncuser $user tag nickserv.warning ""
    setbncuser $user tag nickserv.onconnect ""		

		setbncuser $user tag auth on
	
	}
}

putmainlog "Nickserv migrate script loaded. /sbnc tcl nickserv:migrate_users \"<default authphrase>\""
