├── Procfile
├── README.md
├── app.json
├── bot.py
└── requirements.txt
/Procfile:
--------------------------------------------------------------------------------
1 | worker: python3 bot.py
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
File To Link Bot - TeLe TiPs
2 | Telegram bot to provide links of different types of files you send.
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ## WHAT CAN THIS BOT DO
16 | Is it a nuisance to send huge files to others? File To Link Bot is for you.This bot will help you to provide shorten links for different types of files you send.
17 |
18 | ## Deployment Methods
19 |
20 | ### Heroku
21 |
22 | [](https://heroku.com/deploy?template=https://github.com/teletips/FileToLink)
23 |
24 | ## Config Vars
25 | 1. `BOT_TOKEN` : A Valid Telegram Bot Token, get it from @Botfather
26 |
27 | ## HOW TO USE THIS BOT
28 |
29 | ```
30 | - You can send any type of files (Video, Image, Audio, Document) to this bot.
31 | - Bot will send a shorten link of that file to you.
32 | ```
33 | ## Credits
34 | - [TeLe TiPs](https://github.com/teletips)
35 |
36 | ## Friendly Warning
37 |
38 | - You are free to use this code in any of your projects, but you MUST include the following in your README.md (Copy & paste)
39 | ```
40 | ##Credits
41 | - [File To Link Telegram bot by TeLe TiPs] (https://github.com/teletips/FileToLink)
42 | ```
43 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "FileToLinkTeLeTiPs",
3 | "description": "Bot to provide links of different types of files you send.",
4 | "website": "https://FileToLinkTeLeTiPs/",
5 | "repository": "https://github.com/Thakshaka/FileToLinkTeLeTiPs",
6 | "env": {
7 | "TG_BOT_TOKEN": {"description": "Your Bot's Token From BotFather Bot","required": true}
8 | },
9 | "buildpacks": [
10 | {"url": "heroku/python"}
11 | ],
12 | "formation": {
13 | "worker": {
14 | "quantity": 1,
15 | "size": "free"
16 | }
17 | },
18 | "stack": "heroku-20"
19 | }
20 |
--------------------------------------------------------------------------------
/bot.py:
--------------------------------------------------------------------------------
1 | import telebot
2 | import time
3 | import pyshorteners
4 | import os
5 |
6 | bot = telebot.TeleBot(token=os.getenv('TG_BOT_TOKEN'))
7 |
8 | def short(url):
9 | return pyshorteners.Shortener().tinyurl.short(url)
10 |
11 | @bot.message_handler(commands=['start'])
12 | def send_welcome(message):
13 | bot.reply_to(message, 'Heya! I am a File To Link Bot created by TeLe TiPs.Send me any file (Video, Audio, Photo, Document)👇🏻')
14 |
15 | @bot.message_handler(commands=['help'])
16 | def send_welcome(message):
17 | bot.reply_to(message, 'Send me any type of a file & I will send you the shorten link of it')
18 |
19 | @bot.message_handler(content_types=['photo', 'video', 'audio', 'document'])
20 | def file_sent(message):
21 | try:
22 | bot.send_message(message.chat.id, short(bot.get_file_url(message.document.file_id)))
23 | except AttributeError:
24 | try:
25 | bot.send_message(message.chat.id, short(bot.get_file_url(message.photo[0].file_id)))
26 | except AttributeError:
27 | try:
28 | bot.send_message(message.chat.id, short(bot.get_file_url(message.audio.file_id)))
29 | except AttributeError:
30 | try:
31 | bot.send_message(message.chat.id, short(bot.get_file_url(message.video.file_id)))
32 | except AttributeError:
33 | pass
34 |
35 |
36 | while True:
37 | try:
38 | bot.polling()
39 | except Exception:
40 | time.sleep(15)
41 |
42 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | pytelegrambotapi
2 | pyshorteners
3 |
--------------------------------------------------------------------------------