Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
Heroku files removed. ! some minor code fixes.
  • Loading branch information
m4mallu committed Apr 30, 2024
1 parent 4d4b8d2 commit 38ad8fc
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 145 deletions.
107 changes: 58 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,97 @@
<h1 align="left">
<a target="_blank">
Clonebot
<img src="http://www.randomnoun.com/wpf/shell32-avi/tshell32_160.gif" width="272" height="60">
</a>
</h1>

#### An <a href="https://choosealicense.com/licenses/gpl-3.0/" target="_blank"> opensource </a> Telegram robot can clone media & text from any chat to your own chat.<br>
Read the <a href="https://space4renjith.blogspot.com/2022/05/clonebot-technical-documentation.html" target="_blank"> documentation </a>to know how to use the bot
# Clonebot

[![Clonebot Logo](http://www.randomnoun.com/wpf/shell32-avi/tshell32_160.gif)](#)

#### An [opensource](https://choosealicense.com/licenses/gpl-3.0/) Telegram robot can clone media & text from any chat to your own chat.
Read the [documentation](https://space4renjith.blogspot.com/2022/05/clonebot-technical-documentation.html) to know how to use the bot

---

**DUE TO SOME SECURITY REASONS, DEPLOY TO HEROKU FROM THIS REPOSITORY HAS BEEN ABOLISHED!**
<br>
<p align="left">
<br>
<b>DUE TO SOME SECURITY REASONS, DEPLOY TO HEROKU FROM THIS REPOSITORY HAS BEEN ABOLISHED !</b>
<br>
<u>This repository is no longer supporting Heroku deployment. Use a paid VPS / Raspberry Pi / Local pc instead. See the documentation for more.</u>
<br><br>
<a href="https://t.me/rmprojects" target="_blank">@M4Mallu</a>
</p>
*This repository is no longer supporting Heroku deployment. Use a paid VPS / Raspberry Pi / Local PC instead. See the documentation for more.*

[@M4Mallu](https://t.me/rmprojects)

<details>
<summary><b>Deploy Using Docker</b></summary>
1. Deploying on VPS Using Docker

- Start Docker daemon (skip if already running), if installed by snap then use 2nd command:
1. **Deploying on VPS Using Docker**

- Start Docker daemon (skip if already running), if installed by snap then use 2nd command:

```bash
sudo dockerd
sudo snap start docker
```

Note: If not started or not starting, run the command below then try to start.
Note: If not started or not starting, run the command below then try to start.

```bash
sudo apt install docker.io
```

- Build Docker image:
- Build Docker image:

```bash
sudo docker build . -t clone-bot
```

- Run the image:
- Run the image:

```bash
sudo docker run clone-bot
```

- To stop the image:
- To stop the image:

```bash
sudo docker ps
sudo docker stop id
```

- To clear the container:
- To clear the container:

```bash
sudo docker container prune
```

- To delete the images:
- To delete the images:

```bash
sudo docker image prune -a
```

2. Deploying on VPS Using docker-compose

**NOTE**: If you want to use port other than 80, change it in docker-compose.yml

```
sudo apt install docker-compose
```
- Build and run Docker image:
```
sudo docker-compose up
```
- After editing files with nano for example (nano start.sh):
```
sudo docker-compose up --build
```
- To stop the image:
```
sudo docker-compose stop
```
- To run the image:
```
sudo docker-compose start
```
2. **Deploying on VPS Using docker-compose**

</details>
**NOTE**: If you want to use a port other than 80, change it in docker-compose.yml

```bash
sudo apt install docker-compose
```

- Build and run Docker image:

```bash
sudo docker-compose up
```

- After editing files with nano for example (nano start.sh):

```bash
sudo docker-compose up --build
```

- To stop the image:

```bash
sudo docker-compose stop
```

- To run the image:

```bash
sudo docker-compose start
```

</details>
32 changes: 0 additions & 32 deletions app.json

This file was deleted.

10 changes: 2 additions & 8 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
#----------------------------------- https://github.com/m4mallu/clonebot --------------------------------------------#
import os
import sys
from user import User
from pyrogram import Client
from presets import Presets as Msg
from pyrogram.enums import ParseMode


if bool(os.environ.get("ENV", False)):
from sample_config import Config
from sample_config import LOGGER
else:
from config import Config
from config import LOGGER
from config import Config
from config import LOGGER


class Bot(Client):
Expand Down
2 changes: 1 addition & 1 deletion library/chat_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def date_time_calc(start_date, start_time, cur_date, cur_time):
return f'{date_diff}D', time_diff


# Functions to set the bot vaiables to default values
# Functions to set the bot variables to default values
async def set_to_defaults(id):
await reset_all(id)
file_types.clear()
Expand Down
8 changes: 1 addition & 7 deletions library/sql.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import os
import threading
from config import Config
from sqlalchemy import create_engine
from sqlalchemy import Column, Boolean, Numeric
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session


clone_cancel_key = {} # Clone cancel status key
clone_btn_count = {} # Clone button single click actuator key
index_skip_key = {} # Skip indexing function key
Expand All @@ -15,11 +14,6 @@
master_index = [] # Unique id index of cloning medias (including target chat)
file_types = ["document", "video", "audio", "voice", "photo", "text"]

if bool(os.environ.get("ENV", False)):
from sample_config import Config
else:
from config import Config

def start() -> scoped_session:
engine = create_engine(Config.DB_URI, client_encoding="utf8")
BASE.metadata.bind = engine
Expand Down
7 changes: 1 addition & 6 deletions plugins/cb_button.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ----------------------------------- https://github.com/m4mallu/clonebot ---------------------------------------------#
import os
import sys
from bot import Bot
from library.sql import *
Expand All @@ -12,12 +13,6 @@
from plugins.commands import reply_markup_home
from plugins.index_files import index_target_chat, purge_media

if bool(os.environ.get("ENV", False)):
from sample_config import Config
else:
from config import Config


@Client.on_callback_query(filters.regex(r'^start_btn$'))
async def start_settings(client: Bot, cb: CallbackQuery):
user = await Bot.get_me(self=client.USER)
Expand Down
2 changes: 1 addition & 1 deletion plugins/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def clone_medias(bot: Bot, m: Message):
else:
delay = 3
#
# The vaulues will be swithed if the start message id is greater than the end message id
# The values will be switched if the start message id is greater than the end message id
if start_id > end_id:
start_id = start_id ^ end_id
end_id = end_id ^ start_id
Expand Down
1 change: 0 additions & 1 deletion plugins/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ async def force_reply_msg(client: Bot, message: Message):
chat_info = message.text
id = int(message.from_user.id)
chat_status = []
member_status = []
user_bot_me = await client.USER.get_me()
query = await query_msg(id)
a = int(query.s_chat_msg_id)
Expand Down
1 change: 1 addition & 0 deletions plugins/index_files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ----------------------------------- https://github.com/m4mallu/clonebot ---------------------------------------------#
import os
import asyncio
from bot import Bot
from library.sql import *
Expand Down
4 changes: 2 additions & 2 deletions presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,6 @@ class Presets(object):
<u><b>Credits:</u></b> https://github.com/m4mallu
"""
GET_CHAT_ID_MSG = "<b>You have been forwaded a message\nfrom a chat having the id:</b>\n\n<code>{" \
GET_CHAT_ID_MSG = "<b>You have been forwarded a message\nfrom a chat having the id:</b>\n\n<code>{" \
"}</code>\n<b>Message Id: </b><code>{}</code>\n\n<i>Tap the above text to copy !</i> "
CLONE_REPORT_INFO = "A report has been generted in your SAVED MESSAGES folder. Thanks for using this bot 🤝"
CLONE_REPORT_INFO = "A report has been generated in your SAVED MESSAGES folder. Thanks for using this bot 🤝"
14 changes: 9 additions & 5 deletions run.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
echo
echo
echo "Credits: m4mallu> https://github.com/m4mallu"
echo
sleep 1
clear >$(tty)
virtualenv -p python3 venv > /dev/null
. ./venv/bin/activate > /dev/null
echo "Installing requirements, please wait..."
pip3 install -r requirements.txt > /dev/null
echo "Done! Starting the bot..."
echo
sleep 1
clear >$(tty)
echo "Starting the bot, please wait..."
sleep 1
clear >$(tty)
python3 main.py
20 changes: 0 additions & 20 deletions sample-vps-config.py

This file was deleted.

11 changes: 5 additions & 6 deletions sample_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#----------------------------------- https://github.com/m4mallu/clonebot --------------------------------------------#
import os
import logging

logging.basicConfig(
Expand All @@ -12,19 +11,19 @@
class Config(object):

# Get a bot token from botfather
TG_BOT_TOKEN = os.environ.get("TG_BOT_TOKEN", "")
TG_BOT_TOKEN = "Your_Telegram_bot_token"

# Get from my.telegram.org
APP_ID = int(os.environ.get("APP_ID", ""))
APP_ID = int(Your_telegram_App_Id)

# Get from my.telegram.org
API_HASH = os.environ.get("API_HASH", "")
API_HASH = "Your_Telegram_Api_Hash"

# Generate a user session string
TG_USER_SESSION = os.environ.get("TG_USER_SESSION", "")
TG_USER_SESSION = "Your_user_session_string_compatible_with_Pyrogram_v2"

# Database URI
DB_URI = os.environ.get("DATABASE_URL", "")
DB_URI = "Your_database_URI"


def LOGGER(name: str) -> logging.Logger:
Expand Down
9 changes: 2 additions & 7 deletions user.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#----------------------------------- https://github.com/m4mallu/clonebot --------------------------------------------#
import os
from pyrogram import Client
from pyrogram.enums import ParseMode

if os.environ.get("ENV", False):
from sample_config import Config
from sample_config import LOGGER
else:
from config import Config
from config import LOGGER
from config import Config
from config import LOGGER

class User(Client):
def __init__(self):
Expand Down

0 comments on commit 38ad8fc

Please sign in to comment.