Skip to content

Commit

Permalink
Update pixelateTG.py
Browse files Browse the repository at this point in the history
  • Loading branch information
arbadacarbaYK authored May 26, 2024
1 parent 50826ed commit 3d32a09
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions pixelateTG.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,13 @@ def overlay(photo_path, user_id, overlay_type, resize_factor, bot):

return processed_path

# looking for one straight file

# Overlay functions
def liotta_overlay(photo_path, user_id, bot):
return overlay(photo_path, user_id, 'liotta', RESIZE_FACTOR, bot)

def skull_overlay(photo_path, user_id, bot):
return overlay(photo_path, user_id, 'skullofsatoshi', RESIZE_FACTOR, bot)

# looking for a random file out of a similar naming

def pepe_overlay(photo_path, user_id, bot):
return overlay(photo_path, user_id, 'pepe', RESIZE_FACTOR, bot)

Expand All @@ -97,14 +94,13 @@ def pixelate_faces(update: Update, context: CallbackContext) -> None:
image = cv2.imread(photo_path)
mtcnn = MTCNN()
faces = mtcnn.detect_faces(image)

chat_type = update.effective_chat.type
if chat_type == "private": # Direct message
if not faces:
# No faces detected, do nothing
return

keyboard = [
if not faces:
# No faces detected, do nothing
update.message.reply_text('No faces detected in the image.')
return

keyboard = [
[InlineKeyboardButton("🤡 Clowns", callback_data=f'clowns_overlay_{session_id}'),
InlineKeyboardButton("😂 Liotta", callback_data=f'liotta_{session_id}'),
InlineKeyboardButton("☠️ Skull", callback_data=f'skull_of_satoshi_{session_id}')],
Expand All @@ -114,14 +110,15 @@ def pixelate_faces(update: Update, context: CallbackContext) -> None:
[InlineKeyboardButton("⚔️ Pixel", callback_data=f'pixelate_{session_id}'),
InlineKeyboardButton("CANCEL", callback_data=f'cancel_{session_id}')], # Add Cancel button
]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Press until happy', reply_markup=reply_markup)
reply_markup = InlineKeyboardMarkup(keyboard)
context.user_data[session_id]['photo_path'] = photo_path
context.user_data[session_id]['user_id'] = update.message.from_user.id

context.user_data[session_id]['photo_path'] = photo_path
context.user_data[session_id]['user_id'] = update.message.from_user.id
# Delete the original picture from the chat
if update.effective_chat.type == "private":
update.message.reply_text('Press until happy', reply_markup=reply_markup)
update.message.delete()

else:
update.message.reply_text('Press until happy', reply_markup=reply_markup)

def process_image(photo_path, user_id, file_id, bot):
image = cv2.imread(photo_path)
Expand All @@ -140,7 +137,6 @@ def process_face(x, y, w, h):

return processed_path


def button_callback(update: Update, context: CallbackContext) -> None:
query = update.callback_query
query.answer()
Expand Down

0 comments on commit 3d32a09

Please sign in to comment.