diff --git a/CHANGELOG.md b/CHANGELOG.md index 9270d1c1..81b4f531 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed yandex translate plugin - Removed soundcloud plugin due to API removal - Removed imdb.py, the backing app is not being maintained and is broken +- Removed quran.py as API no longer exists + +## Breaking +- Removed support for Python <3.8 ## [1.3.0] 2020-03-17 ### Added diff --git a/plugins/quran.py b/plugins/quran.py deleted file mode 100644 index 6e540b2a..00000000 --- a/plugins/quran.py +++ /dev/null @@ -1,62 +0,0 @@ -import requests -from requests import HTTPError - -from cloudbot import hook - - -def statuscheck(status, item): - """since we are doing this a lot might as well return something more meaningful""" - if status == 404: - out = f"It appears {item} does not exist." - elif status == 503: - out = "Qur'an API is having problems, it would be best to check back later." - else: - out = f"Qur'an API returned an error, response: {status}" - return out - - -def smart_truncate(content, length=425, suffix="...\n"): - if len(content) <= length: - return content - - return ( - content[:length].rsplit(" ", 1)[0] - + suffix - + content[:length].rsplit(" ", 1)[1] - + smart_truncate(content[length:]) - ) - - -@hook.command("quran", "verse", singlethread=True) -def quran(text, message, reply): - """ - Prints the specified Qur'anic verse(s) and its/their translation(s)""" - api_url = "http://quranapi.azurewebsites.net/api/verse/" - chapter = text.split(":")[0] - verse = text.split(":")[1] - params = {"chapter": chapter, "number": verse, "lang": "ar"} - r = requests.get(api_url, params=params) - try: - r.raise_for_status() - except HTTPError as e: - reply(statuscheck(e.response.status_code, text)) - raise - - if r.status_code != 200: - return statuscheck(r.status_code, text) - params["lang"] = "en" - r2 = requests.get(api_url, params=params) - - try: - r2.raise_for_status() - except HTTPError as e: - reply(statuscheck(e.response.status_code, text)) - raise - - data = r.json() - data2 = r2.json() - out = f"\x02{text}\x02: " - verse = data["Text"] - out += verse - message(out) - translation = smart_truncate(data2["Text"]) - return translation