Jack commited on
Commit
134fc6f
1 Parent(s): 2e58aed
Files changed (4) hide show
  1. Dockerfile +39 -0
  2. LICENSE +21 -0
  3. README.md +1 -10
  4. main.py +44 -0
Dockerfile ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python image as a base image
2
+ FROM python:3.10-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1 \
6
+ PYTHONDONTWRITEBYTECODE=1
7
+
8
+ # Add a non-root user
9
+ RUN useradd -ms /bin/bash myuser
10
+
11
+ # Install system dependencies
12
+ RUN apt-get update && apt-get install -y \
13
+ sudo \
14
+ build-essential \
15
+ libpq-dev \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Grant sudo privileges to the non-root user
19
+ RUN echo "myuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/myuser
20
+
21
+ # Update the system
22
+ RUN apt-get update && apt-get upgrade -y
23
+
24
+ # Set the working directory in the container
25
+ WORKDIR /app
26
+
27
+ # Copy the requirements file and install dependencies
28
+ COPY requirements.txt .
29
+ RUN pip install --no-cache-dir -r requirements.txt
30
+
31
+ # Copy the Python script and .env file into the container
32
+ COPY main.py .
33
+ COPY .env .
34
+
35
+ # Switch to the non-root user
36
+ USER myuser
37
+
38
+ # Run the Python script
39
+ CMD ["python", "main.py"]
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Silent Demon SD ( MysterySD )
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.
README.md CHANGED
@@ -1,10 +1 @@
1
- ---
2
- title: EditBot
3
- emoji: 👁
4
- colorFrom: gray
5
- colorTo: purple
6
- sdk: docker
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ ###
 
 
 
 
 
 
 
 
 
main.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ from logging import basicConfig, INFO, getLogger
3
+ from os import getenv
4
+ from dotenv import load_dotenv
5
+ from pyrogram import Client, filters
6
+
7
+ basicConfig(level=INFO, format="[%(levelname)s] %(asctime)s - %(message)s")
8
+ log = getLogger(__name__)
9
+
10
+ load_dotenv('.env', override=True)
11
+
12
+ API_ID = int(getenv("API_ID", 0))
13
+ API_HASH = getenv("API_HASH")
14
+ BOT_TOKEN = getenv('BOT_TOKEN')
15
+
16
+ if BOT_TOKEN:
17
+ try:
18
+ bot = Client("TgBotStadtus", api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN)
19
+ except Exception as e:
20
+ log.warning(e)
21
+ exit(1)
22
+
23
+ @bot.on_message(filters.channel & (filters.document | filters.video))
24
+ async def change_caption(client, message):
25
+ # Add your logic here to handle the message
26
+ if message.video:
27
+ hash = message.video.file_unique_id[:6]
28
+ elif message.document:
29
+ hash = message.document.file_unique_id[:6]
30
+ l = f"""Fast Download Link:\n <a href="https://f2l.mrprincebotz.workers.dev/{message.chat.id}?id={message.id}&hash={hash}">ᗪOᗯᑎᒪOᗩᗪ ᕼᗴᖇᗴ</a>\n"""
31
+ h=message.caption
32
+ # Extracting duration from the string h
33
+ duration_start = h.find("Dᴜʀᴀᴛɪᴏɴ:") + len("Dᴜʀᴀᴛɪᴏɴ:")
34
+ duration_end = h.find("\n", duration_start)
35
+ duration = h[duration_start:duration_end]
36
+
37
+ # Combining strings h, duration, and l
38
+ combined_message = f"{h[:duration_end]}\n\n{l}\nUᴘʟᴏᴀᴅᴇᴅ ʙʏ 🔥 TᴇᴀᴍMʀPʀɪɴᴄᴇ 🔥"
39
+ print(combined_message)
40
+ await message.edit_caption(combined_message)
41
+
42
+
43
+ if __name__ == '__main__':
44
+ bot.run()