├── runtime.txt
├── Procfile
├── requirements.txt
├── LICENSE
├── app.json
├── README.md
└── main.py
/runtime.txt:
--------------------------------------------------------------------------------
1 | python-3.10.4
2 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | worker: python3 main.py
2 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | pyrogram
2 | tgcrypto==1.2.3
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Muhammed
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 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "AutoCaption-Bot",
3 | "description": "Auto Caption BoT V1 @Pr0fess0r-99",
4 | "logo": "https://graph.org/file/a3a93ffb7283578499cce.jpg",
5 | "keywords": [
6 | "Private",
7 | "Auto",
8 | "Caption",
9 | "Bot"
10 | ],
11 | "website": "https://youtube.com/channel/UCmGBpXoM-OEm-FacOccVKgQ",
12 | "repository": "https://github.com/PR0FESS0R-99/AutoCaption-BoT",
13 | "success_url": "https://youtube.com/channel/UCmGBpXoM-OEm-FacOccVKgQ",
14 | "env": {
15 | "app_id": {
16 | "description": "Your APP ID From my.telegram.org or @MT_MyTelegramOrg_Bot",
17 | "value": ""
18 | },
19 | "api_hash": {
20 | "description": "Your API Hash From my.telegram.org or @MT_MyTelegramOrg_Bot",
21 | "value": ""
22 | },
23 | "bot_token": {
24 | "description": "Your Bot Token From @BotFather",
25 | "value": ""
26 | },
27 | "custom_caption": {
28 | "description": "Caption Text. use {file_name} to get original file name",
29 | "required": false
30 | }
31 | },
32 | "buildpacks": [
33 | {
34 | "url": "heroku/python"
35 | }
36 | ],
37 | "formation": {
38 | "worker": {
39 | "quantity": 1,
40 | "size": "free"
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 𝙈𝙏 𝘼𝙪𝙩𝙤𝘾𝙖𝙥𝙩𝙞𝙤𝙣 𝘽𝙤𝙩
2 |
3 | This Repo is Telegram Channel Code to help build a bot that automatically adds captions to files added to a Telegram channel
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | ### Deploy To Heroku
22 | [](https://heroku.com/deploy?template=https://github.com/PR0FESS0R-99/AutoCaption-BoT)
23 |
24 | ### Simple Variables 😉
25 |
26 | * `app_id` : Get this value from [telegram.org](https://my.telegram.org/apps) or [@MT_MyTelegramOrg_Bot](https://t.me/MT_MyTelegramOrg_Bot) .
27 | * `api_hash` : Get this value from [telegram.org](https://my.telegram.org/apps) or [@MT_MyTelegramOrg_Bot](https://t.me/MT_MyTelegramOrg_Bot) .
28 | * `bot_token` : Create a bot using [@BotFather](https://telegram.dog/BotFather), and get the Telegram API token .
29 | * `custom_caption` : your caption. add {file_name} to get file original name. More info to watch [YT TUTORIAL](https://github.com/PR0FESS0R-99) .
30 |
31 | ### Made With
32 |
33 | ● 📚 𝗟𝗔𝗡𝗚𝗨𝗔𝗚𝗘
34 |
35 | [](https://www.python.org)
36 |
37 | ● 🧮 𝗟𝗜𝗕𝗥𝗔𝗥𝗬
38 |
39 | [](https://docs.pyrogram.org)
40 |
41 |
42 | ### Developer & Support
43 |
44 | [Telegram Channel](https://Telegram.dog/Mo_Tech_YT)
45 |
46 | [Follow On InstaGram](https://www.instagram.com/mrk_yt_)
47 |
48 | [Subscribe YouTube Channel](https://youtube.com/c/MoTech_YT)
49 |
50 | ### Credits
51 |
52 |
53 | ### LICENSE
54 |
55 | [](https://github.com/PR0FESS0R-99/AutoCaption-BoT/blob/main/LICENSE)
56 |
57 | Licensed under [MIT License](https://github.com/PR0FESS0R-99/AutoCaptionBot-V1/blob/main/LICENSE)
58 | 🚫 Don't Sell This Code. Code is fully open source project ❤️🔥
59 | Copyright Claimed by © @PR0FESS0R-99
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | import pyrogram, os, asyncio
2 |
3 | try: app_id = int(os.environ.get("app_id", None))
4 | except Exception as app_id: print(f"⚠️ App ID Invalid {app_id}")
5 | try: api_hash = os.environ.get("api_hash", None)
6 | except Exception as api_id: print(f"⚠️ Api Hash Invalid {api_hash}")
7 | try: bot_token = os.environ.get("bot_token", None)
8 | except Exception as bot_token: print(f"⚠️ Bot Token Invalid {bot_token}")
9 | try: custom_caption = os.environ.get("custom_caption", "`{file_name}`")
10 | except Exception as custom_caption: print(f"⚠️ Custom Caption Invalid {custom_caption}")
11 |
12 | AutoCaptionBot = pyrogram.Client(
13 | name="AutoCaptionBot", api_id=app_id, api_hash=api_hash, bot_token=bot_token)
14 |
15 | start_message = """
16 | 👋Hello {}
17 | I am an AutoCaption bot
18 | All you have to do is add me to your channel and I will show you my power
19 | @Mo_Tech_YT"""
20 |
21 | about_message = """
22 | • Name : [AutoCaption V1](t.me/{username})
23 | • Developer : [Muhammed](https://github.com/PR0FESS0R-99)
24 | • Language : Python3
25 | • Library : Pyrogram v{version}
26 | • Updates : Click Here
27 | • Source Code : Click Here"""
28 |
29 | @AutoCaptionBot.on_message(pyrogram.filters.private & pyrogram.filters.command(["start"]))
30 | def start_command(bot, update):
31 | update.reply(start_message.format(update.from_user.mention), reply_markup=start_buttons(bot, update), parse_mode=pyrogram.enums.ParseMode.HTML, disable_web_page_preview=True)
32 |
33 | @AutoCaptionBot.on_callback_query(pyrogram.filters.regex("start"))
34 | def strat_callback(bot, update):
35 | update.message.edit(start_message.format(update.from_user.mention), reply_markup=start_buttons(bot, update.message), parse_mode=pyrogram.enums.ParseMode.HTML, disable_web_page_preview=True)
36 |
37 | @AutoCaptionBot.on_callback_query(pyrogram.filters.regex("about"))
38 | def about_callback(bot, update):
39 | bot = bot.get_me()
40 | update.message.edit(about_message.format(version=pyrogram.__version__, username=bot.mention), reply_markup=about_buttons(bot, update.message), parse_mode=pyrogram.enums.ParseMode.HTML, disable_web_page_preview=True)
41 |
42 | @AutoCaptionBot.on_message(pyrogram.filters.channel)
43 | def edit_caption(bot, update: pyrogram.types.Message):
44 | if os.environ.get("custom_caption"):
45 | motech, _ = get_file_details(update)
46 | try:
47 | try: update.edit(custom_caption.format(file_name=motech.file_name))
48 | except pyrogram.errors.FloodWait as FloodWait:
49 | asyncio.sleep(FloodWait.value)
50 | update.edit(custom_caption.format(file_name=motech.file_name, mote))
51 | except pyrogram.errors.MessageNotModified: pass
52 | else:
53 | return
54 |
55 | def get_file_details(update: pyrogram.types.Message):
56 | if update.media:
57 | for message_type in (
58 | "photo",
59 | "animation",
60 | "audio",
61 | "document",
62 | "video",
63 | "video_note",
64 | "voice",
65 | # "contact",
66 | # "dice",
67 | # "poll",
68 | # "location",
69 | # "venue",
70 | "sticker"
71 | ):
72 | obj = getattr(update, message_type)
73 | if obj:
74 | return obj, obj.file_id
75 |
76 | def start_buttons(bot, update):
77 | bot = bot.get_me()
78 | buttons = [[
79 | pyrogram.types.InlineKeyboardButton("Updates", url="t.me/Mo_Tech_YT"),
80 | pyrogram.types.InlineKeyboardButton("About 🤠", callback_data="about")
81 | ],[
82 | pyrogram.types.InlineKeyboardButton("➕️ Add To Your Channel ➕️", url=f"http://t.me/{bot.username}?startchannel=true")
83 | ]]
84 | return pyrogram.types.InlineKeyboardMarkup(buttons)
85 |
86 | def about_buttons(bot, update):
87 | buttons = [[
88 | pyrogram.types.InlineKeyboardButton("🏠 Back To Home 🏠", callback_data="start")
89 | ]]
90 | return pyrogram.types.InlineKeyboardMarkup(buttons)
91 |
92 | print("Telegram AutoCaption V1 Bot Start")
93 | print("Bot Created By https://github.com/PR0FESS0R-99")
94 |
95 | AutoCaptionBot.run()
96 |
--------------------------------------------------------------------------------