-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,348 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM ubuntu:20.04 | ||
|
||
|
||
RUN mkdir /app | ||
RUN chmod 777 /app | ||
WORKDIR /app | ||
|
||
RUN apt -qq update | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV TZ=Asia/Kolkata | ||
|
||
|
||
RUN apt -qq install -y git aria2 wget curl busybox python3 ffmpeg python3-pip | ||
|
||
COPY requirements.txt . | ||
RUN pip3 install --no-cache-dir -r requirements.txt | ||
COPY . . | ||
CMD ["bash","start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
worker: python3 -m bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,53 @@ | ||
# SC-Video-Compressor-Bot | ||
--- | ||
|
||
## Video Compressor Bot | ||
|
||
## HOW TO DEPLOY YOUTUBE TUTORIAL | ||
|
||
<a href="https://youtu.be/YEwAN3iTGyE"><img src="https://img.shields.io/badge/How%20To-Deploy-red.svg?logo=Youtube"></a> | ||
|
||
#### The Easy Way | ||
|
||
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Jijinr/VidComBot) | ||
|
||
#### The Hard Way | ||
|
||
```sh | ||
virtualenv -p python3 VENV | ||
. ./VENV/bin/activate | ||
pip install -r requirements.txt | ||
# <Create config.py with variables as given below> | ||
python bot.py | ||
``` | ||
|
||
An example `config.py` file could be: | ||
|
||
**Not All of the variables are mandatory** | ||
|
||
```python3 | ||
from sample_config import Config | ||
class Development(Config): | ||
APP_ID = 6 | ||
API_HASH = "eb06d4abfb49dc3eeb1aeb98ae0f581e" | ||
TG_BOT_TOKEN = "" | ||
AUTH_USERS = [ | ||
7351948 | ||
] | ||
``` | ||
|
||
### [@BotFather](https://telegram.dog/BotFather) Commands | ||
|
||
``` | ||
start - Checking bot live. | ||
compress - To compress the video. | ||
cancel - Stop the process. | ||
log - Get log | ||
help - To know about bot | ||
``` | ||
## CREDITS | ||
|
||
[@SpEcHide](https://github.com/spechide/publicleech) | ||
|
||
#### LICENSE | ||
- GPLv3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "VideoCompressBot", | ||
"description": "Telegram's best Video Compress Bot", | ||
"logo": "https://telegra.ph/file/b687febf32e4d583fb1d4.jpg", | ||
"keywords": [ | ||
"telegram", | ||
"best", | ||
"video", | ||
"compress", | ||
"bot" | ||
], | ||
"success_url": "https://telegram.dog/VidComBot", | ||
"website": "https://t.me/DX_Botz", | ||
"repository": "https://github.com/Jijinr/VidComBot", | ||
"env": { | ||
"ENV": { | ||
"description": "Setting this to ANYTHING will enable VARs when in ENV mode", | ||
"value": "ANYTHING" | ||
}, | ||
"TG_BOT_TOKEN": { | ||
"description": "Your bot token, as a string.", | ||
"value": "" | ||
}, | ||
"APP_ID": { | ||
"description": "Get this value from https://my.telegram.org or @usetgxbot", | ||
"value": "" | ||
}, | ||
"API_HASH": { | ||
"description": "Get this value from https://my.telegram.org or @usetgxbot", | ||
"value": "" | ||
}, | ||
"AUTH_USERS": { | ||
"description": "allow only pre-defined users to use this bot", | ||
"value": "699615803 809546777" | ||
}, | ||
"FINISHED_PROGRESS_STR": { | ||
"description": "should be a single character.", | ||
"required": false | ||
}, | ||
"UN_FINISHED_PROGRESS_STR": { | ||
"description": "should be a single character.", | ||
"required": false | ||
} | ||
}, | ||
"stack": "container" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# (c) Shrimadhav U K | ||
|
||
# the logging things | ||
import logging | ||
from logging.handlers import RotatingFileHandler | ||
import os | ||
import time | ||
|
||
|
||
from bot.config import Config | ||
|
||
|
||
# TODO: is there a better way? | ||
TG_BOT_TOKEN = Config.TG_BOT_TOKEN | ||
APP_ID = Config.APP_ID | ||
API_HASH = Config.API_HASH | ||
AUTH_USERS = set(Config.AUTH_USERS) | ||
AUTH_USERS = list(AUTH_USERS) | ||
DOWNLOAD_LOCATION = Config.DOWNLOAD_LOCATION | ||
MAX_FILE_SIZE = Config.MAX_FILE_SIZE | ||
TG_MAX_FILE_SIZE = Config.TG_MAX_FILE_SIZE | ||
FREE_USER_MAX_FILE_SIZE = Config.FREE_USER_MAX_FILE_SIZE | ||
MAX_MESSAGE_LENGTH = Config.MAX_MESSAGE_LENGTH | ||
FINISHED_PROGRESS_STR = Config.FINISHED_PROGRESS_STR | ||
UN_FINISHED_PROGRESS_STR = Config.UN_FINISHED_PROGRESS_STR | ||
SHOULD_USE_BUTTONS = Config.SHOULD_USE_BUTTONS | ||
BOT_START_TIME = time.time() | ||
LOG_FILE_ZZGEVC = Config.LOG_FILE_ZZGEVC | ||
|
||
if os.path.exists(LOG_FILE_ZZGEVC): | ||
with open(LOG_FILE_ZZGEVC, "r+") as f_d: | ||
f_d.truncate(0) | ||
|
||
# the logging things | ||
logging.basicConfig( | ||
level=logging.DEBUG, | ||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", | ||
datefmt="%d-%b-%y %H:%M:%S", | ||
handlers=[ | ||
RotatingFileHandler( | ||
LOG_FILE_ZZGEVC, | ||
maxBytes=FREE_USER_MAX_FILE_SIZE, | ||
backupCount=10 | ||
), | ||
logging.StreamHandler() | ||
] | ||
) | ||
logging.getLogger("pyrogram").setLevel(logging.WARNING) | ||
logging.getLogger("urllib3").setLevel(logging.WARNING) | ||
LOGGER = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# (c) Shrimadhav U K | ||
|
||
|
||
import os | ||
|
||
from bot import ( | ||
APP_ID, | ||
API_HASH, | ||
AUTH_USERS, | ||
DOWNLOAD_LOCATION, | ||
LOGGER, | ||
TG_BOT_TOKEN | ||
) | ||
from bot.plugins.new_join_fn import ( | ||
help_message_f | ||
) | ||
|
||
from pyrogram import ( | ||
Client, | ||
Filters, | ||
MessageHandler, | ||
CallbackQueryHandler | ||
) | ||
|
||
from bot.plugins.incoming_message_fn import ( | ||
incoming_start_message_f, | ||
incoming_compress_message_f, | ||
incoming_cancel_message_f | ||
) | ||
|
||
|
||
from bot.plugins.status_message_fn import ( | ||
exec_message_f, | ||
upload_log_file | ||
) | ||
|
||
from bot.commands import Command | ||
from bot.plugins.call_back_button_handler import button | ||
|
||
if __name__ == "__main__" : | ||
# create download directory, if not exist | ||
if not os.path.isdir(DOWNLOAD_LOCATION): | ||
os.makedirs(DOWNLOAD_LOCATION) | ||
# | ||
sessions = "/app/sessions" | ||
if not os.path.isdir(sessions): | ||
os.makedirs(sessions) | ||
app = Client( | ||
"SGVideoCompressBot", | ||
bot_token=TG_BOT_TOKEN, | ||
api_id=APP_ID, | ||
api_hash=API_HASH, | ||
workers=2 | ||
) | ||
# | ||
app.set_parse_mode("html") | ||
# | ||
# START command | ||
incoming_start_message_handler = MessageHandler( | ||
incoming_start_message_f, | ||
filters=Filters.command([Command.START]) & Filters.chat(chats=AUTH_USERS) | ||
) | ||
app.add_handler(incoming_start_message_handler) | ||
|
||
# COMPRESS command | ||
incoming_compress_message_handler = MessageHandler( | ||
incoming_compress_message_f, | ||
filters=Filters.command([Command.COMPRESS]) & Filters.chat(chats=AUTH_USERS) | ||
) | ||
app.add_handler(incoming_compress_message_handler) | ||
|
||
# CANCEL command | ||
incoming_cancel_message_handler = MessageHandler( | ||
incoming_cancel_message_f, | ||
filters=Filters.command([Command.CANCEL]) & Filters.chat(chats=AUTH_USERS) | ||
) | ||
app.add_handler(incoming_cancel_message_handler) | ||
|
||
# MEMEs COMMANDs | ||
exec_message_handler = MessageHandler( | ||
exec_message_f, | ||
filters=Filters.command([Command.EXEC]) & Filters.chat(chats=AUTH_USERS) | ||
) | ||
app.add_handler(exec_message_handler) | ||
|
||
# HELP command | ||
help_text_handler = MessageHandler( | ||
help_message_f, | ||
filters=Filters.command([Command.HELP]) & Filters.chat(chats=AUTH_USERS) | ||
) | ||
app.add_handler(help_text_handler) | ||
|
||
# Telegram command to upload LOG files | ||
upload_log_f_handler = MessageHandler( | ||
upload_log_file, | ||
filters=Filters.command([Command.UPLOAD_LOG_FILE]) & Filters.chat(chats=AUTH_USERS) | ||
) | ||
app.add_handler(upload_log_f_handler) | ||
|
||
call_back_button_handler = CallbackQueryHandler( | ||
button | ||
) | ||
app.add_handler(call_back_button_handler) | ||
|
||
# run the APPlication | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# (c) PublicLeech Author(s) | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
|
||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
|
||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
from bot.get_cfg import get_config | ||
|
||
|
||
class Command: | ||
START = get_config( | ||
"COMMAND_START", | ||
"start" | ||
) | ||
COMPRESS = get_config( | ||
"COMMAND_COMPRESS", | ||
"compress" | ||
) | ||
CANCEL = get_config( | ||
"COMMAND_CANCEL", | ||
"cancel" | ||
) | ||
STATUS = get_config( | ||
"COMMAND_STATUS", | ||
"status" | ||
) | ||
EXEC = get_config( | ||
"COMMAND_EXEC", | ||
"exec" | ||
) | ||
HELP = get_config( | ||
"COMMAND_HELP", | ||
"help" | ||
) | ||
UPLOAD_LOG_FILE = get_config( | ||
"COMMAND_UPLOAD_LOG_FILE", | ||
"log" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
from bot.get_cfg import get_config | ||
|
||
class Config(object): | ||
# get a token from @BotFather | ||
TG_BOT_TOKEN = get_config("TG_BOT_TOKEN", "") | ||
# The Telegram API things | ||
APP_ID = int(get_config("APP_ID", 12345)) | ||
API_HASH = get_config("API_HASH") | ||
# Get these values from my.telegram.org | ||
# array to store the channel ID who are authorized to use the bot | ||
AUTH_USERS = set( | ||
int(x) for x in get_config( | ||
"AUTH_USERS", | ||
should_prompt=True | ||
).split() | ||
) | ||
# the download location, where the HTTP Server runs | ||
DOWNLOAD_LOCATION = get_config("DOWNLOAD_LOCATION", "/app/DOWNLOADS") | ||
# Telegram maximum file upload size | ||
MAX_FILE_SIZE = 1572864000 | ||
TG_MAX_FILE_SIZE = 1572864000 | ||
FREE_USER_MAX_FILE_SIZE = 1572864000 | ||
# default thumbnail to be used in the videos | ||
DEF_THUMB_NAIL_VID_S = get_config("DEF_THUMB_NAIL_VID_S", "https://placehold.it/90x90") | ||
# proxy for accessing youtube-dl in GeoRestricted Areas | ||
# Get your own proxy from https://github.com/rg3/youtube-dl/issues/1091#issuecomment-230163061 | ||
HTTP_PROXY = get_config("HTTP_PROXY", None) | ||
# maximum message length in Telegram | ||
MAX_MESSAGE_LENGTH = 4096 | ||
# add config vars for the display progress | ||
FINISHED_PROGRESS_STR = get_config("FINISHED_PROGRESS_STR", "🟩") | ||
UN_FINISHED_PROGRESS_STR = get_config("UN_FINISHED_PROGRESS_STR", "⬛") | ||
LOG_FILE_ZZGEVC = get_config("LOG_FILE_ZZGEVC", "Log.txt") | ||
# because, https://t.me/c/1494623325/5603 | ||
SHOULD_USE_BUTTONS = get_config("SHOULD_USE_BUTTONS", False) |
Oops, something went wrong.