Skip to content

Instantly share code, notes, and snippets.

@jesopo
Last active December 29, 2019 17:16
Show Gist options
  • Select an option

  • Save jesopo/f3bfe7d73d7d39b121c6457f2d29f32f to your computer and use it in GitHub Desktop.

Select an option

Save jesopo/f3bfe7d73d7d39b121c6457f2d29f32f to your computer and use it in GitHub Desktop.
ttm.sh URL shortener for BitBot
from src import ModuleManager, utils
URL = "https://ttm.sh"
class Module(ModuleManager.BaseModule):
def on_load(self):
self.exports.add("shorturl-s-ttmsh", self._shorturl)
def _shorturl(self, url):
if len(url) < 18:
return None
page = utils.http.request(URL, method="POST", post_data={
"shorten": url})
if page and page.data:
return page.decode("utf8").rstrip("\n")
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment