-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.0.0 Just moved all cactive files into one repo
- Loading branch information
Showing
18 changed files
with
235 additions
and
35 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
### What is this? | ||
This is a collection of Cactive's NPM Modules rewritten in Python | ||
|
||
### How to install and use? | ||
First, by using these modules you agree to our LICENSE: https://github.com/CactiveNetwork/cactive-rewrites/tree/main/python/LICENSE.md | ||
|
||
Install: | ||
```bash | ||
pip install cactive | ||
``` | ||
|
||
To find out the documentation for all modules please type: | ||
```python | ||
import cactive | ||
|
||
cactive.get_started() | ||
``` | ||
|
||
### PyPI | ||
https://pypi.org/project/cactive |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Hypixel Nick Tracker and ip-python | ||
requests==2.28.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
[metadata] | ||
name = cactive-hypixel-nick-tracker | ||
name = cactive | ||
description_file=README.md | ||
license_files=LICENSE.md | ||
version = 3.0.6 | ||
version = 1.0.0 | ||
author = Cactive | ||
author_email = [email protected] | ||
description = Wrapper for the exclusive CactiveNetwork unofficial Hypixel API. | ||
description = All of the Cactive NPM modules rewritten in Python | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/CactiveNetwork/cactive-rewrites/tree/main/python/hypixel-nick-tracker | ||
url = https://github.com/CactiveNetwork/cactive-rewrites/tree/main/python/ | ||
project_urls = | ||
Bug Tracker = https://github.com/CactiveNetwork/cactive-rewrites/tree/main/python/hypixel-nick-tracker/issues | ||
Bug Tracker = https://github.com/CactiveNetwork/cactive-rewrites/tree/main/python/issues | ||
classifiers = | ||
Programming Language :: Python :: 3 | ||
License :: Other/Proprietary License | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
__version__ = "1.0.0" | ||
|
||
print("By using Cactive's Python Rewrites, you agree to follow this LICENSE: https://github.com/CactiveNetwork/cactive-rewrites/tree/main/python/LICENSE.md") | ||
|
||
from . import hypixel_nick_tracker | ||
from . import ip | ||
|
||
def get_started() -> None: | ||
''' | ||
Prints documentation for each module | ||
''' | ||
|
||
print("Documentation for ip is here: https://github.com/CactiveNetwork/cactive-rewrites/blob/main/python/src/cactive/ip/README.md") | ||
print("Documentation for hypixel-nick-tracker is here: https://github.com/CactiveNetwork/cactive-rewrites/blob/main/python/src/cactive/hypixel_nick_tracker/README.md") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Cactive IP API (Python) | ||
|
||
--- | ||
|
||
### API Information: | ||
|
||
This is a free to use API hosted in Melbourne, Australia that provides detailed information of IP addresses. | ||
|
||
You can request the API through the HTTP or HTTPS protocol and the `GET` method at [ip.cactive.co/api/lookup/](https://ip.cactive.co/api/lookup/). | ||
|
||
You can either provide an IP address with `/api/lookup/[ip]` or leave it blank to get the IP address of the requester. | ||
|
||
**Example:** https://ip.cactive.co/api/lookup/8.8.8.8 | ||
|
||
--- | ||
|
||
### Installation: | ||
|
||
```bash | ||
pip install cactive-ip | ||
``` | ||
|
||
### Usage: | ||
|
||
```python | ||
import cactive.ip as ip | ||
|
||
def examples(): | ||
# Get the IP address of the client | ||
self = ip.self() | ||
print(self.ip) # eg: 192.168.0.1 | ||
|
||
# Get the time zone of a domain, IPv4 or IPv6 | ||
external = ip.retrieve("cactive.cloud") | ||
print(external.time_zone) # eg: Australia/Melbourne | ||
|
||
examples() | ||
``` | ||
|
||
### Data Schema: | ||
|
||
| Field | Type | Example | | ||
|--------------------|----------------|---------------------| | ||
| `ip` | String | `8.8.8.8` | | ||
| `city` | String or None | `Ashburn` | | ||
| `state` | String or None | `Virginia` | | ||
| `state_code` | String or None | `VA` | | ||
| `country` | String or None | `United States` | | ||
| `country_code` | String or None | `US` | | ||
| `country_currency` | String or None | `USD` | | ||
| `continent` | String or None | `North America` | | ||
| `continent_code` | String or None | `NA` | | ||
| `post_code` | String or None | `20149` | | ||
| `time_zone` | String or None | `America/New_York` | | ||
| `latitude` | Number or None | `39.03` | | ||
| `longitude` | Number or None | `-77.5` | | ||
| `reverse_dns` | String or None | `dns.google` | | ||
| `isp` | String or None | `Google LLC` | | ||
| `isp_org` | String or None | `Google Public DNS` | | ||
| `as_number` | String or None | `AS15169` | | ||
| `as_name` | String or None | `GOOGLE` | | ||
| `as_org` | String or None | `Google LLC` | | ||
| `detection_vpn` | Boolean | `false` | | ||
| `detection_server` | Boolean | `true` | | ||
| `detection_mobile` | Boolean | `false` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
from requests import get, Response | ||
from json import loads, dumps | ||
|
||
from typing import Union | ||
|
||
|
||
class IPData: | ||
''' | ||
The class which holds all IPData | ||
''' | ||
|
||
def __init__( | ||
self, | ||
ip: str, | ||
city: Union[str, None], | ||
state: Union[str, None], | ||
state_code: Union[str, None], | ||
country: Union[str, None], | ||
country_code: Union[str, None], | ||
country_currency: Union[str, None], | ||
continent: Union[str, None], | ||
continent_code: Union[str, None], | ||
post_code: Union[str, None], | ||
time_zone: Union[str, None], | ||
latitude: Union[float, None], | ||
longitude: Union[float, None], | ||
reverse_dns: Union[str, None], | ||
isp: Union[str, None], | ||
isp_org: Union[str, None], | ||
as_number: Union[str, None], | ||
as_name: Union[str, None], | ||
as_org: Union[str, None], | ||
detection_vpn: bool, | ||
detection_server: bool, | ||
detection_mobile: bool, | ||
) -> None: | ||
self.ip = ip | ||
self.city = city | ||
self.state = state | ||
self.state_code = state_code | ||
self.country = country | ||
self.country_code = country_code | ||
self.country_currency = country_currency | ||
self.continent = continent | ||
self.continent_code = continent_code | ||
self.post_code = post_code | ||
self.time_zone = time_zone | ||
self.latitude = latitude | ||
self.longitude = longitude | ||
self.reverse_dns = reverse_dns | ||
self.isp = isp | ||
self.isp_org = isp_org | ||
self.as_number = as_number | ||
self.as_name = as_name | ||
self.as_org = as_org | ||
self.detection_vpn = detection_vpn | ||
self.detection_server = detection_server | ||
self.detection_mobile = detection_mobile | ||
|
||
def __str__(self) -> str: | ||
return dumps(self.__dict__) | ||
|
||
|
||
class IPError(Exception): | ||
''' | ||
Custom exception for errors in IPData | ||
''' | ||
|
||
def __init__(self, error: str) -> None: | ||
Exception.__init__(self, error) | ||
|
||
|
||
def fetch(ip: Union[str, None]) -> IPData: | ||
''' | ||
Do not call this function directly. Please use self or retrieve | ||
''' | ||
|
||
ip = ip if ip is not None else "" | ||
|
||
r: Response = get(f"https://ip.cactive.co/api/lookup/{ip}") | ||
d: dict = loads(r.text) | ||
|
||
if "errors" in d: | ||
raise IPError(d["errors"][0]["message"]) | ||
return IPData(*d.values()) | ||
|
||
|
||
def self() -> IPData: | ||
''' | ||
Get the IP data for yourself | ||
''' | ||
|
||
return fetch(None) | ||
|
||
|
||
def retrieve(ip: str) -> IPData: | ||
''' | ||
Get IP data for another IP address | ||
''' | ||
|
||
return fetch(ip) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import cactive | ||
|
||
cactive.get_started() |
File renamed without changes.