├── LICENSE ├── Procfile ├── README.md ├── app.json ├── bot.py ├── requirements.txt └── runtime.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 AkBotZ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | worker: python3 bot.py 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Link Shortener 2 | Make short link by using Different Website API Keys 3 | 4 | Buy Me A Coffee 5 | 6 | ### Installation 7 | 8 | #### The Easy Way 9 | 10 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) 11 | 12 | ##### Required Variables 13 | 14 | * `BOT_TOKEN`: Create a bot using [@BotFather](https://telegram.dog/BotFather), and get the Telegram API token. 15 | 16 | * `API_ID`: Get this value from [telegram.org](https://my.telegram.org/apps) 17 | * `API_HASH`: Get this value from [telegram.org](https://my.telegram.org/apps) 18 | * `API_KEY`: Get this value from your website. 19 | * `API_URL`: Get this value by logging on your link shortener site. 20 | 21 | #### API URL of Some sites are: 22 | 23 | |No.| Website | API URL (Copy & Paste these URL in API_URL var) | API KEY (Get API KEY From Site) | 24 | |---|:-----------------|:---------------------------------------------------------|:--------------------------------------------| 25 | |1. | GPLink | `https://gplinks.in/api` |https://gplinks.in/member/tools/api | 26 | |2. | Droplink | `https://droplink.co/api` |https://droplink.co/member/tools/api | 27 | |3. | TnLink | `https://tnlink.in/api` |https://tnlink.in/member/tools/api | 28 | |4. | DuLink | `https://dulink.in/api` |https://dulink.in/member/tools/api | 29 | |5. | PdiskShortener | `https://pdiskshortener.com/api` |https://pdiskshortener.com/member/tools/api | 30 | |6. | MdiskShortener | `https://mdiskshortner.link/api` |https://mdiskshortner.link/member/tools/api | 31 | |7. | EasySky | `https://easysky.in/api` |https://easysky.in/members/tools/api | 32 | |8. | ClickyFly | `https://clickyfly.com/api` |https://clickyfly.com/member/tools/api | 33 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Link Shortener Bot", 3 | "description": "Make short link by different API Keys", 4 | "keywords": [ 5 | "telegram", 6 | "short link", 7 | "GPLink", 8 | "Droplink", 9 | "Dulink", 10 | "Tnlink", 11 | "pdisklinkshortener" 12 | ], 13 | "website": "https://github.com/AkBotZ/Link-Shortener-Bot", 14 | "repository": "https://github.com/AkBotZ/Link-Shortener-Bot", 15 | "env": { 16 | "API_HASH": { 17 | "description": "Get this value from https://my.telegram.org", 18 | "value": "" 19 | }, 20 | "API_ID": { 21 | "description": "Get this value from https://my.telegram.org", 22 | "value": "" 23 | }, 24 | "API_KEY": { 25 | "description": "Get API key from your Website", 26 | "value": "" 27 | }, 28 | "API_URL": { 29 | "description": "Paste ONLY ONE API URL From Your Link Shortener Website, Examples are given here: https://github.com/AkBotZ/Link-Shortener-Bot#api-url-of-some-sites-are", 30 | "value": "" 31 | }, 32 | "BOT_TOKEN": { 33 | "description": "Your bot token, Get it from @Botfather", 34 | "value": "" 35 | } 36 | }, 37 | "addons": [], 38 | "buildpacks": [ 39 | { 40 | "url": "heroku/python" 41 | } 42 | ], 43 | "formation": { 44 | "worker": { 45 | "quantity": 1, 46 | "size": "free" 47 | } 48 | }, 49 | "stack": "heroku-22" 50 | } 51 | -------------------------------------------------------------------------------- /bot.py: -------------------------------------------------------------------------------- 1 | # ©AKBOTZ 2 | 3 | import re 4 | import aiohttp 5 | 6 | from os import environ 7 | from pyrogram import Client, filters 8 | from pyrogram.types import * 9 | 10 | API_ID = environ.get('API_ID') 11 | API_HASH = environ.get('API_HASH') 12 | BOT_TOKEN = environ.get('BOT_TOKEN') 13 | API_KEY = environ.get('API_KEY') 14 | API_URL = environ.get('API_URL') 15 | 16 | akbotz = Client('link shortener bot', 17 | api_id=API_ID, 18 | api_hash=API_HASH, 19 | bot_token=BOT_TOKEN, 20 | workers=100) 21 | 22 | print("Developer: @AKBotZ , Join & Share Channel") 23 | print("Bot is Started Now") 24 | 25 | @akbotz.on_message(filters.command('start') & filters.private) 26 | async def start(bot, message): 27 | await message.reply( 28 | f"**Hi {message.chat.first_name}!**\n\n" 29 | "I'm Link Shortener bot. Just send me link and get short link, You can also send multiple links seperated by a space or enter.\n\n**Developer:** @AKBotZ") 30 | 31 | 32 | @akbotz.on_message(filters.private & filters.text & filters.incoming) 33 | async def link_handler(bot, message): 34 | link_pattern = re.compile('https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,}', re.DOTALL) 35 | links = re.findall(link_pattern, message.text) 36 | if len(links) <1: 37 | await message.reply("No links Found in this text",quote=True) 38 | return 39 | for link in links: 40 | try: 41 | short_link = await get_shortlink(link) 42 | await message.reply(f"𝐇𝐞𝐫𝐞 𝐢𝐬 𝐘𝐨𝐮𝐫 𝐒𝐡𝐨𝐫𝐭𝐞𝐧𝐞𝐝 𝐋𝐢𝐧𝐤\n\n𝐎𝐫𝐢𝐠𝐢𝐧𝐚𝐥 𝐋𝐢𝐧𝐤: {link}\n\n𝐒𝐡𝐨𝐫𝐭𝐞𝐧𝐞𝐝 𝐋𝐢𝐧𝐤: `{short_link}`",quote=True,disable_web_page_preview=True) 43 | except Exception as e: 44 | await message.reply(f'𝐄𝐫𝐫𝐨𝐫: `{e}`', quote=True) 45 | 46 | 47 | async def get_shortlink(link): 48 | url = API_URL 49 | params = {'api': API_KEY, 'url': link} 50 | 51 | async with aiohttp.ClientSession() as session: 52 | async with session.get(url, params=params, raise_for_status=True) as response: 53 | data = await response.json() 54 | return data["shortenedUrl"] 55 | 56 | 57 | akbotz.run() 58 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyrogram 2 | tgcrypto 3 | aiohttp 4 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.9.13 2 | --------------------------------------------------------------------------------