-
Notifications
You must be signed in to change notification settings - Fork 9
Feature addded (2) #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abinashzpathak123-web
wants to merge
3
commits into
Mr3rf1:main
Choose a base branch
from
abinashzpathak123-web:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,4 +1,4 @@ | ||
| # t.me/Mr3rf1 | ||
| # t.me/Mr3rf1 | @rickmorti12 | ||
|
|
||
| api_id = 1234567 # set your own api_id | ||
| api_hash = "82bd7b4562f7ju24d182bdc38huj9352" # set your own api_key | ||
|
|
@@ -16,10 +16,23 @@ async def main(): | |
| from jdatetime import datetime | ||
| from pytz import timezone | ||
| import sqlite3 | ||
| import hashlib | ||
| except ImportError: | ||
| print(' [!] Please install dependencies~> python3 -m pip install -r requirements.txt') | ||
| exit(0) | ||
|
|
||
| # ---- NEW: Duplicate detection (session only) ---- | ||
| seen_hashes = set() | ||
|
|
||
| def get_file_hash(file_path): | ||
| """Compute SHA256 hash for a file.""" | ||
| sha256 = hashlib.sha256() | ||
| with open(file_path, "rb") as f: | ||
| for chunk in iter(lambda: f.read(4096), b""): | ||
| sha256.update(chunk) | ||
| return sha256.hexdigest() | ||
| # ------------------------------------------------- | ||
|
|
||
| def get_phone_number(): | ||
| """Get phone number with validation for international format""" | ||
| while True: | ||
|
|
@@ -135,19 +148,51 @@ async def handler(event): | |
| if hasattr(event.message.media, 'photo') and event.message.media.photo: | ||
| print(f' {Fore.YELLOW}[{Fore.RED}!{Fore.YELLOW}]{Fore.RESET} Found self-destructive photo in {chat_title}. Downloading...', end='') | ||
| file_path = await client.download_media(event.message.media, 'secret_photo.jpg') | ||
|
|
||
| # ---- NEW: Duplicate detection ---- | ||
| media_hash = get_file_hash(file_path) | ||
| if media_hash in seen_hashes: | ||
| print(f'\r {Fore.YELLOW}[{Fore.RED}!{Fore.YELLOW}]{Fore.RESET} Duplicate photo detected — skipping.') | ||
| os.remove(file_path) | ||
| return | ||
| seen_hashes.add(media_hash) | ||
| # ---------------------------------- | ||
|
|
||
| if file_path: | ||
| with open(file_path, 'rb') as file: | ||
| await client.send_file('me', file, caption=caption, parse_mode='html') | ||
| print(f'\r {Fore.YELLOW}[{Fore.GREEN}!{Fore.YELLOW}]{Fore.RESET} Secret photo from {chat_title} saved to your messages') | ||
|
|
||
| # ---- NEW: Notification ping ---- | ||
| await client.send_message('me', f"✅ Saved new photo from {chat_title}") | ||
| # -------------------------------- | ||
|
|
||
| os.remove(file_path) | ||
|
|
||
| elif hasattr(event.message.media, 'document') and event.message.media.document: | ||
| print(f' {Fore.YELLOW}[{Fore.RED}!{Fore.YELLOW}]{Fore.RESET} Found self-destructive media in {chat_title}. Downloading...', end='') | ||
| file_path = await client.download_media(event.message.media, 'secret_media') | ||
|
|
||
| # ---- NEW: Duplicate detection ---- | ||
| media_hash = get_file_hash(file_path) | ||
| if media_hash in seen_hashes: | ||
| print(f'\r {Fore.YELLOW}[{Fore.RED}!{Fore.YELLOW}]{Fore.RESET} Duplicate media detected — skipping.') | ||
| os.remove(file_path) | ||
| return | ||
| seen_hashes.add(media_hash) | ||
| # ---------------------------------- | ||
|
|
||
| if file_path: | ||
| with open(file_path, 'rb') as file: | ||
| await client.send_file('me', file, caption=caption, parse_mode='html') | ||
| print(f'\r {Fore.YELLOW}[{Fore.GREEN}!{Fore.YELLOW}]{Fore.RESET} Secret media from {chat_title} saved to your messages') | ||
|
|
||
| # ---- NEW: Notification ping ---- | ||
| await client.send_message('me', f"✅ Saved new media from {chat_title}") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove these notification messages and pull again. thx for contributing |
||
| # -------------------------------- | ||
|
|
||
| os.remove(file_path) | ||
|
|
||
| except Exception as e: | ||
| print(f' {Fore.YELLOW}[{Fore.RED}ERROR{Fore.YELLOW}]{Fore.RESET} Failed to process self-destructive media: {str(e)}') | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove these notification messages and pull again. thx for contributing