Skip to content

Commit

Permalink
the whole code
Browse files Browse the repository at this point in the history
  • Loading branch information
OxMohsen committed May 22, 2022
0 parents commit 31c5a60
Show file tree
Hide file tree
Showing 14 changed files with 524 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vscode
__pycache__
lib
config.py
*.session
log.txt
.idea
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worker: python3 main.py
142 changes: 142 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<div id="top"></div>

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![GPL3 License][license-shield]][license-url]


<br />
<div align="center">
<a href="https://github.com/OxMohsen/uniquify-bot">
<img src="https://img.apksum.com/4c/com.duplicate.files.remover.duplicatefinderfiles/1.0/icon.png" alt="Logo" width="80" height="80">
</a>

<h3 align="center">uniquify bot</h3>

<p align="center">
Uniquify bot is a Telegram bot that deletes duplicate files (Video, Audio, Photo, Voice, and Document) from target chat.
<br />
<a href="https://github.com/OxMohsen/uniquify-bot/issues">Report Bug</a>
·
<a href="https://github.com/OxMohsen/uniquify-bot/issues">Request Feature</a>
</p>
</div>

<details>
<summary>Table of Contents</summary>
<ol>
<li>
<a href="#about-the-project">About The Project</a>
<ul>
<li><a href="#built-with">Built With</a></li>
</ul>
</li>
<li>
<a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#installation">Installation</a></li>
</ul>
</li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
</ol>
</details>



## About The Project

uniquify bot will help you to find and delete duplicate files in your channel or group.
this bot uses `file_unique_id` to find duplicate files, so we can assure you that there is the same file as the deleted file in your group or channel.

<p align="right">(<a href="#top">back to top</a>)</p>



### Built With

* [Python](https://www.python.org/)
* [pyrogram](https://pyrogram.org/)

<p align="right">(<a href="#top">back to top</a>)</p>


## Getting Started

To get a local copy up and running follow these simple example steps.

### Installation

1. Get your `api_id` and `api_hash` in [https://my.telegram.org](https://my.telegram.org)
2. Create a new bot in [https://t.me/botfather](https://t.me/botfather)
3. Clone the repo
```sh
git clone https://github.com/OxMohsen/uniquify-bot.git
```
4. navigate into the new folder
```sh
cd uniquify-bot
```
5. Install python packages
```sh
pip3 install -r requirements.txt
```
5. rename the `sample-config.py` to `config.py`
6. fill the `config.py` with your data
7. run the bot
```sh
python3 main.py
```

if you using heroku, you can deploy the bot with the following button.<br >
<a href="https://heroku.com/deploy?template=https://github.com/OxMohsen/uniquify-bot">
<img height="30px" src="https://img.shields.io/badge/Deploy%20To%20Heroku-blueviolet?style=for-the-badge&logo=heroku">
</a>

<p align="right">(<a href="#top">back to top</a>)</p>

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

<p align="right">(<a href="#top">back to top</a>)</p>


## License

Distributed under the GPLv3 License. See `LICENSE` for more information.

<p align="right">(<a href="#top">back to top</a>)</p>


## Contact

Your Name - [@OxMohsen](https://twitter.com/OxMohsen) - [email protected]

Project Link: [https://github.com/OxMohsen/uniquify-bot](https://github.com/OxMohsen/uniquify-bot)

<p align="right">(<a href="#top">back to top</a>)</p>


[contributors-shield]: https://img.shields.io/github/contributors/OxMohsen/uniquify-bot.svg?style=for-the-badge
[contributors-url]: https://github.com/OxMohsen/uniquify-bot/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/OxMohsen/uniquify-bot.svg?style=for-the-badge
[forks-url]: https://github.com/OxMohsen/uniquify-bot/network/members
[stars-shield]: https://img.shields.io/github/stars/OxMohsen/uniquify-bot.svg?style=for-the-badge
[stars-url]: https://github.com/OxMohsen/uniquify-bot/stargazers
[issues-shield]: https://img.shields.io/github/issues/OxMohsen/uniquify-bot.svg?style=for-the-badge
[issues-url]: https://github.com/OxMohsen/uniquify-bot/issues
[license-shield]: https://img.shields.io/github/license/OxMohsen/uniquify-bot.svg?style=for-the-badge
[license-url]: https://github.com/OxMohsen/uniquify-bot/blob/master/LICENSE
24 changes: 24 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "uniquify-bot",
"description": "Telegram bot to remove duplicate media from a chat",
"keywords": ["telegram", "duplicate", "media", "removing", "bot"],
"logo": "https://img.apksum.com/4c/com.duplicate.files.remover.duplicatefinderfiles/1.0/icon.png",
"website": "https://github.com/OxMohsen/uniquify-bot",
"repository": "https://github.com/OxMohsen/uniquify-bot",
"env": {
"APP_ID": {"description": "Get this value from https://my.telegram.org", "required": true},
"API_HASH": {"description": "Get this value from https://my.telegram.org" , "required": true},
"TG_BOT_TOKEN": {"description": "Get bot token from @BotFather bot","required": true},
"TG_USER_SESSION": {"description": "String session from an admin user.","required": true},
"AUTH_USERS": {"description": "User ids of authorized users separated by space", "required": true}
},
"buildpacks": [
{"url": "heroku/python"}
],
"formation": {
"worker": {
"quantity": 1,
"size": "free"
}
}
}
31 changes: 31 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from pyrogram import Client, enums

from config import LOGGER, Config
from user import User


class Bot(Client):
USER: User = None
USER_ID: int = None

def __init__(self):
super().__init__(
"oxmohsen_bot",
api_hash=Config.API_HASH,
api_id=Config.APP_ID,
bot_token=Config.TG_BOT_TOKEN,
sleep_threshold=0,
plugins={"root": "plugins"},
)
self.LOGGER = LOGGER

async def start(self):
await super().start()
usr_bot_me = await self.get_me()
self.set_parse_mode(enums.ParseMode.HTML)
self.LOGGER(__name__).info(f"Bot {usr_bot_me.first_name} (@{usr_bot_me.username}) started!")
self.USER, self.USER_ID = await User().start()

async def stop(self, *args):
await super().stop()
self.LOGGER(__name__).info("Bot stopped. Bye.")
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from bot import Bot

Bot().run()
36 changes: 36 additions & 0 deletions plugins/call_back.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from bot import Bot
from presets import Presets
from pyrogram import Client, filters
from pyrogram.types import CallbackQuery
from support.buttons import reply_markup_back, reply_markup_start

from plugins.commands import purge_status


@Client.on_callback_query(filters.regex(r"^help_btn$"))
async def help_button(b: Bot, cb: CallbackQuery):
await cb.answer()
await cb.message.edit_text(Presets.HELP_MESSAGE, reply_markup=reply_markup_back)


@Client.on_callback_query(filters.regex(r"^back_btn$"))
async def back_button(b: Bot, cb: CallbackQuery):
await cb.answer()
await cb.message.edit_text(
Presets.WELCOME_MSG.format(cb.from_user.mention),
reply_markup=reply_markup_start,
)


@Client.on_callback_query(filters.regex(r"^close_btn$"))
async def close_button(b: Bot, cb: CallbackQuery):
await cb.message.delete()


@Client.on_callback_query(filters.regex(r"^cancel_btn$"))
async def cancel_button(b: Bot, cb: CallbackQuery):
id = int(cb.from_user.id)
try:
purge_status.pop(id)
except Exception:
pass
Loading

0 comments on commit 31c5a60

Please sign in to comment.