Last active
December 29, 2019 17:16
-
-
Save jesopo/f3bfe7d73d7d39b121c6457f2d29f32f to your computer and use it in GitHub Desktop.
ttm.sh URL shortener for BitBot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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