Formatting of code : You can (and must) use [ tcl ] an [ /tcl ] tags (without spaces in tags) to format your TCL codes and have syntax coloration x


CheckDomain by BlackShadow
#1
i tried this script but there's something wrong ..

tcl
#############################################################################
## CheckDomain.tcl 1.1  (17/10/2020)                                ##
##                                                                        ##
##                              Copyright 2008 - 2020 @ WwW.TCLScripts.NET ##
##        _  _  _  _  _  _  _  _  _  _  _  _  _  _          ##
##        / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \          ##
##      ( T | C | L | S | C | R | I | P | T | S | . | N | E | T )        ##
##        \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/          ##
##                                                                        ##
##                      ® BLaCkShaDoW Production ®                        ##
##                                                                        ##
##                                PRESENTS                                ##
##                                     ® ##
##########################  CHECK DOMAIN TCL  #############################
##                                       ##
##  DESCRIPTION:                                             ##
##  Tells you whether an Internet domain name is registered or not.        ##
##    Every valid user can have it's own list of domains that the eggdrop  ##
##    will verify using a timer and announce if something changes to them  ##
##                                                       ##
##  Tested on Eggdrop v1.8.4 (Debian Linux) Tcl version: 8.6.6            ##
##                                                       ##
#############################################################################
##                                                         ##
##  INSTALLATION:                                             ##
##  ++ http,tls packages are REQUIRED for this script to work.            ##
##  ++ Edit CheckDomain.tcl script & place it into your /scripts directory.##
##  ++ add "source scripts/CheckDomain.tcl" to your eggdrop.conf & rehash. ##
##                                                         ##
#############################################################################
##                                                       ##
##  OFFICIAL LINKS:                                                        ##
##  Bugs report : http://www.tclscripts.net                              ##
##  GitHub page : https://github.com/tclscripts/                   ##
##  Online help : irc://irc.undernet.org/tcl-help                        ##
##                #TCL-HELP / UnderNet                                  ##
##                You can ask in english or romanian                      ##
##                                                       ##
##    paypal.me/DanielVoipan = Please consider a donation. Thanks!        ##
##                                                       ##
#############################################################################
##                                                       ##
##  THE MAGIC MAKERS (TCLscripts.net's team):                              ##
##                                                                        ##
##  o BLaCkShaDoW (Daniel) - coding 'magic' maker & the botsfather.        ##
##    BLaCkShaDoW@tclscripts.net [ www.tclscripts.net ]                    ##
##                                                       ##
##  o Settore (Stefan) - generous hosting storage & bandwidth for the      ##
##    tclscripts.net project website.                                      ##
##    settore@tclscripts.net [ www.thedeveloper.site ]                    ##
##                                                       ##
##  o Florian (most craziest imagination guy) - an earful of crazy ideas,  ##
##    the necessary materials needed for our eggdrops to run & tcl scripts ##
##    to be released.                                                      ##
##    florian@tclscripts.net [ www.tntradio.ro ]                          ##
##                                                       ##
##  o Time2Go (Ionut) - [ #Tcl-Help Admin ] retired..                      ##
##                                                       ##
##  o zeke - our secret demon "behind the hood".                          ##
##    zeke@tclscripts.net [ www.tclscripts.net ]                          ##
##                                                       ##
#############################################################################
##                                                       ##
##          You want a customised TCL Script for your eggdrop?            ##
##              Easy-peasy, just tell us what you need!                  ##
## We can create almost anything in TCL based on your ideas and donations. ##
##    Email blackshadow@tclscripts.net or info@tclscripts.net with your    ##
##    request informations and we'll contact you as soon as possible.    ##
##                                                       ##
#############################################################################
##                                           ##
##  COMMANDS:                                                              ##
##                                           ##
##  To activate:                                                          ##
##  .chanset +checkdomain | from BlackTools: .set #channel +checkdomain    ##
##                                                                        ##
##  !dom domain - check's the set domain            ##
##  !dom save <domain1> <domain2>.. - save domains for timer check        ##
##  !dom reset - reset the domains saved ##
##  !dom status - shows the status of the saved domains                    ##
##  !dom version - shows tcl version                                      ##
##                                          ##
##                                                                        ##
#############################################################################
##                                                         ##
##  PERSONAL AND NON-COMMERCIAL USE LIMITATION.                            ##
##                                                                        ##
##  This program is provided on an "as is" and "as available" basis,      ##
##  with ABSOLUTELY NO WARRANTY. Use it at your own risk.                  ##
##                                                                        ##
##  Use this code for personal and NON-COMMERCIAL purposes ONLY.          ##
##                                                                        ##
##  Unless otherwise specified, YOU SHALL NOT copy, reproduce, sublicense, ##
##  distribute, disclose, create derivatives, in any way ANY PART OF      ##
##  THIS CONTENT, nor sell or offer it for sale.                          ##
##                                                                        ##
##  You will NOT take and/or use any screenshots of this source code for  ##
##  any purpose without the express written consent or knowledge of author.##
##                                                                        ##
##  You may NOT alter or remove any trademark, copyright or other notice  ##
##  from this source code.                                                ##
##                                                                        ##
##              Copyright 2008 - 2020 @ WwW.TCLScripts.NET                ##
##                                                                        ##
#############################################################################
 
#############################################################################
##                              CONFIGURATIONS                            ##
#############################################################################
 
###
# Cmdchar trigger
# - set here the trigger you want to use.
set infodomain(char) "!"
 
###
#Who can use the !check cmd ? (must have access)
set infodomain(flags) "mn|-"
 
###
#Set private message for when its status changes
set infodomain(prv_message) "--- Domain %domain% changed its status to %status%."
 
###
# FLOOD PROTECTION
# - set the number of minute(s) to ignore flooders (0 to disable)
###
set infodomain(ignore_prot) "1"
 
###
#Here is the flood message
set infodomain(flood_text) "Flood protection enabled. You need to wait\002 %get_seconds% seconds\002 before using commands again."
 
###
# FLOOD PROTECTION
# - set the number of !links before trigger flood protection.
# By default, 3:10, which allows for upto 3 queries in 10 seconds.
# 3 or more quries in 10 seconds would cuase the forth and later
# queries to be ignored for the amount of time specifide above.
###
set infodomain(flood_prot) "3:10"
 
##############################################################################
###        DO NOT MODIFY HERE UNLESS YOU KNOW WHAT YOU'RE DOING            ###
##############################################################################
 
package require http
package require tls
 
###
# Bindings
# + using commands
bind pub $infodomain(flags) $infodomain(char)dom domain_info:check
 
###
# Channel flags
setudef flag checkdomain
 
bind time - "00 00 * * *" domain_info:time
 
###
proc domain_info:time {minute hour day month year} {
global infodomain
set users ""
foreach user [userlist] {
set domains_saved [getuser $user XTRA check_domains]
if {$domains_saved != ""} {
lappend users [list $user $domains_saved]
}
}
if {$users != ""} {
domain_info:timer:timer_act $users 0
}
}
 
###
proc domain_info:timer:timer_act {users num} {
global infodomain
set user_line [lindex $users $num]
set user [lindex $user_line 0]
set domain_info [lindex $user_line 1]
domain_info:user_auto_check $domain_info $user 0 $num $users
}
 
###
proc domain_info:user_auto_check {domains user num user_num users} {
global infodomain
set domain_line [lindex $domains $num]
set domain [lindex $domain_line 0]
set status [lindex $domain_line 1]
set data [domain_info:data $domain]
if {$data == 0} {
set add_status "NoT ValiD TLD"
} elseif {$data == -1} {
set add_status "SiTe Error"
} else {
set add_status $data
}
set modif [domain_info:modify $domain $user $add_status]
if {$modif == 2} {
if {$add_status == "false"} {
set add_status "\0034\002Unavailable\002\003"
} elseif {$add_status == "true"} {
set add_status "\0033\002Available\002\003"
} else {
set add_status "\0034\002$add_status\002\003"
}
set nick [hand2nick $user]
set replace(%domain%) $domain
set replace(%status%) $add_status
if {$nick != ""} {
putserv "PRIVMSG $nick :[string map [array get replace] $infodomain(prv_message)]"
}
}
set incr [expr $num + 1]
if {[lindex $domains $incr] != ""} {
utimer 10 [list domain_info:user_auto_check $domains $user $incr $user_num $users]
} else {
set incr_user [expr $user_num + 1]
if {[lindex $users $incr_user] != ""} {
utimer 60 [list domain_info:timer:timer_act $users $incr_user]
}
}
}
 
###
proc domain_info:modify {domain user status} {
global infodomain
set found_type 0
set changed 0
set list [getuser $user XTRA check_domains]
set search [lsearch $list "$domain *"]
set found_dom [lindex $list $search]
set found_status [lindex $found_dom 1]
if {$found_status != $status} {
set list [lreplace $list $search $search]
set to_add [list $domain $status]
lappend list $to_add
set found_type 2
set changed 1
}
if {$found_status == ""} {set found_type 1}
if {$changed == 1} {
setuser $user XTRA check_domains $list
}
return $found_type
}
 
###
proc domain_info:check {nick host hand chan arg} {
global infodomain
set dom [lindex [split $arg] 0]
set save_domains [lrange [split $arg] 1 end]
if {![channel get $chan checkdomain]} {
return
}
if {![validuser $hand]} { return }
if {$infodomain(ignore_prot) != "0"} {
set flood_protect [infodomain:flood:prot $chan $host]
if {$flood_protect == "1"} {
set get_seconds [infodomain:get:flood_time $host $chan]
set replace(%get_seconds%) $get_seconds
putserv "NOTICE $nick :\002$nick\002: [string map [array get replace] $infodomain(flood_text)]"
return
}
}
if {[string equal -nocase $dom "version"]} {
putserv "PRIVMSG $chan :\002$infodomain(projectName) $infodomain(version)\002 coded by\002 $infodomain(author)\002 ($infodomain(email)) --\002 $infodomain(website)\002."
return
} elseif {[string equal -nocase $dom "save"]} {
if {$save_domains == ""} {
putserv "NOTICE $nick :\002Error\002: No valid domains supplied."
return
}
set valid_d ""
set invalid_d ""
set list_d ""
foreach d $save_domains {
if {[regexp {(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]} $d]} {
lappend valid_d $d
lappend list_d [list $d ""]
} else {
lappend invalid_d $d
}
}
if {$valid_d == ""} {
putserv "NOTICE $nick :Valid Domains added : N/A"
} else {
putserv "NOTICE $nick :Valid Domains added : [join $valid_d ", "]"
setuser $hand XTRA check_domains $list_d
}
if {$invalid_d != ""} {
putserv "NOTICE $nick :Invalid Domains: [join $invalid_d ", "]"
}
return
} elseif {[string equal -nocase $dom "reset"]} {
setuser $hand XTRA check_domains
putserv "NOTICE $nick :CheckDomain reset succeded."
return
} elseif {[string equal -nocase $dom "status"]} {
set domains [getuser $hand XTRA check_domains]
if {$domains == ""} {
putserv "NOTICE $nick :No domains added."
return
}
set inc 0
foreach d $domains {
incr inc
set d_name [lindex $d 0]
set d_status [lindex $d 1]
if {$d_status == ""} {
set status "\0034\002NoT Verified YeT\002\003"
} elseif {$d_status == "false"} {
set status "\0034\002Unavailable\002\003"
} elseif {$d_status == "true"} {
set status "\0033\002Available\002\003"
} else {
set status "\0034\002Error\002\003"
}
lappend d_list "\#$inc. $d_name \($status\)"
}
putserv "NOTICE $nick :[join $d_list ", "]"
return
}
if {![regexp {(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]} $dom]} {
putserv "PRIVMSG $chan :\002Error\002: Invalid specified domain supplied"
return
}
set data [domain_info:data $dom]
if {$data == "0"} {
putserv "PRIVMSG $chan :\002Error\002: Domain does not have a valid TLD."
return
} elseif {$data == "-1"} {
putserv "PRIVMSG $chan :\002Error\002: Unable to retrieve information."
return
}
if {$data == "false"} {
putserv "PRIVMSG $chan :Domain: \002$dom\002 ; Status: \0034\002Unavailable\002\003 (already registered)"
} else {
putserv "PRIVMSG $chan :Domain: \002$dom\002 ; Status: \0033\002Available\002\003 (not registered)"
}
}
 
###
proc domain_info:data {dom} {
global infodomain
set link "https://api.ip2whois.com/v1?key=free&domain=$dom"
set status -1
http::register https 443 [list ::tls::socket -autoservername true]
set ipq [http::config -useragent "lynx"]
set error [catch {set ipq [http::geturl $link -timeout 10000]} eror]
set data [http::data $ipq]
::http::cleanup $ipq
if {$error == "0"} {
regexp -nocase {"error_message":"(.*)"\}} $data -> status
if {[string equal -nocase $status "No data found."]} {return "true"} else {return false}
} else { return -1 }
}
 
###
proc infodomain:flood:prot {chan host} {
global infodomain
set number [scan $infodomain(flood_prot) %\[^:\]]
set timer [scan $infodomain(flood_prot) %*\[^:\]:%s]
if {[info exists infodomain(flood:$host:$chan:act)]} {
return 1
}
foreach tmr [utimers] {
if {[string match "*infodomain:remove:flood $host $chan*" [join [lindex $tmr 1]]]} {
killutimer [lindex $tmr 2]
}
}
if {![info exists infodomain(flood:$host:$chan)]} {
set infodomain(flood:$host:$chan) 0
}
incr infodomain(flood:$host:$chan)
utimer $timer [list infodomain:remove:flood $host $chan]
if {$infodomain(flood:$host:$chan) > $number} {
set infodomain(flood:$host:$chan:act) 1
utimer [expr $infodomain(ignore_prot) * 60] [list infodomain:expire:flood $host $chan]
return 1
} else {
return 0
}
}
 
###
proc infodomain:remove:flood {host chan} {
global infodomain
if {[info exists infodomain(flood:$host:$chan)]} {
unset infodomain(flood:$host:$chan)
}
}
 
###
proc infodomain:expire:flood {host chan} {
global infodomain
if {[info exists infodomain(flood:$host:$chan:act)]} {
unset infodomain(flood:$host:$chan:act)
}
}
 
###
proc infodomain:get:flood_time {host chan} {
global infodomain
foreach tmr [utimers] {
if {[string match "*infodomain:expire:flood $host $chan*" [join [lindex $tmr 1]]]} {
return [lindex $tmr 0]
}
}
}
 
###
# Credits
set infodomain(projectName) "CheckDomain"
set infodomain(author) "BLaCkShaDoW"
set infodomain(website) "wWw.TCLScriptS.NeT"
set infodomain(email) "blackshadow\[at\]tclscripts.net"
set infodomain(version) "v1.1"
 
putlog "\002$infodomain(projectName) $infodomain(version)\002 coded by\002 $infodomain(author)\002 ($infodomain(website)): Loaded & initialised.."
 
#######################
#######################################################################################################
###                  *** END OF CheckDomain TCL ***                                                ###
#######################################################################################################




this domain is not yet regsitered.. so it will be  Status: available

tcl
<user> !dom test.online
<bot> Domain: test.online ; Status: Unavailable (already registered)
<user> !dom test.site
<bot> Domain: test.site ; Status: Unavailable (already registered)


  Reply
#2
The service used (api.ip2whois.com) now need a key.
As it is not provided (key=free is not valid), it returns an error_code 101. This error code is not managed by the script, and you got the message the TCL will provide when the service returns an error which is not "no data found".

The script must be update to use a key.

Note that the service now provides a V2 of the API.
irc.zeolia.net - Offrez-moi un café
Merci de ne pas demander d'aide en MP
  Reply
#3
thank you @CrazyCat.  i hope @BlackShadow read this and update the scirpt..  :)))
  Reply
#4
You can try this little modification (think to create an account on ip2whois.com and fill the ip2wkey in the script with your free key)

tcl
#############################################################################
## CheckDomain.tcl 1.1  (17/10/2020)                                ##
##                                                                        ##
##                              Copyright 2008 - 2020 @ WwW.TCLScripts.NET ##
##        _  _  _  _  _  _  _  _  _  _  _  _  _  _          ##
##        / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \          ##
##      ( T | C | L | S | C | R | I | P | T | S | . | N | E | T )        ##
##        \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/          ##
##                                                                        ##
##                      ® BLaCkShaDoW Production ®                        ##
##                                                                        ##
##                                PRESENTS                                ##
##                                     ® ##
##########################  CHECK DOMAIN TCL  #############################
##                                       ##
##  DESCRIPTION:                                             ##
##  Tells you whether an Internet domain name is registered or not.        ##
##    Every valid user can have it's own list of domains that the eggdrop  ##
##    will verify using a timer and announce if something changes to them  ##
##                                                       ##
##  Tested on Eggdrop v1.8.4 (Debian Linux) Tcl version: 8.6.6            ##
##                                                       ##
#############################################################################
##                                                         ##
##  INSTALLATION:                                             ##
##  ++ http,tls packages are REQUIRED for this script to work.            ##
##  ++ Edit CheckDomain.tcl script & place it into your /scripts directory.##
##  ++ add "source scripts/CheckDomain.tcl" to your eggdrop.conf & rehash. ##
##                                                         ##
#############################################################################
##                                                       ##
##  OFFICIAL LINKS:                                                        ##
##  Bugs report : http://www.tclscripts.net                              ##
##  GitHub page : https://github.com/tclscripts/                   ##
##  Online help : irc://irc.undernet.org/tcl-help                        ##
##                #TCL-HELP / UnderNet                                  ##
##                You can ask in english or romanian                      ##
##                                                       ##
##    paypal.me/DanielVoipan = Please consider a donation. Thanks!        ##
##                                                       ##
#############################################################################
##                                                       ##
##  THE MAGIC MAKERS (TCLscripts.net's team):                              ##
##                                                                        ##
##  o BLaCkShaDoW (Daniel) - coding 'magic' maker & the botsfather.        ##
##    BLaCkShaDoW@tclscripts.net [ www.tclscripts.net ]                    ##
##                                                       ##
##  o Settore (Stefan) - generous hosting storage & bandwidth for the      ##
##    tclscripts.net project website.                                      ##
##    settore@tclscripts.net [ www.thedeveloper.site ]                    ##
##                                                       ##
##  o Florian (most craziest imagination guy) - an earful of crazy ideas,  ##
##    the necessary materials needed for our eggdrops to run & tcl scripts ##
##    to be released.                                                      ##
##    florian@tclscripts.net [ www.tntradio.ro ]                          ##
##                                                       ##
##  o Time2Go (Ionut) - [ #Tcl-Help Admin ] retired..                      ##
##                                                       ##
##  o zeke - our secret demon "behind the hood".                          ##
##    zeke@tclscripts.net [ www.tclscripts.net ]                          ##
##                                                       ##
#############################################################################
##                                                       ##
##          You want a customised TCL Script for your eggdrop?            ##
##              Easy-peasy, just tell us what you need!                  ##
## We can create almost anything in TCL based on your ideas and donations. ##
##    Email blackshadow@tclscripts.net or info@tclscripts.net with your    ##
##    request informations and we'll contact you as soon as possible.    ##
##                                                       ##
#############################################################################
##                                           ##
##  COMMANDS:                                                              ##
##                                           ##
##  To activate:                                                          ##
##  .chanset +checkdomain | from BlackTools: .set #channel +checkdomain    ##
##                                                                        ##
##  !dom domain - check's the set domain            ##
##  !dom save <domain1> <domain2>.. - save domains for timer check        ##
##  !dom reset - reset the domains saved ##
##  !dom status - shows the status of the saved domains                    ##
##  !dom version - shows tcl version                                      ##
##                                          ##
##                                                                        ##
#############################################################################
##                                                         ##
##  PERSONAL AND NON-COMMERCIAL USE LIMITATION.                            ##
##                                                                        ##
##  This program is provided on an "as is" and "as available" basis,      ##
##  with ABSOLUTELY NO WARRANTY. Use it at your own risk.                  ##
##                                                                        ##
##  Use this code for personal and NON-COMMERCIAL purposes ONLY.          ##
##                                                                        ##
##  Unless otherwise specified, YOU SHALL NOT copy, reproduce, sublicense, ##
##  distribute, disclose, create derivatives, in any way ANY PART OF      ##
##  THIS CONTENT, nor sell or offer it for sale.                          ##
##                                                                        ##
##  You will NOT take and/or use any screenshots of this source code for  ##
##  any purpose without the express written consent or knowledge of author.##
##                                                                        ##
##  You may NOT alter or remove any trademark, copyright or other notice  ##
##  from this source code.                                                ##
##                                                                        ##
##              Copyright 2008 - 2020 @ WwW.TCLScripts.NET                ##
##                                                                        ##
#############################################################################
 
#############################################################################
##                              CONFIGURATIONS                            ##
#############################################################################
 
###
# Cmdchar trigger
# - set here the trigger you want to use.
set infodomain(char) "!"
 
###
#Who can use the !check cmd ? (must have access)
set infodomain(flags) "mn|-"
 
###
#Set private message for when its status changes
set infodomain(prv_message) "--- Domain %domain% changed its status to %status%."
 
###
# FLOOD PROTECTION
# - set the number of minute(s) to ignore flooders (0 to disable)
###
set infodomain(ignore_prot) "1"
 
###
#Here is the flood message
set infodomain(flood_text) "Flood protection enabled. You need to wait\002 %get_seconds% seconds\002 before using commands again."
 
###
# ip2whois key
set ip2wkey "AZERTYUIOP"
 
###
# FLOOD PROTECTION
# - set the number of !links before trigger flood protection.
# By default, 3:10, which allows for upto 3 queries in 10 seconds.
# 3 or more quries in 10 seconds would cuase the forth and later
# queries to be ignored for the amount of time specifide above.
###
set infodomain(flood_prot) "3:10"
 
##############################################################################
###        DO NOT MODIFY HERE UNLESS YOU KNOW WHAT YOU'RE DOING            ###
##############################################################################
 
package require http
package require tls
 
###
# Bindings
# + using commands
bind pub $infodomain(flags) $infodomain(char)dom domain_info:check
 
###
# Channel flags
setudef flag checkdomain
 
bind time - "00 00 * * *" domain_info:time
 
###
proc domain_info:time {minute hour day month year} {
	global infodomain
	set users ""
	foreach user [userlist] {
		set domains_saved [getuser $user XTRA check_domains]
		if {$domains_saved != ""} {
			lappend users [list $user $domains_saved]
		}
	}
	if {$users != ""} {
		domain_info:timer:timer_act $users 0
	}
}
 
###
proc domain_info:timer:timer_act {users num} {
	global infodomain
	set user_line [lindex $users $num]
	set user [lindex $user_line 0]
	set domain_info [lindex $user_line 1]
	domain_info:user_auto_check $domain_info $user 0 $num $users
}
 
###
proc domain_info:user_auto_check {domains user num user_num users} {
	global infodomain
	set domain_line [lindex $domains $num]
	set domain [lindex $domain_line 0]
	set status [lindex $domain_line 1]
	set data [domain_info:data $domain]
	if {$data == 0} {
		set add_status "NoT ValiD TLD"
	} elseif {$data == -1} {
		set add_status "SiTe Error"
	} else {
		set add_status $data
	}
	set modif [domain_info:modify $domain $user $add_status]
	if {$modif == 2} {
		if {$add_status == "false"} {
			set add_status "\0034\002Unavailable\002\003"
		} elseif {$add_status == "true"} {
			set add_status "\0033\002Available\002\003"
		} else {
			set add_status "\0034\002$add_status\002\003"
		}
		set nick [hand2nick $user]
		set replace(%domain%) $domain
		set replace(%status%) $add_status
		if {$nick != ""} {
			putserv "PRIVMSG $nick :[string map [array get replace] $infodomain(prv_message)]"
		}
	}
	set incr [expr $num + 1]
	if {[lindex $domains $incr] != ""} {
		utimer 10 [list domain_info:user_auto_check $domains $user $incr $user_num $users]
	} else {
		set incr_user [expr $user_num + 1]
		if {[lindex $users $incr_user] != ""} {
			utimer 60 [list domain_info:timer:timer_act $users $incr_user]
		}
	}
}
 
###
proc domain_info:modify {domain user status} {
	global infodomain
	set found_type 0
	set changed 0
	set list [getuser $user XTRA check_domains]
	set search [lsearch $list "$domain *"]
	set found_dom [lindex $list $search]
	set found_status [lindex $found_dom 1]
	if {$found_status != $status} {
		set list [lreplace $list $search $search]
		set to_add [list $domain $status]
		lappend list $to_add
		set found_type 2
		set changed 1
	}
	if {$found_status == ""} {set found_type 1}
	if {$changed == 1} {
		setuser $user XTRA check_domains $list
	}
	return $found_type
}
 
###
proc domain_info:check {nick host hand chan arg} {
	global infodomain
	set dom [lindex [split $arg] 0]
	set save_domains [lrange [split $arg] 1 end]
	if {![channel get $chan checkdomain]} {
		return
	}
	if {![validuser $hand]} { return }
	if {$infodomain(ignore_prot) != "0"} {
		set flood_protect [infodomain:flood:prot $chan $host]
		if {$flood_protect == "1"} {
			set get_seconds [infodomain:get:flood_time $host $chan]
			set replace(%get_seconds%) $get_seconds
			putserv "NOTICE $nick :\002$nick\002: [string map [array get replace] $infodomain(flood_text)]"
			return
		}
	}
	if {[string equal -nocase $dom "version"]} {
		putserv "PRIVMSG $chan :\002$infodomain(projectName) $infodomain(version)\002 coded by\002 $infodomain(author)\002 ($infodomain(email)) --\002 $infodomain(website)\002."
		return
	} elseif {[string equal -nocase $dom "save"]} {
		if {$save_domains == ""} {
			putserv "NOTICE $nick :\002Error\002: No valid domains supplied."
			return
		}
		set valid_d ""
		set invalid_d ""
		set list_d ""
		foreach d $save_domains {
			if {[regexp {(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]} $d]} {
				lappend valid_d $d
				lappend list_d [list $d ""]
			} else {
				lappend invalid_d $d
			}
		}
		if {$valid_d == ""} {
			putserv "NOTICE $nick :Valid Domains added : N/A"
		} else {
			putserv "NOTICE $nick :Valid Domains added : [join $valid_d ", "]"
			setuser $hand XTRA check_domains $list_d
		}
		if {$invalid_d != ""} {
			putserv "NOTICE $nick :Invalid Domains: [join $invalid_d ", "]"
		}
		return
	} elseif {[string equal -nocase $dom "reset"]} {
		setuser $hand XTRA check_domains
		putserv "NOTICE $nick :CheckDomain reset succeded."
		return
	} elseif {[string equal -nocase $dom "status"]} {
		set domains [getuser $hand XTRA check_domains]
		if {$domains == ""} {
			putserv "NOTICE $nick :No domains added."
			return
		}
		set inc 0
		foreach d $domains {
			incr inc
			set d_name [lindex $d 0]
			set d_status [lindex $d 1]
			if {$d_status == ""} {
				set status "\0034\002NoT Verified YeT\002\003"
			} elseif {$d_status == "false"} {
				set status "\0034\002Unavailable\002\003"
			} elseif {$d_status == "true"} {
				set status "\0033\002Available\002\003"
			} else {
				set status "\0034\002Error\002\003"
			}
			lappend d_list "\#$inc. $d_name \($status\)"
		}
		putserv "NOTICE $nick :[join $d_list ", "]"
		return
	}
	if {![regexp {(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]} $dom]} {
		putserv "PRIVMSG $chan :\002Error\002: Invalid specified domain supplied"
		return
	}
	set data [domain_info:data $dom]
	if {$data == "0"} {
		putserv "PRIVMSG $chan :\002Error\002: Domain does not have a valid TLD."
		return
	} elseif {$data == "-1"} {
		putserv "PRIVMSG $chan :\002Error\002: Unable to retrieve information."
		return
	}
	if {$data == "false"} {
		putserv "PRIVMSG $chan :Domain: \002$dom\002 ; Status: \0034\002Unavailable\002\003 (already registered)"
	} else {
		putserv "PRIVMSG $chan :Domain: \002$dom\002 ; Status: \0033\002Available\002\003 (not registered)"
	}
}
 
###
proc domain_info:data {dom} {
	global infodomain
	set link "https://api.ip2whois.com/v2?key=$::ip2wkey&domain=$dom"
	set status -1
	http::register https 443 [list ::tls::socket -autoservername true]
	set ipq [http::config -useragent "lynx"]
	set error [catch {set ipq [http::geturl $link -timeout 10000]} eror]
	set data [http::data $ipq]
	::http::cleanup $ipq
	if {$error == "0"} {
		regexp -nocase {"error_message":"(.*)"\}} $data -> status
		if {[string equal -nocase $status "No data found."]} {return "true"} else {return false}
	} else { return -1 }
}
 
###
proc infodomain:flood:prot {chan host} {
	global infodomain
	set number [scan $infodomain(flood_prot) %\[^:\]]
	set timer [scan $infodomain(flood_prot) %*\[^:\]:%s]
	if {[info exists infodomain(flood:$host:$chan:act)]} {
		return 1
	}
	foreach tmr [utimers] {
		if {[string match "*infodomain:remove:flood $host $chan*" [join [lindex $tmr 1]]]} {
			killutimer [lindex $tmr 2]
		}
	}
	if {![info exists infodomain(flood:$host:$chan)]} {
		set infodomain(flood:$host:$chan) 0
	}
	incr infodomain(flood:$host:$chan)
	utimer $timer [list infodomain:remove:flood $host $chan]
	if {$infodomain(flood:$host:$chan) > $number} {
		set infodomain(flood:$host:$chan:act) 1
		utimer [expr $infodomain(ignore_prot) * 60] [list infodomain:expire:flood $host $chan]
		return 1
	} else {
		return 0
	}
}
 
###
proc infodomain:remove:flood {host chan} {
	global infodomain
	if {[info exists infodomain(flood:$host:$chan)]} {
		unset infodomain(flood:$host:$chan)
	}
}
 
###
proc infodomain:expire:flood {host chan} {
	global infodomain
	if {[info exists infodomain(flood:$host:$chan:act)]} {
		unset infodomain(flood:$host:$chan:act)
	}
}
 
###
proc infodomain:get:flood_time {host chan} {
	global infodomain
	foreach tmr [utimers] {
		if {[string match "*infodomain:expire:flood $host $chan*" [join [lindex $tmr 1]]]} {
			return [lindex $tmr 0]
		}
	}
}
 
###
# Credits
set infodomain(projectName) "CheckDomain"
set infodomain(author) "BLaCkShaDoW"
set infodomain(website) "wWw.TCLScriptS.NeT"
set infodomain(email) "blackshadow\[at\]tclscripts.net"
set infodomain(version) "v1.1"
 
putlog "\002$infodomain(projectName) $infodomain(version)\002 coded by\002 $infodomain(author)\002 ($infodomain(website)): Loaded & initialised.."
 
#######################
#######################################################################################################
###                  *** END OF CheckDomain TCL ***                                                ###
#######################################################################################################


irc.zeolia.net - Offrez-moi un café
Merci de ne pas demander d'aide en MP
  Reply
#5
thanks CrazyCat, is it working now..
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)