diff --git a/sopel_modules/SpiceBot/Sherlock.py b/sopel_modules/SpiceBot/Sherlock.py new file mode 100644 index 0000000..43b6dfa --- /dev/null +++ b/sopel_modules/SpiceBot/Sherlock.py @@ -0,0 +1,89 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +"""A way to search google""" + +import sopel_modules + +from .Tools import read_directory_json_to_dict + +import os +from fake_useragent import UserAgent +import requests +import time + + +class Sherlock(): + + def __init__(self): + self.header = {'User-Agent': str(UserAgent().chrome)} + self.dict = {} + + dir_to_scan = [] + for plugin_dir in set(sopel_modules.__path__): + configsdir = os.path.join(plugin_dir, "SpiceBot_Configs") + usercfgdir = os.path.join(configsdir, "sherlock") + dir_to_scan.append(usercfgdir) + + valid_usernames_dict = read_directory_json_to_dict(dir_to_scan, "Gif API", "SpiceBot_Gif") + + for social_network in list(valid_usernames_dict.keys()): + self.dict[social_network] = valid_usernames_dict[social_network] + self.dict[social_network]["cache"] = dict() + + def check_network(self, username, social_network): + + if username in list(self.dict[social_network]["cache"].keys()): + if time.time() - self.dict[social_network]["cache"][username]["time"] <= 1800: + return self.dict[social_network]["cache"][username]["exists"] + + url = self.dict.get(social_network).get("url").format(username) + error_type = self.dict.get(social_network).get("errorType") + cant_have_period = self.dict.get(social_network).get("noPeriod") + + if ("." in username) and (cant_have_period == "True"): + while ("." in username): + username = username.replace(".", '') + + r, error_type = self.make_request(url=url, error_type=error_type, social_network=social_network) + + user_exists = False + + if error_type == "message": + error = self.dict.get(social_network).get("errorMsg") + # Checks if the error message is in the HTML + if error not in r.text: + user_exists = True + + elif error_type == "status_code": + # Checks if the status code of the repsonse is 404 + if not r.status_code == 404: + user_exists = True + + elif error_type == "response_url": + error = self.dict.get(social_network).get("errorUrl") + # Checks if the redirect url is the same as the one defined in data.json + if error not in r.url: + user_exists = True + + self.dict[social_network]["cache"][username] = { + "time": time.time(), + "exists": user_exists + } + + if user_exists: + return True + else: + return False + + def make_request(self, url, error_type, social_network): + try: + r = requests.get(url, headers=self.header) + if r.status_code: + return r, error_type + except Exception as e: + returnval = e + returnval = None + return returnval, "" + + +sherlock = Sherlock() diff --git a/sopel_modules/SpiceBot/Tools.py b/sopel_modules/SpiceBot/Tools.py index 637d16f..ef61bee 100644 --- a/sopel_modules/SpiceBot/Tools.py +++ b/sopel_modules/SpiceBot/Tools.py @@ -333,7 +333,7 @@ def read_directory_json_to_dict(directories, configtypename="Config File", log_f if len(os.listdir(directory)) > 0: for file in os.listdir(directory): filepath = os.path.join(directory, file) - if os.path.isfile(filepath): + if os.path.isfile(filepath) and filepath.endswith('.json'): filesprocess.append(filepath) for filepath in filesprocess: @@ -356,7 +356,8 @@ def read_directory_json_to_dict(directories, configtypename="Config File", log_f filecount += 1 slashsplit = str(filepath).split("/") filename = slashsplit[-1] - configs_dict[filename] = dict_from_file + filename_base = os.path.basename(filename).rsplit('.', 1)[0] + configs_dict[filename_base] = dict_from_file else: fileopenfail += 1 diff --git a/sopel_modules/SpiceBot/__init__.py b/sopel_modules/SpiceBot/__init__.py index e5e8ccd..90787d3 100644 --- a/sopel_modules/SpiceBot/__init__.py +++ b/sopel_modules/SpiceBot/__init__.py @@ -24,6 +24,7 @@ from .Users import * from .AI import * from .Google import * from .Gif import * +from .Sherlock import * from .configure import * diff --git a/sopel_modules/SpiceBot_Configs/gifapi/gfycat b/sopel_modules/SpiceBot_Configs/gifapi/gfycat.json similarity index 100% rename from sopel_modules/SpiceBot_Configs/gifapi/gfycat rename to sopel_modules/SpiceBot_Configs/gifapi/gfycat.json diff --git a/sopel_modules/SpiceBot_Configs/gifapi/gifme b/sopel_modules/SpiceBot_Configs/gifapi/gifme.json similarity index 100% rename from sopel_modules/SpiceBot_Configs/gifapi/gifme rename to sopel_modules/SpiceBot_Configs/gifapi/gifme.json diff --git a/sopel_modules/SpiceBot_Configs/gifapi/giphy b/sopel_modules/SpiceBot_Configs/gifapi/giphy.json similarity index 100% rename from sopel_modules/SpiceBot_Configs/gifapi/giphy rename to sopel_modules/SpiceBot_Configs/gifapi/giphy.json diff --git a/sopel_modules/SpiceBot_Configs/gifapi/tenor b/sopel_modules/SpiceBot_Configs/gifapi/tenor.json similarity index 100% rename from sopel_modules/SpiceBot_Configs/gifapi/tenor rename to sopel_modules/SpiceBot_Configs/gifapi/tenor.json diff --git a/sopel_modules/SpiceBot_Configs/sherlock/500px.json b/sopel_modules/SpiceBot_Configs/sherlock/500px.json new file mode 100644 index 0000000..8a9d0bc --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/500px.json @@ -0,0 +1,5 @@ +{ +"url": "https://500px.com/{}", +"errorType": "message", +"errorMsg": "Sorry, no such page." +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/About.me.json b/sopel_modules/SpiceBot_Configs/sherlock/About.me.json new file mode 100644 index 0000000..2fc37a2 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/About.me.json @@ -0,0 +1,4 @@ +{ +"url": "https://about.me/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/AngelList.json b/sopel_modules/SpiceBot_Configs/sherlock/AngelList.json new file mode 100644 index 0000000..4e32b6e --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/AngelList.json @@ -0,0 +1,5 @@ +{ +"url": "https://angel.co/{}", +"errorType": "message", +"errorMsg": "We couldn't find what you were looking for." +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/BLIP.fm.json b/sopel_modules/SpiceBot_Configs/sherlock/BLIP.fm.json new file mode 100644 index 0000000..22bb880 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/BLIP.fm.json @@ -0,0 +1,5 @@ +{ +"url": "https://blip.fm/{}", +"errorType": "message", +"errorMsg": "Page Not Found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Bandcamp.json b/sopel_modules/SpiceBot_Configs/sherlock/Bandcamp.json new file mode 100644 index 0000000..51b61b0 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Bandcamp.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.bandcamp.com/{}", +"errorType": "message", +"errorMsg": "Sorry, that something isn’t here" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Behance.json b/sopel_modules/SpiceBot_Configs/sherlock/Behance.json new file mode 100644 index 0000000..3f556e0 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Behance.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.behance.net/{}", +"errorType": "message", +"errorMsg": "Oops! We can’t find that page." +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/BitBucket.json b/sopel_modules/SpiceBot_Configs/sherlock/BitBucket.json new file mode 100644 index 0000000..425bcbd --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/BitBucket.json @@ -0,0 +1,4 @@ +{ +"url": "https://bitbucket.org/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Blogger.json b/sopel_modules/SpiceBot_Configs/sherlock/Blogger.json new file mode 100644 index 0000000..6c2e688 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Blogger.json @@ -0,0 +1,5 @@ +{ +"url": "https://{}.blogspot.com", +"errorType": "status_code", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/BuzzFeed.json b/sopel_modules/SpiceBot_Configs/sherlock/BuzzFeed.json new file mode 100644 index 0000000..2e847bc --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/BuzzFeed.json @@ -0,0 +1,5 @@ +{ +"url": "https://buzzfeed.com/{}", +"errorType": "message", +"errorMsg": "We can't find the page you're looking for." +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Canva.json b/sopel_modules/SpiceBot_Configs/sherlock/Canva.json new file mode 100644 index 0000000..330ec53 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Canva.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.canva.com/{}", +"errorType": "message", +"errorMsg": "Not found (404)" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/CashMe.json b/sopel_modules/SpiceBot_Configs/sherlock/CashMe.json new file mode 100644 index 0000000..af79737 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/CashMe.json @@ -0,0 +1,4 @@ +{ +"url": "https://cash.me/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Codecademy.json b/sopel_modules/SpiceBot_Configs/sherlock/Codecademy.json new file mode 100644 index 0000000..dc5a9a0 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Codecademy.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.codecademy.com/{}", +"errorType": "message", +"errorMsg": "404 error" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Codementor.json b/sopel_modules/SpiceBot_Configs/sherlock/Codementor.json new file mode 100644 index 0000000..af0651d --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Codementor.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.codementor.io/{}", +"errorType": "message", +"errorMsg": "404" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/ColourLovers.json b/sopel_modules/SpiceBot_Configs/sherlock/ColourLovers.json new file mode 100644 index 0000000..460868d --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/ColourLovers.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.colourlovers.com/love/{}", +"errorType": "message", +"errorMsg": "Page Not Loved" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Contently.json b/sopel_modules/SpiceBot_Configs/sherlock/Contently.json new file mode 100644 index 0000000..d1858d7 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Contently.json @@ -0,0 +1,6 @@ +{ +"url": "https://{}.contently.com/", +"errorType": "message", +"errorMsg": "We can't find that page!", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/DailyMotion.json b/sopel_modules/SpiceBot_Configs/sherlock/DailyMotion.json new file mode 100644 index 0000000..2e1251a --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/DailyMotion.json @@ -0,0 +1,6 @@ + +{ +"url": "https://www.dailymotion.com/{}", +"errorType": "message", +"errorMsg": "Page not found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Designspiration.json b/sopel_modules/SpiceBot_Configs/sherlock/Designspiration.json new file mode 100644 index 0000000..938072b --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Designspiration.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.designspiration.net/{}", +"errorType": "message", +"errorMsg": "Content Not Found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/DeviantART.json b/sopel_modules/SpiceBot_Configs/sherlock/DeviantART.json new file mode 100644 index 0000000..13a39b2 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/DeviantART.json @@ -0,0 +1,5 @@ +{ +"url": "https://{}.deviantart.com", +"errorType": "status_code", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Disqus.json b/sopel_modules/SpiceBot_Configs/sherlock/Disqus.json new file mode 100644 index 0000000..5ab29ee --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Disqus.json @@ -0,0 +1,4 @@ +{ +"url": "https://disqus.com/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Dribbble.json b/sopel_modules/SpiceBot_Configs/sherlock/Dribbble.json new file mode 100644 index 0000000..08b7375 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Dribbble.json @@ -0,0 +1,6 @@ +{ +"url": "https://dribbble.com/{}", +"errorType": "message", +"errorMsg": "Whoops, that page is gone.", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Ebay.json b/sopel_modules/SpiceBot_Configs/sherlock/Ebay.json new file mode 100644 index 0000000..43b284f --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Ebay.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.ebay.com/usr/{}", +"errorType": "message", +"errorMsg": "The User ID you entered was not found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Ello.json b/sopel_modules/SpiceBot_Configs/sherlock/Ello.json new file mode 100644 index 0000000..9445173 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Ello.json @@ -0,0 +1,5 @@ +{ +"url": "https://ello.co/{}", +"errorType": "message", +"errorMsg": "We couldn't find the page you're looking for" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Etsy.json b/sopel_modules/SpiceBot_Configs/sherlock/Etsy.json new file mode 100644 index 0000000..ab9f2b4 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Etsy.json @@ -0,0 +1,4 @@ +{ +"url": "https://www.etsy.com/shop/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Facebook.json b/sopel_modules/SpiceBot_Configs/sherlock/Facebook.json new file mode 100644 index 0000000..b2283aa --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Facebook.json @@ -0,0 +1,4 @@ +{ +"url": "https://www.facebook.com/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Flickr.json b/sopel_modules/SpiceBot_Configs/sherlock/Flickr.json new file mode 100644 index 0000000..50ba923 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Flickr.json @@ -0,0 +1,4 @@ +{ +"url": "https://www.flickr.com/people/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Flipboard.json b/sopel_modules/SpiceBot_Configs/sherlock/Flipboard.json new file mode 100644 index 0000000..5f94c33 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Flipboard.json @@ -0,0 +1,5 @@ +{ +"url": "https://flipboard.com/@{}", +"errorType": "message", +"errorMsg": "loading" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Fotolog.json b/sopel_modules/SpiceBot_Configs/sherlock/Fotolog.json new file mode 100644 index 0000000..ce33261 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Fotolog.json @@ -0,0 +1,4 @@ +{ +"url": "https://fotolog.com/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Foursquare.json b/sopel_modules/SpiceBot_Configs/sherlock/Foursquare.json new file mode 100644 index 0000000..7f5e1ac --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Foursquare.json @@ -0,0 +1,4 @@ +{ +"url": "https://foursquare.com/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/GitHub.json b/sopel_modules/SpiceBot_Configs/sherlock/GitHub.json new file mode 100644 index 0000000..5a887ee --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/GitHub.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.github.com/{}", +"errorType": "status_code", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/GoodReads.json b/sopel_modules/SpiceBot_Configs/sherlock/GoodReads.json new file mode 100644 index 0000000..0edf8c0 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/GoodReads.json @@ -0,0 +1,4 @@ +{ +"url": "https://www.goodreads.com/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/GooglePlus.json b/sopel_modules/SpiceBot_Configs/sherlock/GooglePlus.json new file mode 100644 index 0000000..8e7f674 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/GooglePlus.json @@ -0,0 +1,4 @@ +{ +"url": "https://plus.google.com/+{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Gravatar.json b/sopel_modules/SpiceBot_Configs/sherlock/Gravatar.json new file mode 100644 index 0000000..33343c6 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Gravatar.json @@ -0,0 +1,4 @@ +{ +"url": "http://en.gravatar.com/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Gumroad.json b/sopel_modules/SpiceBot_Configs/sherlock/Gumroad.json new file mode 100644 index 0000000..8c4cafd --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Gumroad.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.gumroad.com/{}", +"errorType": "message", +"errorMsg": "Page not found." +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/HackerNews.json b/sopel_modules/SpiceBot_Configs/sherlock/HackerNews.json new file mode 100644 index 0000000..5b34d7b --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/HackerNews.json @@ -0,0 +1,5 @@ +{ +"url": "https://news.ycombinator.com/user?id={}", +"errorType": "message", +"errorMsg": "No such user." +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/HackerOne.json b/sopel_modules/SpiceBot_Configs/sherlock/HackerOne.json new file mode 100644 index 0000000..8cedfc4 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/HackerOne.json @@ -0,0 +1,5 @@ +{ +"url": "https://hackerone.com/{}", +"errorType": "message", +"errorMsg": "Page not found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Houzz.json b/sopel_modules/SpiceBot_Configs/sherlock/Houzz.json new file mode 100644 index 0000000..dd5c35c --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Houzz.json @@ -0,0 +1,5 @@ +{ +"url": "https://houzz.com/user/{}", +"errorType": "message", +"errorMsg": "The page you requested was not found." +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/IFTTT.json b/sopel_modules/SpiceBot_Configs/sherlock/IFTTT.json new file mode 100644 index 0000000..6389e03 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/IFTTT.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.ifttt.com/p/{}", +"errorType": "message", +"errorMsg": "The requested page or file does not exist" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Imgur.json b/sopel_modules/SpiceBot_Configs/sherlock/Imgur.json new file mode 100644 index 0000000..aaf419c --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Imgur.json @@ -0,0 +1,4 @@ +{ +"url": "https://imgur.com/user/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Instagram.json b/sopel_modules/SpiceBot_Configs/sherlock/Instagram.json new file mode 100644 index 0000000..cf6c902 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Instagram.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.instagram.com/{}", +"errorType": "message", +"errorMsg": "The link you followed may be broken" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Instructables.json b/sopel_modules/SpiceBot_Configs/sherlock/Instructables.json new file mode 100644 index 0000000..398f5c0 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Instructables.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.instructables.com/member/{}", +"errorType": "message", +"errorMsg": "404: We're sorry, things break sometimes" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Keybase.json b/sopel_modules/SpiceBot_Configs/sherlock/Keybase.json new file mode 100644 index 0000000..756cbe6 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Keybase.json @@ -0,0 +1,4 @@ +{ +"url": "https://keybase.io/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Kongregate.json b/sopel_modules/SpiceBot_Configs/sherlock/Kongregate.json new file mode 100644 index 0000000..b663194 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Kongregate.json @@ -0,0 +1,6 @@ +{ +"url": "https://www.kongregate.com/accounts/{}", +"errorType": "message", +"errorMsg": "Sorry, no account with that name was found.", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/LiveJournal.json b/sopel_modules/SpiceBot_Configs/sherlock/LiveJournal.json new file mode 100644 index 0000000..80645f9 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/LiveJournal.json @@ -0,0 +1,6 @@ +{ +"url": "https://{}.livejournal.com", +"errorType": "message", +"errorMsg": "Unknown Journal", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Medium.json b/sopel_modules/SpiceBot_Configs/sherlock/Medium.json new file mode 100644 index 0000000..f82f540 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Medium.json @@ -0,0 +1,4 @@ +{ +"url": "https://medium.com/@{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/MixCloud.json b/sopel_modules/SpiceBot_Configs/sherlock/MixCloud.json new file mode 100644 index 0000000..e989578 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/MixCloud.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.mixcloud.com/{}", +"errorType": "message", +"errorMsg": "Page Not Found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Newgrounds.json b/sopel_modules/SpiceBot_Configs/sherlock/Newgrounds.json new file mode 100644 index 0000000..d220631 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Newgrounds.json @@ -0,0 +1,5 @@ +{ +"url": "https://{}.newgrounds.com", +"errorType": "status_code", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Pastebin.json b/sopel_modules/SpiceBot_Configs/sherlock/Pastebin.json new file mode 100644 index 0000000..2d013a5 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Pastebin.json @@ -0,0 +1,5 @@ +{ +"url": "https://pastebin.com/u/{}", +"errorType": "response_url", +"errorUrl": "https://pastebin.com/index" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Patreon.json b/sopel_modules/SpiceBot_Configs/sherlock/Patreon.json new file mode 100644 index 0000000..1359348 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Patreon.json @@ -0,0 +1,4 @@ +{ +"url": "https://www.patreon.com/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Pexels.json b/sopel_modules/SpiceBot_Configs/sherlock/Pexels.json new file mode 100644 index 0000000..d935f22 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Pexels.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.pexels.com/@{}", +"errorType": "message", +"errorMsg": "Ouch, something went wrong!" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Pinterest.json b/sopel_modules/SpiceBot_Configs/sherlock/Pinterest.json new file mode 100644 index 0000000..a48649c --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Pinterest.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.pinterest.com/{}", +"errorType": "response_url", +"errorUrl": "https://www.pinterest.com/?show_error=true" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Reddit.json b/sopel_modules/SpiceBot_Configs/sherlock/Reddit.json new file mode 100644 index 0000000..473fd05 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Reddit.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.reddit.com/user/{}", +"errorType": "message", +"errorMsg": "page not found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/ReverbNation.json b/sopel_modules/SpiceBot_Configs/sherlock/ReverbNation.json new file mode 100644 index 0000000..fe9f1f3 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/ReverbNation.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.reverbnation.com/{}", +"errorType": "message", +"errorMsg": "Sorry, we couldn't find that page" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Roblox.json b/sopel_modules/SpiceBot_Configs/sherlock/Roblox.json new file mode 100644 index 0000000..0b8803d --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Roblox.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.roblox.com/user.aspx?username={}", +"errorType": "message", +"errorMsg": "Page cannot be found or no longer exists" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Scribd.json b/sopel_modules/SpiceBot_Configs/sherlock/Scribd.json new file mode 100644 index 0000000..093e9ec --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Scribd.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.scribd.com/{}", +"errorType": "message", +"errorMsg": "Page not found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Slack.json b/sopel_modules/SpiceBot_Configs/sherlock/Slack.json new file mode 100644 index 0000000..665a35c --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Slack.json @@ -0,0 +1,5 @@ +{ +"url": "https://{}.slack.com", +"errorType": "status_code", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/SlideShare.json b/sopel_modules/SpiceBot_Configs/sherlock/SlideShare.json new file mode 100644 index 0000000..dfd7890 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/SlideShare.json @@ -0,0 +1,4 @@ +{ +"url": "https://slideshare.net/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/SoundCloud.json b/sopel_modules/SpiceBot_Configs/sherlock/SoundCloud.json new file mode 100644 index 0000000..fe9245f --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/SoundCloud.json @@ -0,0 +1,4 @@ +{ +"url": "https://soundcloud.com/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Spotify.json b/sopel_modules/SpiceBot_Configs/sherlock/Spotify.json new file mode 100644 index 0000000..49113c3 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Spotify.json @@ -0,0 +1,4 @@ +{ +"url": "https://open.spotify.com/user/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Steam.json b/sopel_modules/SpiceBot_Configs/sherlock/Steam.json new file mode 100644 index 0000000..912ae40 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Steam.json @@ -0,0 +1,5 @@ +{ +"url": "https://steamcommunity.com/id/{}", +"errorType": "message", +"errorMsg": "The specified profile could not be found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Tinder.json b/sopel_modules/SpiceBot_Configs/sherlock/Tinder.json new file mode 100644 index 0000000..d243de3 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Tinder.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.gotinder.com/@{}", +"errorType": "message", +"errorMsg": "Looking for Someone?" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Trakt.json b/sopel_modules/SpiceBot_Configs/sherlock/Trakt.json new file mode 100644 index 0000000..9a031e5 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Trakt.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.trakt.tv/users/{}", +"errorType": "message", +"errorMsg": "404" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Trip.json b/sopel_modules/SpiceBot_Configs/sherlock/Trip.json new file mode 100644 index 0000000..d7b2016 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Trip.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.trip.skyscanner.com/user/{}", +"errorType": "message", +"errorMsg": "Page not found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/TripAdvisor.json b/sopel_modules/SpiceBot_Configs/sherlock/TripAdvisor.json new file mode 100644 index 0000000..f52727e --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/TripAdvisor.json @@ -0,0 +1,5 @@ +{ +"url": "https://tripadvisor.com/members/{}", +"errorType": "message", +"errorMsg": "This page is on vacation…" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Twitter.json b/sopel_modules/SpiceBot_Configs/sherlock/Twitter.json new file mode 100644 index 0000000..978e13c --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Twitter.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.twitter.com/{}", +"errorType": "message", +"errorMsg": "page doesn’t exist" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Unsplash.json b/sopel_modules/SpiceBot_Configs/sherlock/Unsplash.json new file mode 100644 index 0000000..674dc26 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Unsplash.json @@ -0,0 +1,4 @@ +{ +"url": "https://unsplash.com/@{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/VK.json b/sopel_modules/SpiceBot_Configs/sherlock/VK.json new file mode 100644 index 0000000..85b53c9 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/VK.json @@ -0,0 +1,4 @@ +{ +"url": "https://vk.com/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/VSCO.json b/sopel_modules/SpiceBot_Configs/sherlock/VSCO.json new file mode 100644 index 0000000..2cff67e --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/VSCO.json @@ -0,0 +1,4 @@ +{ +"url": "https://vsco.co/{}", +"errorType": "status_code" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Vimeo.json b/sopel_modules/SpiceBot_Configs/sherlock/Vimeo.json new file mode 100644 index 0000000..104ee8b --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Vimeo.json @@ -0,0 +1,5 @@ +{ +"url": "https://vimeo.com/{}", +"errorType": "message", +"errorMsg": "404 Not Found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/Wattpad.json b/sopel_modules/SpiceBot_Configs/sherlock/Wattpad.json new file mode 100644 index 0000000..42b1f2f --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/Wattpad.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.wattpad.com/user/{}", +"errorType": "message", +"errorMsg": "This page seems to be missing..." +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/WeHeartIt.json b/sopel_modules/SpiceBot_Configs/sherlock/WeHeartIt.json new file mode 100644 index 0000000..4c36735 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/WeHeartIt.json @@ -0,0 +1,5 @@ +{ +"url": "https://weheartit.com/{}", +"errorType": "message", +"errorMsg": "Oops! You've landed on a moving target!" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/WordPress.json b/sopel_modules/SpiceBot_Configs/sherlock/WordPress.json new file mode 100644 index 0000000..f50bcb4 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/WordPress.json @@ -0,0 +1,6 @@ +{ +"url": "https://{}.wordpress.com", +"errorType": "response_url", +"errorUrl": "wordpress.com/typo/?subdomain=", +"noPeriod": "True" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/YouTube.json b/sopel_modules/SpiceBot_Configs/sherlock/YouTube.json new file mode 100644 index 0000000..9932d9d --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/YouTube.json @@ -0,0 +1,5 @@ +{ +"url": "https://www.youtube.com/{}", +"errorType": "message", +"errorMsg": "Not Found" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/devRant.json b/sopel_modules/SpiceBot_Configs/sherlock/devRant.json new file mode 100644 index 0000000..3463f4c --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/devRant.json @@ -0,0 +1,5 @@ +{ +"url": "https://devrant.com/users/{}", +"errorType": "response_url", +"errorUrl": "https://devrant.com/" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/iMGSRC.RU.json b/sopel_modules/SpiceBot_Configs/sherlock/iMGSRC.RU.json new file mode 100644 index 0000000..5f114e6 --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/iMGSRC.RU.json @@ -0,0 +1,5 @@ +{ +"url": "https://imgsrc.ru/main/user.php?user={}", +"errorType": "response_url", +"errorUrl": "https://imgsrc.ru/" +} diff --git a/sopel_modules/SpiceBot_Configs/sherlock/last.fm.json b/sopel_modules/SpiceBot_Configs/sherlock/last.fm.json new file mode 100644 index 0000000..eb3209f --- /dev/null +++ b/sopel_modules/SpiceBot_Configs/sherlock/last.fm.json @@ -0,0 +1,5 @@ +{ +"url": "https://last.fm/user/{}", +"errorType": "message", +"errorMsg": "Whoops! Sorry, but this page doesn't exist." +} diff --git a/sopel_modules/SpiceBot_Core_Commands/Sherlock.py b/sopel_modules/SpiceBot_Core_Commands/Sherlock.py new file mode 100644 index 0000000..d38f32d --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Commands/Sherlock.py @@ -0,0 +1,49 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function + +# sopel imports +import sopel.module + +import spicemanip + +import sopel_modules.SpiceBot as SpiceBot + + +@SpiceBot.prerun.prerun('module') +@sopel.module.commands('sherlock', 'username') +def bot_command_sherlock(bot, trigger): + + netlist = list(SpiceBot.sherlock.dict.keys()) + + username = spicemanip.main(trigger.sb["args"], 1) or trigger.nick + trigger.sb["args"] = spicemanip.main(trigger.sb["args"], "2+", 'list') + + checklist = netlist + checklistname = 'all' + if SpiceBot.inlist(username, netlist): + checklistname = SpiceBot.inlist_match(username, netlist) + checklist = [checklistname] + username = spicemanip.main(trigger.sb["args"], 1) or trigger.nick + + bot.osd("Checking username " + username + " in " + checklistname + " network.") + + inlist, notinlist = [], [] + + for social_network in checklist: + + in_social = SpiceBot.sherlock.check_network(username, social_network) + if in_social: + inlist.append(social_network) + else: + notinlist.append(social_network) + + if len(inlist): + if checklistname != 'all': + bot.osd(["The username " + username + " is in " + checklist[0], SpiceBot.sherlock.dict.get(social_network).get("url").format(username)]) + else: + bot.osd(["The username " + username + " is in the following:", spicemanip.main(inlist, "andlist")], trigger.nick, 'NOTICE') + if len(notinlist): + if checklistname != 'all': + bot.osd(["The username " + username + " is NOT in the following:", spicemanip.main(notinlist, "andlist")]) + else: + bot.osd(["The username " + username + " is NOT in the following:", spicemanip.main(notinlist, "andlist")], trigger.nick, 'NOTICE') diff --git a/sopel_modules/SpiceBot_Core_Commands/__init__.py b/sopel_modules/SpiceBot_Core_Commands/__init__.py index a451704..cf853c4 100644 --- a/sopel_modules/SpiceBot_Core_Commands/__init__.py +++ b/sopel_modules/SpiceBot_Core_Commands/__init__.py @@ -19,6 +19,7 @@ from .BotPrivs import * from .Search import * from .AI import * from .Gif import * +from .Sherlock import * __author__ = 'Sam Zick' __email__ = 'sam@deathbybandaid.net'