├── .deepsource.toml ├── LICENSE ├── Procfile ├── README.md ├── app.json ├── bot.py ├── config.py ├── requirements.txt └── runtime.txt /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [[analyzers]] 4 | name = "python" 5 | enabled = true 6 | 7 | [analyzers.meta] 8 | max_line_length = 110 9 | runtime_version = "3.x.x" 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Mrvishal2k2 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 | # TG-BitlyBot 2 | Make a short link by using [Bit.ly](https://bit.ly/) API key Or With [Da.gd](https://da.gd) If BITLY_KEY isn't present 3 | 4 | * **Language:** [Python3](https://www.python.org) 5 | * **Library:** [Pyrogram](https://docs.pyrogram.org) 6 | 7 | ### Installation 8 | 9 | #### Easy Way 10 | Use [ShortLinkRobot](https://t.me/URLShortenRobot) with 10+ sites and inline Support !! 11 | 12 | #### The Simple Way 13 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) 14 | 15 | #### Hard Way (VPS) 16 | * This is just a demo of commands to use 17 | ``` 18 | git clone https://github.com/Mrvishal2k2/TG-ShortLinkBot 19 | virtualenv -p /usr/bin/python3 venv 20 | . ./venv/bin/activate 21 | pip install -r requirements.txt 22 | python3 bot.py 23 | ``` 24 | 25 | ### Developer 26 | * Telegram [Mrvishal2k2](https://t.me/Mrvishal_2k2) 27 | * You can checkout my bots At [BotDunia](https://t.me/BotDunia) 28 | 29 | 30 | #### Required Variables 31 | 32 | * `BOT_TOKEN`: Create a bot using [@BotFather](https://telegram.dog/BotFather), and get the Telegram API token. 33 | * `API_ID`: Get this value from [telegram.org](https://my.telegram.org/apps) 34 | You can also get it from [UseTGXBot](https://t.me/UseTGXBot) 35 | * `API_HASH`: Get this value from [telegram.org](https://my.telegram.org/apps) 36 | You can also get it from [UseTGXBot](https://t.me/UseTGXBot) 37 | * `BITLY_KEY`: (Not Compulsory) Create [Bit.ly](https://bitly.com/a/sign_in) account then get this value from Profile settings > Generic access token. 38 | If BITLY_KEY is not provided Still u can use with [Da.gd](https://da.gd) Shortlink !! 39 | * `OWNER`: (Not mandatory) Owner's Username without @ 40 | 41 | ## Commands: 42 | ``` 43 | start - start the bot 44 | help - ask help 45 | ``` 46 | 47 | ### Support: 48 | * Join BotDunia channel 49 | 50 | * Join Support Group 51 | 52 | 53 | ### Follow on: 54 |

55 | 56 |

57 |

58 | 59 |

60 | 61 | ## All rights reserved !! 62 | * Kangers stay away from Kang !! 63 | * Don't be a copy cat !! 64 | * Good to see if you give me credits if you are using !! 65 | * This is only for personal use !! Don't make a Bot channel Business with this !! 66 | 67 | ## Credits 68 | * [Mahesh Malekar](https://github.com/Mahesh0253) For his Awesome [GPLinks](https://github.com/Mahesh0253/GPlink-bot) Opensource 69 | * And everyone in this Journey 70 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Bitly_Bot", 3 | "description": "Make short link by using Bitly API key", 4 | "keywords": [ 5 | "telegram", 6 | "Bitly" 7 | ], 8 | "website": "https://github.com/MrVishal2k2", 9 | "repository": "https://github.com/Mrvishal2k2/TG-ShortLinkBot/tree/Bitly", 10 | "logo": "https://telegra.ph//file/b3461e7795bb258688623.jpg", 11 | "env": { 12 | "BOT_TOKEN": { 13 | "description": "Your bot token.Get from Botfather bot", 14 | "value": "" 15 | }, 16 | "API_ID": { 17 | "description": "Get this value from https://my.telegram.org", 18 | "value": "" 19 | }, 20 | "API_HASH": { 21 | "description": "Get this value from https://my.telegram.org", 22 | "value": "" 23 | }, 24 | "BITLY_KEY": { 25 | "description": "Bitly API See Readme for further details", 26 | "required": false 27 | }, 28 | "OWNER": { 29 | "description": "OWNER username without @", 30 | "required": false 31 | } 32 | 33 | }, 34 | "addons": [], 35 | "buildpacks": [ 36 | { 37 | "url": "heroku/python" 38 | } 39 | ], 40 | "formation": { 41 | "worker": { 42 | "quantity": 1, 43 | "size": "free" 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /bot.py: -------------------------------------------------------------------------------- 1 | """ 2 | Bitly Bot 3 | 4 | © All rights reserved by Mrvishal2k2 5 | Kangers don't f*ckin kang this !!! 6 | Should have to give credits 😏 else f***off 7 | This is only for personal use Dont use this for ur bot channel business 😂 8 | Thanks to Mahesh Malekar for his Gplinks Bot !! 9 | """ 10 | 11 | 12 | import logging 13 | from pyrogram import Client, filters, idle 14 | from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup 15 | from pyshorteners import Shortener 16 | from config import API_ID, API_HASH, BOT_TOKEN, BITLY_KEY, OWNER 17 | 18 | logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') 19 | log = logging.getLogger(__name__) 20 | logging.getLogger("pyrogram").setLevel(logging.WARNING) 21 | 22 | SHORTLINKBOT = Client('ShortlinkBot', 23 | api_id=API_ID, 24 | api_hash=API_HASH, 25 | bot_token=BOT_TOKEN, 26 | workers=50, 27 | sleep_threshold=10) 28 | 29 | 30 | @SHORTLINKBOT.on_message(filters.command(['start', 'help'])) 31 | async def start(_, update): 32 | """Start Message""" 33 | markup = InlineKeyboardMarkup([[InlineKeyboardButton("My Owner 👮", url=f"https://t.me/{OWNER}")]]) 34 | await update.reply( 35 | f"**Hi {update.chat.first_name}!**\n\n" 36 | "I'm shortlink bot. Just send me link and get adsless short link", 37 | reply_markup=markup, 38 | quote=True) 39 | 40 | 41 | @SHORTLINKBOT.on_message(filters.regex(r'https?://[^\s]+')) 42 | async def link_handler(_, update): 43 | """Link Handler""" 44 | link = update.matches[0].group(0) 45 | shortened_url, Err = get_shortlink(link) 46 | if shortened_url is None: 47 | message = f"Something went wrong \n{Err}" 48 | await update.reply(message, quote=True) 49 | return 50 | message = f"Here is your shortlink\n {shortened_url}" 51 | markup = InlineKeyboardMarkup( 52 | [ 53 | [ 54 | InlineKeyboardButton("Open Link 🔗", url=shortened_url) 55 | ] 56 | ] 57 | ) 58 | # i don't think this bot with get sending message error so no need of exceptions 59 | await update.reply_text(text=message, reply_markup=markup, quote=True) 60 | 61 | 62 | def get_shortlink(url): 63 | """Get Shortlink""" 64 | shortened_url = None 65 | Err = None 66 | try: 67 | if BITLY_KEY: 68 | # Bittly Shorten 69 | s = Shortener(api_key=BITLY_KEY) 70 | shortened_url = s.bitly.short(url) 71 | else: 72 | # Da.gd : I prefer this 73 | s = Shortener() 74 | shortened_url = s.dagd.short(url) 75 | except Exception as error: # skipcq: PYL-W0703 - sometimes it can give error. 76 | Err = f"#ERROR: {error}" 77 | log.info(Err) 78 | return shortened_url, Err 79 | 80 | 81 | if __name__ == "__main__" : 82 | SHORTLINKBOT.start() 83 | log.info(">>Bot-Started<<") 84 | idle() 85 | SHORTLINKBOT.stop() 86 | log.info(">>Bot-Stopped<<") 87 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | from os import environ 2 | 3 | API_ID = int(environ.get('API_ID')) 4 | API_HASH = environ.get('API_HASH') 5 | BOT_TOKEN = environ.get('BOT_TOKEN') 6 | BITLY_KEY = environ.get('BITLY_KEY') 7 | OWNER = environ.get('OWNER', 'BotDunia') 8 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pyrogram 2 | tgcrypto 3 | pyshorteners 4 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.9.5 2 | --------------------------------------------------------------------------------