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.

raw on connect

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

ComputerTech wrote:Ok, but didnt caesar use heartbroken's clde as well? and got a error

but i will do that and find out whats wrong, then post here :)

Cheers CrazyCat
caesar uses what he wants, caesar didn't said he had a trouble with this script, caesar made a test (to help you?) and throw an error.
YOU have a trouble with your script, so we are looking for an answer to YOUR trouble.

I think caesar is able to say himself if he has a trouble with a script, and he's also able to well describe it, and to find the solution. caesar has rarely trouble, he has often solutions.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I used the link in the code with a random IP, then went on the website and tried the examples they give in the documentation page and i got the error I mentioned above. I concluded at the time it's a error on their side since I wasn't the only one that was apparently getting that error. Anyway...
Once the game is over, the king and the pawn go back in the same box.
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Tested simply:

Code: Select all

crazycat@raspbian:~$ curl http://ip-api.com/json/178.132.216.199?fields=status,city,isp,country,query,regionName,countryCode
{"status":"success","country":"Kosovo","countryCode":"XK","regionName":"Pristina","city":"Pristina","isp":"Kujtesa Network","query":"178.132.216.199"}
It works fine

And the examples given in https://ip-api.com/docs/api:json are all working. And all are using http, not https.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Opening the link you mentioned in Firefox on Windows gives me a {status: "fail"} reply, but if where to use the same curl in Linux it works just fine, meaning getting the same result.
Once the game is over, the king and the pawn go back in the same box.
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

It works for me:
Image

Don't you use a plugin like https everywhere which forces https in firefox ?

BTW, I alway test with curl the url used by eggdrop, browsers can create errors :)
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Sorry for delayed reply, been busy with farming, fixing stuff, etc.

thing i dont understand is, i litteraly havent changed anything in the bot, nor script, just one day it stopped *shrug*. So not even sure where to start tbh :?

So as i understand, it's the code thats not working correct?
ComputerTech
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

If the code worked and you didn't change it, it's correct.
So, you have to add debug lines to know what is exactly doing the script and where it's blocking.
G
Gulio
Halfop
Posts: 74
Joined: Sun Nov 01, 2020 11:53 am

Hello

Post by Gulio »

Try this, u can add same every info u want to get for output msg

Code: Select all


Connect >> Nick: X - IP: 192.184.9.108 - COUNTRY: United States - CODE: US - CITY: Los Angeles - ORG: Level 3, LLC - ASN: AS32421 Level 3 Parent, LLC - ASNAME: BLCC - REVERSE: highgate.irccloud.com - MOBILE: false - PROXY: false

Code: Select all


package require http
package require json

set ExpChan "#Connect"

bind raw - NOTICE Client_Connect

proc json2dict {JSONtext} {
	string range [string trim [string trimleft [string map {\t {} \n {} \r {} , { } : { } \[ \{ \] \}} $JSONtext] {\uFEFF}]] 1 end-1
}

proc Client_Connect {from key arg} {
	if {[string match *!*@* $from] || ![string match -nocase "*client connecting*" $arg]} { return }
	if {[scan $arg %\[^\:\]\:%\[^(\](%\[^@\]@%\[^\)\] _ nick ident host] == "4"} {
		::http::config -useragent "lynx"
		set ipq [http::geturl http://ip-api.com/json/$host?fields=status,message,country,countryCode,city,org,as,asname,reverse,mobile,proxy,query]
		set    data                  [json2dict [http::data $ipq]]
		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    Getorg                [dict get $data org]
		set    Getas                 [dict get $data as]
		set    Getasname             [dict get $data asname]
		set    Getreverse            [dict get $data reverse]
		set    Getmobile             [dict get $data mobile]
		set    Getproxy              [dict get $data proxy]
		::http::cleanup $ipq
		if {[dict get $data status] eq "success"} {


			puthelp "PRIVMSG $::ExpChan :\0033Connected \00314>> \00310Nick\0036:\00314 [regsub -all {([^:]+:)} $nick ""]\0036- \0033IP:\00314 $Getquery \0036- \0033COUNTRY:\00314 $Getcountry \0036- \0033CODE:\00314 $GetcountryCode \0036- \0033CITY:\00314 $Getcity \0036- \0033ORG:\00314 $Getorg \0036- \0033ASN:\00314 $Getas \0036- \0033ASNAME:\00314 $Getasname \0036- \0033REVERSE:\00314 $Getreverse \0036- \0033MOBILE:\00314 $Getmobile \0036- \0033PROXY:\00314 $Getproxy "
		} else {
			putcmdlog "Error! it fails to get data for this $host"
		}
	}
	return 0
}

User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Thanks Gulio! will try that right away :D
ComputerTech
s
sashafire
Voice
Posts: 1
Joined: Thu Nov 05, 2020 8:29 am

Post by sashafire »

I am so glad I found this as it fixed my issue... Thanks a lot to everyone who's keeping the forum alive and merci CrazyCat for helping this. This means a lot.

Quick question, how confident are we in the location data quality for ip-api? I'm thinking about using other services like geojs.io or abstractapi.com/ip-geolocation-api but their free plans are limited :(
---
Experience is the name everyone gives to their mistakes.
G
Gulio
Halfop
Posts: 74
Joined: Sun Nov 01, 2020 11:53 am

hi

Post by Gulio »

ip-api is better from those u write above have real db and show same as what is my ip address so dont worry u can use without problem.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Keep in mind that ip-api has a max 45 HTTP requests per minute from an IP address and the FREE service they provide isn't for commercial use, you got paid plans for that. Should consult their website.
Once the game is over, the king and the pawn go back in the same box.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

There is one, Unrealircd third party module *geo-base* uses, to show the user connecting country, i will find the link for you guys :D, as far as i see, it has no limit *shrug*

ps, Nice new avatar caesar :P
ComputerTech
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

I think the unreal module use the geolite database from maxmind (must be downloaded), not an http query.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Ah, you are correct CrazyCat, but cant the geolite used in the eggdrop dir? same as unreal :?
ComputerTech
Post Reply