Skip to content

Commit

Permalink
fix for is.gd being broken
Browse files Browse the repository at this point in the history
  • Loading branch information
hlmtre committed Jan 26, 2024
1 parent 1b39911 commit b4d98a8
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions modules/shortener.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ def post_init(self):
def handle(self, event):
try:
target = re.search("https?://[\\S]+", event.line).group(0)
url = 'https://is.gd/create.php'
payload = {'format': 'simple', 'url': target}
url = 'https://u.aql.ink/new'
payload = target
if len(target) > 60 and re.match(
self.r_pattern, target) is None: # Post only shortened link if NOT reddit link
r = requests.get(url, params=payload)
if re.search("https://is.gd*", r.text):
r = requests.post(url, data=payload)
if re.search("https://u.aql.ink/*", r.text):
self.say(event.channel, r.text)
else:
self.say("Something went wrong :(")
self.bot.debug_print(payload)
self.bot.debug_print(r)
self.say(event.channel, "Something went wrong :(")
else:
return
except requests.exceptions.HTTPError as e:
Expand All @@ -46,11 +48,11 @@ def handle(self, event):
# Called from the rshort module to shorten the link to put in link
# description
def reddit_link(self, link):
url = 'https://is.gd/create.php'
payload = {'format': 'simple', 'url': link}
url = 'https://u.aql.ink/new'
payload = link
try:
r = requests.get(url, params=payload)
if re.search("https://is.gd*", r.text):
r = requests.post(url, data=payload)
if re.search("https://u.aql.ink/*", r.text):
return r.text
else:
return "Something went wrong :("
Expand Down

0 comments on commit b4d98a8

Please sign in to comment.