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.

Client connections script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
FmX
Voice
Posts: 39
Joined: Wed Dec 06, 2006 12:42 pm

Client connections script

Post by FmX »

Hello. Does anyone have a script that shows clients connecting to the server in a channel with the user's nick, ip and location? Thank you very much.
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Client connections script

Post by CrazyCat »

I've a script working with unrealircd:
package require http
bind raw - NOTICE ipcheck
proc ipcheck {frm key text} {
   if {[string match *!*@* $frm] || ![string match -nocase "*client connecting*" $text]} {
      return
   }
   regexp {:\ ([^ ]+)\s\(([^@]+)@([^\)])+\)\s\[([^\]]+)} $text - unick ident host ip
   set data [getipdatas $ip]
   if {[dict get $data status] eq "success"} {
      set country [encoding convertfrom utf-8 [dict get $data country]]
      putserv "PRIVMSG #logger :$unick ($ip) is connecting from $country"
   }
}

proc getipdatas { ip } {
	::http::config -useragent "lynx"
	set ipq [http::geturl http://ip-api.com/json/$ip?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query&lang=fr]
	set data [json2dict [http::data $ipq]]
	::http::cleanup $ipq
	return $data
}
Note that your eggdrop must be ircop and must have +scC snomask.
User avatar
FmX
Voice
Posts: 39
Joined: Wed Dec 06, 2006 12:42 pm

Re: Client connections script

Post by FmX »

I have this error:
Tcl error [ipcheck]: invalid command name "json2dict"

yes, bot is irc op.
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Client connections script

Post by CrazyCat »

Sorry, I forget:
package require json
User avatar
FmX
Voice
Posts: 39
Joined: Wed Dec 06, 2006 12:42 pm

Re: Client connections script

Post by FmX »

I make it this way and its working:
proc getipdatas {ip} {
    ::http::config -useragent "lynx"
    set ipq [http::geturl http://ip-api.com/json/$ip?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query&lang=fr]
    set jsonData [http::data $ipq]

    set data [json::json2dict $jsonData]

    ::http::cleanup $ipq

    return $data
}
also include
package require json
Post Reply