Skip to content

Commit

Permalink
Merge pull request #23 from hlmtre/shortener_fix
Browse files Browse the repository at this point in the history
fix for is.gd being broken
  • Loading branch information
hlmtre authored Jan 27, 2024
2 parents aecd0ff + 42f26b0 commit 7f02607
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.x']
python-version: ['3.9']

steps:
- uses: actions/checkout@v1
Expand Down
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 7f02607

Please sign in to comment.