This repository has been archived on 2023-04-13. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
CloudBot/disabled_stuff/domainr.py

19 lines
780 B
Python
Raw Permalink Normal View History

2013-09-01 23:00:40 -06:00
from util import hook, http
2013-09-04 18:30:04 +08:00
2013-09-01 23:00:40 -06:00
@hook.command
def domainr(inp):
"""domainr <domain> - Use domain.nr's API to search for a domain, and similar domains."""
try:
2013-09-04 18:30:04 +08:00
data = http.get_json('http://domai.nr/api/json/search?q=' + inp)
2013-09-01 23:00:40 -06:00
except (http.URLError, http.HTTPError) as e:
return "Unable to get data for some reason. Try again later."
if data['query'] == "":
2014-02-13 14:34:50 +13:00
return "An error occurred: {status} - {message}".format(**data['error'])
2013-09-04 18:30:04 +08:00
domains = ""
2013-09-01 23:00:40 -06:00
for domain in data['results']:
2013-09-04 18:30:04 +08:00
domains += ("\x034" if domain['availability'] == "taken" else (
2014-02-14 17:03:08 +13:00
"\x033" if domain['availability'] == "available" else "\x031")) + domain['domain'] + "\x0f" + domain[
'path'] + ", "
2013-09-01 23:00:40 -06:00
return "Domains: " + domains