aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-05-01 08:17:48 +0100
committerGravatar jesopo2019-05-01 08:17:48 +0100
commited57ac7c17ace0906970ddbb0035df7f0f8fb356 (patch)
tree477e9efc5d829c851f3d35ee65170a8e2a918da9 /modules
parentNo longer prefix stderr with "!", it doesn't really make sense (diff)
signature
Move isgd.py to shorturl.py and switch back to using bit.ly
Diffstat (limited to 'modules')
-rw-r--r--modules/shorturl.py (renamed from modules/isgd.py)15
1 files changed, 10 insertions, 5 deletions
diff --git a/modules/isgd.py b/modules/shorturl.py
index cfc94ebb..13503725 100644
--- a/modules/isgd.py
+++ b/modules/shorturl.py
@@ -1,9 +1,13 @@
+#--require-config bitly-api-key
+
import re
from src import ModuleManager, utils
-ISGD_API_URL = "https://is.gd/create.php"
+URL_BITLYSHORTEN = "https://api-ssl.bitly.com/v3/shorten"
class Module(ModuleManager.BaseModule):
+ _name = "Short"
+
def on_load(self):
self.exports.add("shortlink", self._shortlink)
@@ -11,11 +15,12 @@ class Module(ModuleManager.BaseModule):
if not re.match(utils.http.REGEX_URL, url):
url = "http://%s" % url
- page = utils.http.request(ISGD_API_URL, get_params=
- {"format": "json", "url": url}, json=True)
+ page = utils.http.request(URL_BITLYSHORTEN, get_params={
+ "access_token": self.bot.config["bitly-api-key"],
+ "longUrl": url}, json=True)
- if page and page.data["shorturl"]:
- return page.data["shorturl"]
+ if page and page.data["data"]:
+ return page.data["data"]["url"]
@utils.hook("received.command.shorten")
def shorten(self, event):