Mise en forme de code: pensez à utiliser les balises [ tcl ] et [ /tcl ] (sans les espaces bien sûr) autour de vos codes tcl afin d'avoir un meilleur rendu et une coloration syntaxique. x


[Script] Flood & Protect
#31
Voici un petit code rapide, fait avec les divers éléments de cette discussion et d'autres du forum:

tcl
set ipfile "myips.txt"
 
set ips {}
 
bind pub - .ipadd ipadd
bind pub - .ipdel ipdel
bind raw - NOTICE proxy:connect
 
set mask {^(?:25[0-5]|2[0-4]\d|[0-1]?\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|[0-1]?\d{1,2})){3}$}
 
proc proxy:connect {from keyword text} {
	if {[string match -nocase "*Client connecting*" $text]} {
		regexp {\:\ (.*)\ \((.*?)@(.*?)\)} $text matching nick username ip
		if {[lsearch $::ips $ip] != -1} {
			putserv "PRIVMSG #opers :Pas de test pour $ip : dans la base d'exemption"
			return
		}
		set data [getipdatas $ip]
		set Getquery [dict get $data query]
		set Getcountry [dict get $data country]
		set GetcountryCode [dict get $data countryCode]
		set Getcity [dict get $data city]
		set Getisp [dict get $data isp]
		set Getas [dict get $data as]
		set Getreverse [dict get $data reverse]
		if {[dict get $data status] eq "success"} {
			if {[dict get $data proxy] eq "true"} {
				putserv "PRIVMSG #opers :\00304Gline Proxy/Vpn\003 $ip ($Getcity $Getcountry)"
				putquick "GLINE *@$ip +1d :Proxy/VPN $Getcountry"
			}
		}
	}
}
 
proc ipadd {nick uhost handle chan text} {
	if {![regexp $::mask $text ipv4]} {
		putserv "PRIVMSG $nick :$text n'est pas une IP valide"
		return
	}
	if {[lsearch $::ips $text]==-1} {
		lappend ::ips $text
	}
	writeip
}
 
proc ipdel {nick uhost handle chan text} {
	if {[lsearch $::ips $text]!=-1} { 
		lreplace ::ips [lsearch $::ips $text] [lsearch $::ips $text]
	}
	writeip
}
 
proc writeip {} {
  set fo [open $::ipfile w]
  puts $fo [join $::ips "\n"]
  close $fo
}
 
proc readip {} {
	set fi [open $::ipfile r]
	set ::ips [split [read -nonewline $fi] "\n"]
	close $fi
}
 
proc json2dict {JSONtext} {
	string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
}
 
proc getipdatas { ip } {
	::http::config -useragent "lynx"
	set ipq [http::geturl http://ip-api.com/json/$ip?fields=status,message,continent,country,countryCode,region,regionName,city,zip,lat,lon,timezone,currency,isp,org,as,reverse,mobile,proxy,hosting,query&lang=en]
	set data [json2dict [http::data $ipq]]
	::http::cleanup $ipq
	return $data
}
 
readip


Ce n'est pas testé mais il ne devrait pas y avoir de gros bug dedans
irc.zeolia.net - Offrez-moi un café
Merci de ne pas demander d'aide en MP
  Reply


Messages In This Thread
Flood & Protect - by uDc - 17/12/2021, 21:14
RE: Flood & Protect - by CrazyCat - 17/12/2021, 23:27
RE: Flood & Protect - by uDc - 22/12/2021, 21:35
RE: Flood & Protect - by uDc - 18/12/2021, 22:45
RE: Flood & Protect - by CrazyCat - 21/12/2021, 17:28
RE: Flood & Protect - by uDc - 21/12/2021, 20:15
RE: Flood & Protect - by Amand - 22/12/2021, 21:53
RE: Flood & Protect - by uDc - 23/12/2021, 10:34
RE: Flood & Protect - by CrazyCat - 23/12/2021, 11:00
RE: Flood & Protect - by uDc - 23/12/2021, 11:37
RE: Flood & Protect - by CrazyCat - 23/12/2021, 14:00
RE: Flood & Protect - by uDc - 23/12/2021, 18:33
RE: Flood & Protect - by Amand - 23/12/2021, 18:33
RE: Flood & Protect - by CrazyCat - 23/12/2021, 18:42
RE: Flood & Protect - by uDc - 23/12/2021, 21:56
RE: Flood & Protect - by CrazyCat - 24/12/2021, 14:24
RE: Flood & Protect - by uDc - 25/12/2021, 14:21
RE: Flood & Protect - by CrazyCat - 25/12/2021, 19:12
RE: Flood & Protect - by Amand - 26/12/2021, 09:45
RE: Flood & Protect - by uDc - 29/12/2021, 22:15
RE: Flood & Protect - by Amand - 30/12/2021, 00:26
RE: Flood & Protect - by uDc - 13/01/2022, 17:29
RE: Flood & Protect - by CrazyCat - 13/01/2022, 18:51
RE: Flood & Protect - by uDc - 13/01/2022, 19:39
RE: Flood & Protect - by CrazyCat - 13/01/2022, 20:00
RE: Flood & Protect - by uDc - 13/01/2022, 21:44
RE: Flood & Protect - by CrazyCat - 14/01/2022, 00:50
RE: Flood & Protect - by uDc - 14/01/2022, 09:55
RE: Flood & Protect - by CrazyCat - 14/01/2022, 11:22
RE: Flood & Protect - by uDc - 14/01/2022, 11:28
RE: Flood & Protect - by CrazyCat - 14/01/2022, 12:20
RE: Flood & Protect - by uDc - 14/01/2022, 18:40
RE: Flood & Protect - by uDc - 14/01/2022, 22:03
RE: Flood & Protect - by CrazyCat - 15/01/2022, 01:49

Possibly Related Threads…
Thread Author Replies Views Last Post
  Protect /oper IluZi0n 1 3,556 05/02/2010, 23:59
Last Post: fedora

Forum Jump:


Users browsing this thread: 1 Guest(s)